Say no to Electron: use JavaFX to write a fast, responsive desktop app
Look. I agree, that you shouldn&#x27;t make desktop applications in Electron. The thing is, when you have a fresh grad student that was taught PHP as a web framework for most of the time and maybe Node, what do you think they will gravitate towards? I understand veterans feel like Qt, GTK and JavaFX are intuitive in their architecture and syntax but that is simply not true. Heck even XML can be jarring.<p>So here&#x27;s what i&#x27;ve found people trip up with JavaFX mostly.<p>1) FXML. Why do you need so much information just to view &quot;Hello world&quot;. You need to define a scene, then you need to define what&#x27;s inside the scene (You&#x27;ll need to go look up a reference guide on JavaFX to find what objects you can attach just to get started), then you need to describe that a text node is connected to the thing inside the scene. For HTML it&#x27;s always gonna be &lt;html&gt;&lt;body&gt;&lt;&#x2F;body&gt;&lt;&#x2F;html&gt;. Inside the body it doesn&#x27;t matter what structure you create, you&#x27;ll be cutting off &quot;sections&quot; with plain html+css. HTML5 got it&#x27;s canvas if you need more advanced functionality. Why would people who have been taught to use canvas and DOM revert to this?<p>2) Custom CSS. Fantastic, more syntactic sugar and another reference guide to search through... people get effects&#x2F;animations with greensock or css nowadays, it&#x27;s fairly competent stuff and frankly more intuitive.
Just a gem from the reference:
    background: white;
    -fx-text-fill: ladder(background, white 49%, black 50%);<p>Without reading the reference I&#x27;m thinking it&#x27;s filling the color. What does ladder and it&#x27;s arguments mean I would have no idea. What does is this: &quot;Use the following if you want the text color to be black or white depending upon the brightness of the background.&quot; – right, cool but there&#x27;s filters and stuff made for this very thing in plain old CSS.<p>3) JVM hot code reload. The entire section is confusing to people using Node that learned to implement a watcher in Tutorial 1 of setting up package.json. Good luck explaining intricacies of JVM to grads that struggled to get bare bones Java application running in Eclipse. &quot;I find it hard to believe that anyone would prefer the webstack to working with a sane environment like the JVM.&quot; – I profusely disagree. The fact you need to have a virtual machine for your code to execute is a lot for people outside the bubble to comprehend. The fact you have two types of dependencies, runtime and compile, already confuse new people coming into the field. Gradle which is supposed to make lives easier is still way more confusing than fiddling with package.json. It&#x27;s perhaps not Gradle&#x27;s fault, I think the blame is more with veteran developers that like to be &#x27;clever&#x27; and manage to obfuscate something as simple as launching an application.<p>4) SceneBuilder. &quot;It can be integrated into all Java IDEs, making it easy to create new views.&quot;. What the author has forgotten to mention, is that it can be a pain to use and integrate (Haven&#x27;t tried this in IntelliJ and i&#x27;m sure it&#x27;s better there but it&#x27;s still more hassle than opening your flavor of browser inspection). You&#x27;ll most likely end up ditching the GUI and do everything programmatically, at which point you&#x27;ll ask yourself why are you doing css and js in Java. The example in the article is a simple &quot;Hello World&quot;. Anything more complex and you&#x27;ll find people falling into the habit of doing everything inside of Java.<p>5) ScenicView. &quot;To start it with your application, just download the jar and pass the option -javaagent:&#x2F;path-to&#x2F;scenicView.jar to the JVM.&quot; – that line might as well be written in Chinese if you&#x27;re a person coming from the Node scene.<p>6) JavaFX does not automatically refresh stylesheets. You need to build a whole seperate function and implementation just to refresh a stylesheet. &quot;This works in Mac, Windows and Linux Mint. But this was one of the only two problems I had related to differences in OS&#x27;s (the other one was the icon in the system tray on Mac does not work, but there is an ugly workaround for that). JavaFX abstracts that away pretty well, most of the time!&quot;. Well that&#x27;s reassuring there is an iffy solution to a problem that shouldn&#x27;t be there to begin with.<p>I also feel the author is quick to throw anyone using electron under the hipster title and then proceeds to call the webstack a mess yet ignoring the mess that Java is. Need I remind you why Node stuff was so popular? Because people required entire days to figure out how to get a simple ToDo Spring application working. And Spring is supposed to be easy. Think about that. You need to spend dev time on something as obscure as &#x27;JVM tuning&#x27; at one point or another. Or fixing some bizarre leak&#x2F;overflow because hurr-durr imperative programming. And the 20 years of patterns and best practices wasn&#x27;t good enough. We have shit like JPerf to figure out why all those stern-toned articles still lead to shitty code and JRebel to sweep the problem under a rug.<p>&quot;We&#x27;ve been writing desktop apps for decades. The web, on the other hand, only really got started less than 20 years ago, and most of that time it was only used for serving documents and animated gifs, not creating full-fledged applications, or even simple ones!
To think that the web stack would be used to create desktop applications 10 years ago would be unthinkable.&quot; – And here we are with Java still remaining the clusterfuck that it is.<p>&quot;If people are preferring to ship a full web browser with their apps just so they can use great tools such as JavaScript (sarcasm) to build them, something must have gone terribly wrong.&quot; – yeah, that something was the JVM. Kinda funny we now have all this compile-to-js stuff when there&#x27;s still uppity aura revolving around JS. Heck I remember having trouble with just the JRE back when I hadn&#x27;t learned any programming.