There are two common ways of going about defining a graphical user interface.
- Declarative UI.
- You adapt a markup language like HTML or XML, possibly in combination with a layout language like CSS, to define the identity and basic placement of widgets and controls.
- You traverse your declared UI using a real programming language like Javascript in order to add functionality and advanced UI features.
- This approach has been adopted by frameworks such as AngularJS, and QT+QML, and is the standard approach for Android UI development.
- Programmatic UI.
- You create and lay-out the elements of the UI directly in a programming language. While you may still achieve separation of concerns by delegating UI creation and layout to a dedicated "View" object, all actions necessary to construct the UI are programmatically guided instead of declaratively specified.
- All older UIs used this approach, and it is commonly used today to construct UIs for a vast variety of desktop frameworks and can also be used to manipulate the web DOM.
- Swing, SWT, GTK, QT, is an option for Android.
Is one approach better than the other? What are the upsides and downsides of each approach?