Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question or perhaps Documentation] SWT versus JavaFX #1

Closed
rubyFeedback opened this issue Jul 30, 2022 · 2 comments
Closed

[Question or perhaps Documentation] SWT versus JavaFX #1

rubyFeedback opened this issue Jul 30, 2022 · 2 comments

Comments

@rubyFeedback
Copy link

Heya Andy,

This is more a question or perhaps it could be added to the README, if
someone else may find that question interesting.

Today I got my first JavaFX in pure Java to work. \o/

So now I am learning more about JavaFX. I was already using Swing
for a little while. It wasn't very pretty.

Anyway. If you have time and motivation, could you perhaps describe
a bit why people may prefer SWT over JavaFX or vice versa? Is
SWT better? I think you put more time into the glimmer-SWT than
JavaFX so perhaps there is a reason. Or it was just chance or
random.

Also, do games such as snake or tetris or tic-tac-toe work on the
glimmer-dsl-jfx? I tried to find tetris here but could not find it,
whereas on SWT it is under https://github.com/AndyObtiva/glimmer-dsl-swt#tetris

Anyway, these are mostly questions. I myself don't know SWT and
am a JavaFX noob so I don't really know any differences. Perhaps
I get to play around with jruby more but I only tested jruby with
swing so far - not quite sure how to use either SWT or JavaFX
with it (it is probably very easy, but one has to first understand
what is going on really and I am not quite at that point yet; I
was lucky enough to finally understand the commandline syntax
for telling javac where it can find the JavaFX code/JAR files).

@AndyObtiva
Copy link
Owner

AndyObtiva commented Jul 30, 2022

I'm surprised you ask this question since the project page includes a Glimmer DSL Comparison Table that explains everything:

Glimmer DSL Comparison Table:

DSL Platforms Native? Vector Graphics? Pros Cons Prereqs
Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) Mac / Windows / Linux Yes Yes (Canvas Shape DSL) Very Mature / Scaffolding / Native Executable Packaging / Custom Widgets Slow JRuby Startup Time / Heavy Memory Footprint Java / JRuby
Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps) All Web Browsers No Yes (Canvas Shape DSL) Simpler than All JavaScript Technologies / Auto-Webify Desktop Apps Setup Process / Only Rails 5 Support for Now Rails
Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library) Mac / Windows / Linux Yes Yes (Area API) Fast Startup Time / Light Memory Footprint LibUI is an Incomplete Mid-Alpha Only None Other Than MRI Ruby
Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library) Mac / Windows / Linux Some Native-Themed Widgets (Not Truly Native) Yes (Canvas) Fast Startup Time / Light Memory Footprint Widgets Do Not Look Truly Native, Espcially on Linux ActiveTcl / MRI Ruby
Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library) Mac / Windows / Linux Only on Linux Yes (Cairo) Complete Access to GNOME Features on Linux (Forte) Not Native on Mac and Windows None Other Than MRI Ruby on Linux / Brew Packages on Mac / MSYS & MING Toolchains on Windows / MRI Ruby
Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library) Mac (requires XQuartz) / Windows / Linux No Yes (Canvas) No Prerequisites on Windows (Forte Since Binaries Are Included Out of The Box) Widgets Do Not Look Native / Mac Usage Obtrusively Starts XQuartz None Other Than MRI Ruby on Windows / XQuarts on Mac / MRI Ruby
Glimmer DSL for JFX (JRuby JavaFX Desktop Development GUI Library) Mac / Windows / Linux No Yes (javafx.scene.shape and javafx.scene.canvas) Rich in Custom Widgets Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native Java / JRuby / JavaFX SDK
Glimmer DSL for Swing (JRuby Swing Desktop Development GUI Library) Mac / Windows / Linux No Yes (Java2D) Very Mature Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native Java / JRuby
Glimmer DSL for XML (& HTML) All Web Browsers No Yes (SVG) Programmable / Lighter-weight Than Actual XML XML Elements Are Sometimes Not Well-Named (Many Types of Input) None
Glimmer DSL for CSS All Web Browsers No Yes Programmable CSS Is Over-Engineered / Too Many Features To Learn None

Also, I explain in the Glimmer DSL for Swing project the reason why Glimmer originally supported SWT:

Glimmer intentionally avoided Swing-like GUI toolkits in the past because they produced non-native looking graphical user interfaces that not only looked out of place in various operating systems, but also degraded usability, user experience, and the professional look of applications significantly, especially given that unlike SWT, Swing performance is affected by Java Garbage Collection pauses. As such, Glimmer DSL for SWT was initially born as the premiere Glimmer DSL.

In summary, SWT supports native widgets that have the real look and feel of every platform it runs on (Mac, Windows, and Linux) just like the original widgets you get if you write your desktop applications using Mac Cocoa with Swift/Objective-C on Mac, MFC C++ on Windows, and GTK on Linux. This is also what LibUI aspires to do in fact, but in C instead of Java.

JavaFX is just like Swing (but supports newer APIs) in the sense that it renders its own non-native widgets that do not have the real look and feel of every platform it runs on unless you apply themes, which will go out of date if operating systems update their look and feel. Also, JavaFX widgets just like Swing widgets are suspect to Java garbage collection pauses, unlike SWT widgets, which are not garbage collected by Java (they are natively implemented in C++/OS-language and wrapped by Java), so they do not suffer from any pauses even when the garbage collector is triggered.

In conclusion, SWT enables building better looking desktop applications with better performance. Swing and JavaFX on the other hand provide a way to build cross-platform applications, but do not provide a native look and feel out of the box, and might suffer from performance issues.

That is why Glimmer DSL for SWT is the most supported and complete JRuby desktop GUI Glimmer DSL. However, I recently built small Glimmer DSLs for Swing and JavaFX just because I had extra time on my hand late last year. I also figured people learning Swing and JavaFX in Java will end up liking Glimmer more than coding in Java, and that would then excite them to check out other Glimmer DSLs like Glimmer DSL for SWT and Glimmer DSL for LibUI.

I would advise you not to waste your time learning Swing and JavaFX. Learn SWT instead since it is better anyways, and has the biggest support by Glimmer. I assure you that you won't regret the time you put into learning Glimmer DSL for SWT. It is the best Ruby library for building desktop applications today, and competing libraries don't even come close to what it supports and provides. Also, if you've used Glimmer DSL for LibUI before, you almost already know Glimmer DSL for SWT, but I recommend you go into the Project Samples. It's very easy to get through them (especially when following the YouTube videos from within the Glimmer Meta-Sample), and your Glimmer DSL for SWT knowledge will multiply greatly and very fast as a result.

@AndyObtiva
Copy link
Owner

I forgot to answer this question earlier:

Also, do games such as snake or tetris or tic-tac-toe work on the
glimmer-dsl-jfx? I tried to find tetris here but could not find it,
whereas on SWT it is under https://github.com/AndyObtiva/glimmer-dsl-swt#tetris

Such games (Snake, Tetris, Tic Tac Toe) could certainly be developed with glimmer-dsl-jfx as it supports custom 2D graphics as demonstrated by the Hello, Shapes! sample: https://github.com/AndyObtiva/glimmer-dsl-jfx#hello-shapes

hello shapes

I'll create issues for building those games and link them to this one.

Thanks for asking.

This was referenced Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants