Saturday, June 24, 2023

Glimmer DSL for WX (wxWidgets GUI Toolkit) Using wxruby3

Glimmer gets a new GUI DSL in 2023 called Glimmer DSL for WX (Early Alpha 0.0.5 was built in 1 day) to support the very mature wxWidgets GUI toolkit that renders cross-platform native GUI controls (using a brand new wxruby3 binding)! 

The wxruby3 binding is a Godsend and a great surprise in 2023! A couple of years ago, I actually wanted to cover the wxWidgets GUI toolkit with a Glimmer DSL, but the old wxruby binding was no longer maintained. Thanks to the recent efforts by Martin CorinowxWidgets support in Ruby has been rebooted, bringing back Linux and Windows support first. What makes wxWidgets special compared to other GUI toolkits is that it is 100% mature and it renders native GUI controls on all platforms to build desktop GUI apps that look native and familiar on every operating system, unlike Tk, GTK, and the FOX Toolkit. As such, Glimmer now has 2 GUI DSLs that could render native widgets in standard Ruby (aka MRI or CRuby), Glimmer DSL for LibUI and Glimmer DSL for WX, in addition to the 1 GUI DSL that could render native widgets in JRuby, Glimmer DSL for SWT.

The wxruby3 binding handles the low-level heavy lifting of binding C/C++ code to Ruby code to enable using wxWidgets from Ruby. And, through Layered Architecture, Glimmer handles the top-layer of translating high-level declarative syntax that matches the way application engineers think about GUI into wxruby3 code (middle-layer), and wxruby3 then translates the Ruby low-level code into the lower-level language wxWidgets code (C/C++) (lower-layer), which then translates it to Operating System GUI library code (even-lower-layer), which finally translates the code to machine language code (bottom-layer). As such, similar to how Ruby abstracts away low-level OS details, Glimmer abstracts away low-level GUI imperative logic details by providing software engineers with the simplest most minimalistic syntax possible for building GUI in the most productive and maintainable fashion.

Thankfully, Glimmer's DSL engine enables such a grand leap in productivity that it took only 1 day to build Early Alpha 0.0.5 of Glimmer DSL for WX. The same happened when building Glimmer DSL for FX (supporting the FOX Toolkit via the fxruby binding) about 2 years ago. The productivity of building Glimmer DSLs is so high that it is light years beyond older technologies like Shoes (covered recently in the If You Liked Shoes, You'll Love Glimmer blog post). Thankfully though, Shoes paved the way for newer advancements in GUI using Ruby in a similar way to how Smalltalk and Perl paved the way for creating the Ruby programming language. But, Glimmer is the future of GUI! After all, with a Glimmer DSL, software engineers could start writing GUI apps in wxWidgets with a few lines of code instead of pages and pages of low-level Ruby code, thus quadrupling their productivity, if not going 10x or faster. 

In any case, I am including the top part of the Glimmer DSL for WX README and a couple of samples below.

Glimmer on!!!


No comments: