Which is Which in Newspeak UI – Brazil

Brazil, which is the foundation of Newspeak UI (and is indeed named after the movie), could be best described as a multi-platform logical UI and layout framework. It provides the familiar widgets (“visuals”) such as Labels, Buttons, and ListBoxes, and container visuals for combining widgets and managing their layout. Unlike the UI frameworks of Squeak or VisualWorks, Brazil does not attempt to actually implement the widgets by emulating them. Instead it functions as a “logical UI” layer that builds and drives the equivalent “physical UI” made of native artifacts of the host platform.

The first host platform of Brazil was Morphic–meaning the first “native” Brazil interfaces were in fact emulated. This trick allowed us to quickly build a minimal working implementation and polish the API without getting bogged down with FFI issues and native widget peculiarities early on. Since Morphic works on all OS platforms, so did Brazil from the start, allowing to use it on all platforms we need before we build real native mappings for those platforms.

Brazil also manages the layout of interfaces using a capability-based extensible model. Layout is fully managed by Brazil both on native platforms which usually provide rather weak layout facilities of their own, and in Morphic which provides a rich but baroque one. All that Brazil expects from the host are the abilities to position a widget within the specified rectangle, and to measure its natural (desired) extent.

Work on Brazil began in mid-March 2007 and in June a first real UI was built using it. I am currently working on a native Windows mapping. This work is at an advanced enough stage to be able to open all of the existing Brazil UIs as native in Windows with most functionality in place, without any changes in application code. Brazil windows can also be dynamically remapped, so that what appears as a Morphic window can “jump out” of Squeak and become a native window with native controls, and then go back to Morphic all the while retaining its state.

Unlike prior implementations of native UIs in Smalltalk, Brazil is implemented entirely at the image level. This means that there is not a single VM primitive to support UI operations. The mapping relies on “raw” OS functions accessed via the general-purpose Newspeak FFI to do everything, from Windows class registration to widget management and GDI+ painting.

Tags: ,

3 Responses to “Which is Which in Newspeak UI – Brazil”

  1. Benoit St-Jean says:

    Vassili!! As you’ve heard me say to you so many times in the past, “Wow” ! It says it all! Can’t wait to see how you’ve done that “magic” !

  2. Claus says:

    You said:
    Instead it functions as a “logical UI” layer that builds and drives the equivalent “physical UI” made of native artifacts of the host platform.

    So, basically, isnt that about what Sam Shuster did want to do with his project Chagall for VW?

    You say in your code “A button needs to go there” and some translator code tells the platform windowing system below to “create a button there”?

  3. Vassili Bykov says:

    Claus:
    At that level of detail, yes, this is what I mean by logical UI. It is indeed close to what Chagall was supposed to be, but IBM Smalltalk’s Common Widgets is closer still (at least to the extent that I’m familiar with it), in that mapping to native widgets is the primary goal.

Leave a Reply

For spam filtering purposes, please copy the number 9307 to the field below: