Monday, October 18, 2021

Befunge GUI by Glimmer (2 for 1: LibUI & SWT)

In light of the recent Beta release of Glimmer DSL for LibUI, I have been looking for applications that could take advantage of its productivity and speed in building desktop GUI with its Ruby DSL. One such application has been Befunge98 GUI, built for a Ruby implementation of the Befunge-98 programming language done by Victor Maslov (GitHub username: Nakilon).

According to Wikipedia, Befunge is a two-dimensional stack-based, reflective, esoteric programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid. "Arrow" instructions direct the control flow to the left, right, up or down, and loops are constructed by sending the control flow in a cycle. It has been described as "a cross between Forth and Lemmings".

In fact, I built its GUI twice with two different approaches, one using the up and coming Glimmer DSL for LibUI on CRuby relying on a multi-canvas-grid (LibUI area) approach, and one using the very mature Glimmer DSL for SWT on JRuby by relying on a button-grid + data-binding approach.

Thanks to Glimmer's highly productive GUI DSLs, both implementations took me no more than a few hours. In fact, they both took 5 minutes for the initial simplest version that received Befunge input from GUI and rendered output to terminal. Afterwards, the simplest version was upgraded with bidirectional synchronization between the input grid and input multiline-entry/text field in addition to auto-saving/loading of the last program entered and a window-based output terminal or a read-only multiline-entry output control.

Befunge98 GUI (Glimmer DSL for LibUI)


Befunge98 GUI (Glimmer DSL for SWT)



Happy Glimmering!



Friday, October 08, 2021

Glimmer DSL for LibUI Beta Release

I recently mentioned that a new Glimmer DSL was brewing; that is Glimmer DSL for LibUI

It has been a passion project for the last 3 weeks that ended today with Glimmer DSL for LibUI becoming feature-complete and moving from Alpha to Beta.

What is LibUI?

LibUI is a thin Ruby wrapper around libui, a relatively new C GUI library that renders native controls on every platform (similar to SWT, but without the heavy weight of the Java Virtual Machine).

One of the biggest benefits of Glimmer DSL for LibUI as opposed to Glimmer DSL for SWT is that it is a prerequisite-free MRI CRuby desktop development GUI library. No need to pre-install any prerequisites. Just install the gem and have platform-independent native GUI that just works!

The main trade-off in using Glimmer DSL for LibUI as opposed to Glimmer DSL for SWT or Glimmer DSL for Tk is the fact that SWT and Tk are more mature than mid-alpha libui as GUI toolkits. Still, if there is only a need to build a small simple application, Glimmer DSL for LibUI could be a good convenient choice due to having zero prerequisites beyond the dependencies included in the Ruby gem. Also, just like Glimmer DSL for Tk, its apps start instantly and have a small memory footprint. LibUI is a promising new GUI toolkit that might prove quite worthy in the future.

One nifty innovation that this project came up with is implicit data-binding for table data as you will see in the table example below.

Glimmer DSL for LibUI aims to provide a DSL similar to the Glimmer DSL for SWT to enable more productive desktop development in Ruby with:

  • Declarative DSL syntax that visually maps to the GUI control hierarchy
  • Convention over configuration via smart defaults and automation of low-level details
  • Requiring the least amount of syntax possible to build GUI
  • Custom Control support
Hello, World!




Basic Table Progress Bar




Area Gallery


Check out many more examples at the project page.

Keep in mind that just like with Glimmer DSL for LibUI, you can build a complete and elaborate DSL in Glimmer in as fast as 3 weeks (with the first version done in a matter of hours). Glimmer offers ultimate flexibility in sculpting a DSL exactly the way you want whether it involves arguments, keyword arguments, block variables, nested attributes, or content blocks. Use Glimmer for your next DSL project.

Happy Glimmering!



Wednesday, September 29, 2021

Array Include Methods 1.4.0

The array_include_methods gem (Array#include_all? & Array#include_any? methods missing from basic Ruby Array API and more!) has had several releases in versions 1.1.0-1.4.0, with the following changes (some API breaking):

1.4.0

  • array_diff_indexes(other_array) (alias: array_diff_indices)
  • array_intersection_indexes(other_array) (alias: array_intersection_indices)

1.3.0

  • [API Breaking] Separate between operations include_any?(*array) and include_any?(array) to avoid confusion (remove support for the latter as it is not necessary)
  • [API Breaking] Separate between operations include_all?(*array) and include_all?(array) to avoid confusion (rename the latter to include_array?(array))
  • Array#include_all?(*other_array, same_sort: true) accepts same_sort option (default: false)

1.2.0

  • Add Array#array_index(array) method to determine start array index of other array

1.1.0

  • Perform contiguous-element include_all?([...]) check against an array argument (not splatted)
  • Perform sorted include_all?([...]) check against an array argument (not splatted)
  • Perform non-repetition include_all?([...]) check against an array argument (not splatted)
Here is a reminder of what the gem is all about:


Monday, September 27, 2021

Glimmer DSL for SWT 4.21 (New SWT/JRuby/JDK)

Glimmer DSL for SWT 4.21 is the quarterly major release that ships with a new version of SWT (released in 2021-09) as well as other big changes like JRuby 9.3.0.0 and JDK 16:
  • Upgrade to SWT 4.21
  • Upgrade to JDK 16.0.2
  • Upgrade to JRuby 9.3.0.0
  • Update packaging to rely on JDK 16 `jpackage` (instead of older JDK 8 `javapackager`)
  • Renamed `Glimmer::RakeTask::Package.javapackager_extra_args` to `Glimmer::RakeTask::Package.jpackage_extra_args` to match the name of `jpackage` in JDK 16
  • Change `package/[os]` scaffolding placement for packaging icons into `icons/[os]` to accomodate Java 9 Module security for icon retrieval from within a JAR
The biggest difference in this version of SWT is auto-switching to Dark Mode on the Mac.




If you encounter any issues due to the big upgrade from JDK 8 to JDK 16 and jpackage for native-executable packaging, please report in an issue request. There is one annoying message that shows up during packaging with Warbler (unsupported Java version "16", defaulting to 1.7), which seems caused by running JRuby on JDK 16, but I was able to contain its damage and render it harmless (at least as far as I could tell).

In other news, a new Glimmer DSL has been brewing:

Glimmer DSL for LibUI is a prerequisite-free CRuby desktop development GUI library. No need to pre-install any prerequisites. Just install the gem and have platform-independent native GUI that just works!




Happy Glimmering!


Tuesday, September 14, 2021

Strategic 1.1.0 - Painless Strategy Pattern in Ruby and Rails

Strategic 1.1.0 (Painless Strategy Pattern in Ruby and Rails) has been released with the following changes:

- Generate `strategy_name` attribute on `Strategic` class if it does not already exist like in the case of a Rails migration column

- Automatically set `strategy_name` attribute when setting `strategy` attribute (either `strategy_name` attribute in Ruby or column in Rails)

- Load `strategy` attribute from `strategy_name` attribute on `after_initialize` in Rails

- Fix error "undefined method `new' for Strategic::Strategy:Module" that occurs when setting an empty string strategy (must return nil or default strategy)

- Fix issue with `ancestors` method not available on all constants (only ones that are classes/modules

The project README is included below as a refresher on what the Ruby gem is all about!


Saturday, August 28, 2021

Bundler-Download 1.4.0

Bundler-Download 1.4.0 (bundler plugin for large-size downloads) has shipped with support for specifying a Downloadfile at the root of an application, in addition to previous support for including Downloadfile in gems.

Below is the library README.md for a full explanation of what Bundler-Download is all about.


Glimmer DSL for Opal Hello, Text!

Glimmer DSL for Opal [Pure Ruby Web GUI] 0.27.0 ships with the Hello, Text! sample (originally comes with Glimmer DSL for SWT [JRuby Desktop Development GUI Framework])


Glimmer DSL for SWT Screenshot:

Glimmer DSL for SWT Hello Text

Glimmer DSL for Opal Screenshot:

Glimmer DSL for Opal Hello Text

Note that Hello, Text! is relying on the new Shine syntax for intuitive data-binding with the use of <=> to denote bidirectional (two-way) data-binding of GUI attributes (left-side) to Ruby attributes (right-side). Glimmer is the only GUI framework that has the Shine syntax, which makes data-binding GUI code an order of magnitude simpler than the competition, thanks to Ruby and Opal.


Happy Glimmering!