564 points · by agluszak · 6y ago · 365 comments
If you need 3d, we drop into OpenGL and use that (e.g. when integrating WorldWind).
Sometimes I feel bad about how easy it is to write desktop UIs in Java - the API is stable, nobody keeps changing it under me, I don't have to wonder what Microsoft is pushing this year, it is (mostly) easy to debug, has open source forms designers (Netbeans), etc, etc.
In my imaginary company that I own where we all run linux laptops that are managed by puppet or something, I think we might make a strong case for building many internal tools in Swing.
The biggest hurdle I see nowadays to using Swing is all about distribution: both of the jvm and the program. Imo that's really where the web won - certainly not because of its dev productivity. So it's definitely a no-go for your actual software product.... but for internal tools where you have a lot more leverage over the environment, I think it looks extremely attractive.
Regarding JavaFX... Honestly, I really like it. I have a personal project that was originally in Swing and I ported it to JavaFX because HiDPI is in a lot better shape there (though I think Swing has since figured it out?). And it's a lot better in many ways. I love-love-love using SceneBuilder for designing the view layer and the Observable pattern, I think, yields a lot of nice QOL/verbosity-reducing things.
That said, I think it did have a slightly higher O() for frustration than Swing's O(1). And I think the community, as a whole, just understands it less (less prior art etc).
So if someone said "build a usable high-quality GUI asap or you die" to me, I'd go to Swing immediately.
Java Web Start (JNLP) worked great. It just worked. His customers loved him.
I've always wondered why something like desktop JNLP didn't happen.
JNLP did a good job of solving the app distribution/update problem, but required that you already had the JRE installed. Not too much different from assuming a browser is installed, but I found it much less likely that a user would take the initiative to install a JRE than a browser. They just don't understand what they are doing or why in the case of the language runtime.
That said, it did work very well, in my experience.
Wasn’t that Marimba/Castanet?
A.) ...they never figured out a good/unobtrusive update process for the JVM itself.
B.)...Sun faltered when they picked up steam. (Remember when IBM threw 1 billion USD at writing Eclipse in Java?)
I hear Java GUI has supposedly gotten better, but all of the Java GUI apps I see look awful. For instance, try telling that to Ghidra and it's butt-ugly text that shows up super thin on my hidpi display. I like Ghidra, but for a graphical RE tool, Cutter is so much prettier with its QT interface. Of course, r2 is great and works from CLI.
I don't think Swing's MVC strategy worked out. It was worth trying. But maybe 40%-50% of the framework could be safely removed.
Some kind of DSL would be nice. JavaFX ain't it. In my own noodling, Swing's UI component hierarchy needed to be refactored to be fully composable. By the time I created enough shims to make Swing truly composable, I wish I'd started from scratch. (I haven't done Swing work in ages, so maybe this happened.)
An event loop is the biggest thing missing from Swing and other UI toolkits of that era. Meaning all modifications are handled by the framework, no client code (or non event loop threads) can modify the UI. My bestie George Smith's Juipeter (?) took the Win32 API approach, preserving the Swing API and all dispatch was handled under the hood. This is kinda how a browser's event loop is implemented. I much prefer an exposed event loop and Command objects. (It's easier to stepwise debug. Every desktop app I've ever created also had Undo/Redo; so you're gonna do Command objects one way or another.) And then make the framework pretty with some kind of DSL over the top.
Sadly, though inspired, I think Swing's LookAndFeel plumbing proved unnecessary. Sun believed everyone who said it mattered. Maybe it did for a while. But the world moved on. I still have no firm opinions on how I'd make an app reskinnable. (I should probably look to see what Qt's doing these days.)
Edit: I didn't mention AWT/Swing layout managers. Just peeked at Google/JetBrains Compose. Meh. I like that it uses Kotlin; less syntactic vinegar than Java. Alas, Compose repeats the mistake of not separating out the layout code. After doing way too much layout code -- some Australians did a hysterical GridBagLayout rage meme video, back in the day -- The Correct Answer[tm] is custom layout managers. Still include some stock managers in the JDK. And make the layout hooks API easier to implement and debug.
Well, if they didn't bake LookAndFeel in from the start, all of the work would fall on the application developer to manage these things. Having had to look into doing this the way they chose is the best way, what most people have a problem with is the UI didn't look fully native on most platforms for a long time.
I guess what I'm alluding to is something like CSS for desktop apps. I tried to tweak stock L&F a few times (not my choice) and I mostly failed.
Back in the day, there was a guy, Sven?, that crafted amazing L&Fs. I dimly recall he had one that was easily customized.
and of course vt100 escape sequences for some reason.
They are all you have if you don't know about FLTK, QT, Juce, GTK, wxWidgets and many others.
That said, there should have been one, good, cross platform GUI toolking, and Qt, for various reasons, isn't it. The best we have is Electron...
It's also worth pointing out that creating a cross-platform API is better for new players than for entrenched ones.
No client complained about either of those. And at the end of the day you could always call a method to get the platform look and feel and it could look like Windows or Mac OS. I had a menu to change this in the app itself.
I never found the UI development hard. I was hand coding it in the beginning. I thought the Layouts were pretty straight forward (except grid bag which I never used). Eventually NetBeans had a decent UI designer and I used that.
I think the sloppy or slow UI's came from developers who never took advantage of the Observable / MVC aspects of the UI components.
(Flash had many, many drawbacks: proprietary, security, ... but it was really easy, to make something nice looking, that also run smooth - it was designed for that and later taken to higher level with flex)
When people don’t laugh at Electron applications, I don’t know what could be wrong with Swing. Nobody cares about native toolkits anymore (what is native toolkit for Windows or Linux?).
There is the difference. This post is for people who do care about the looks. (or do care, that their users care) Some users don't care, which is fine to serve them, what they want, but most actually do.
"When people don’t laugh at Electron applications, I don’t know what could be wrong with Swing"
People do not laugh at electron apps, because they use html which is designed for good looking. In other words, usually much better looking. It is just not performant, unless you use native modules etc.
And native toolkits are still a thing. Gtk for linux for example.
Personally I also care about the looks, but I prefer function over form, meaning I want a functioning app first and secondly it should look good. But I like to have both.
I was writing UIs in Swing 10 years ago, and we managed fine even back then, but our target customer is technical people so maybe our definition of "looks good" is somewhat easier.
And even SWT was far from perfect. It is one of those thing you can immediately tell by its looks, SWT, Swing, Linux, Mac , Windows. While the looks has been vastly improved, it still remain mostly true today.
Yup, there is the difference. My target audience are common people, so I have to care more.
I tried to do the same few years ago, couldn't find a reliable way.
When I tell Swing to display a simple window with some simple widgets, it will
1. First display the window in some random place on the screen,
2. Then move it to the position I actually specified.
3. Draw all the widgets with a slightly wonky layout,
4. Then erase the widgets it just displayed and redraw them with the correct layout.
This happens in every Swing app I've ever used when opening a window, even IntelliJ. (The glitching window position is not always observable.)
But we are trying it, and opinions (internal to my company) are varied. Some people like it, but I don't. Because (a) it has missing functionality here and there (b) it still has a long road to go to become battle-hardened (c) I don't see any of the current supporters having deep enough pockets to fix (a) and (b)
So we're taking a mostly wait-and-see attitude.
But we have an existing deep and wide investment in Swing in our products, so our risk profile is probably somewhat different to yours.
As far as I'm aware, it was only pulled from the JVM into a separate dependency, as did several other components, in order to keep the JVM slim. Are you saying development on it stopped altogether?
Some OSS examples:
http://www.sweethome3d.com - This one has been the one app I've recommended to people outside the tech bubble! It also focuses on graphics and 3d.. really deserves to be showed off more often
What they have in common is that they are old project - often more than 10 years old and are not on Github. Goes to show how important hype and trendiness is in our industry.
edit: fixed formatting
Have you ever used the merge tools? So dang cool.
If the UI toolkit can't get a button right, it is completely broken IMO. Even including intelliJ products, I have never used a Java GUI which was good.
Part of them because i didn't fully understand Swing when i began the project and partly because synchronizing GUI's to another live process is a quite error prone task.
A debugger process is almost certainly not living in the same thread as the Swing UI of IDEA so this almost surely more of a thread synchroniztion issue rather than Swing issue. (You really don't watch to do any cross-thread touching with Swing apart from for a very limited set of components built for this).
I have it configured as my git mergetool
The only problem is it takes absolutely ages to start up, which is maybe a JVM thing
I wish there was a way to have git pass all of the conflicting files in a merge to the mergetool at once. Instead of having to wait for JetBrains to load up for each individual file and close after each one :(
IDEA is slow(ish) to start because it's an IDE so it's loading tons of plugins, a project database etc. Though actually recent versions only take a few seconds on my admittedly high end MacBook.
How are you doing this? I haven't seen any merge tool, let alone a standalone one, in the JetBrains toolbox. What am I missing?
I.e. the amount of UI problems you have with it when using a tiling wm or wayland (or both) are just sad and make it unusable. Other widely used UI's might also have problems but at least are somewhat usable under wayland and/or tiling wm.
Ironically many of this problems go back/are rooted in to AWT...
In the past Intellij did work if started directly by x (without a wm) which was pretty cool for some very very neach use cases, but sadly (through reasonably) this isn't the case anymore.
If the JVM based apps do not yield a significant performance benefit then there is no point in going after that.
>The second is the DOM. It is a horrible collection of hacks that make simple things hard and hard things impossible. I have thought many times “if only was I drawing this control/layout directly, I would’ve finished hours ago.”
As a user of electron apps there are clearly limitations on what the UI can do as a result and the style of rendering it is clearly webish.
Another issue I keep on seeing with web based apps, moreso on android, is they seem utterly incapable of dealing with the slightest network non-connectivity. The UI tends to freeze.
I do take your point entirely on the fact that perhaps java's inherent performance limitations might result in a fairly comparable poor experience however.
Through tbh. I don't see much reason to spend time for a Java UI framework, Java for desktop is just kinda annoying and somewhat even more dead then Java for servers (which isn't really dead tbh).
Through I guess idea/Intellij would love to replace the low level parts with something which works more reliable.
In fact VSCode starts faster.
A text editor that can be extended vs a platform application is the same argument we've been having about vim vs emacs for years.
DBeaver is an incredibly powerful application that had allowed me to work in Postgres, Teradata, and Oracle databases for years. Could I do the same kind of work in VSCode? Absolutely not, unless I wanted to build out an entirely new interface on top of VSCode. By the time that work is done it could be equally slow to start up. DBeaver has an absolutely massive feature set tailored for database work and it has to load all those plugins at some point.
Another counter point is VSCode with java-lsp could never handle the 300k loc code base we developed on, where intelij and eclipse do just fine. Yes, they startup slowly, but at least they provided meaningful and fast autocomplete without the need to wait for the language sever or VScode to unfreeze.
Again these are purely anecdote, but please don't purely judge an application by it's startup time if it saves you time in the end.
I also think the optimizations for high performance with a relatively small amount of data are fundamentally different than the optimizations for high performance with a very large amount of data, I have not really seen any GUI approach that scales smoothly from small amounts of data to large amounts of data without some complexity on the back-end
> There are lots of fast, usable JVM gui applications.
I used VSCode as an example because it's touted as the fastest electron app.
Now I have no idea how to benchmark DBeaver once it's running but since my use case is to launch it once in while to run a quick SQL query, startup time is important for me.
For years I have said I need a kind of SQL pad: a native app, that launches ultra fast, directly shows me the tables once connected (hide all the complexity of the DB) and let me run some SQL immediately. I guess I'll probably have to scratch my own itch once I find the time.
Debatible, argueable.
If you want people to make good apps, you need to give them buttons and checkboxes and text fields. If you don’t, we’ll, they’re going to do it wrong. Time and time again people have tried doing this and the best we’ve gotten out of it are game UIs and Flutter, which are a solid “mediocre” in the UI department. The former probably gets a pass because it’s allowed to be quirky, but the latter is literally run by a megacorp and it’s still struggling to get basic things right.
Heck, even Swing and HTML are better than this; at least they give you components that someone actually spent time on implementing and making half-decent. Maybe they suck, but they suck together in a consistent way that is at least partially battle-tested, a must for any GUI toolkit. They’ve gotten to the point where they’re no longer just a middle finger to people with accessibility needs.
Look, I don’t want to rain in this author’s work. If you’re going to treat it as an accelerated Graphics2D, go right ahead, this seems like it would be an excellent solution for you. JVM bindings to Skia seem awesome. Just don’t, like, draw something that looks like a GUI in it.
(I could go longer about the characterization of mobile apps as constantly being purged from RAM and losing your work and IntelliJ being a good Java UI, but that would probably make this divisive comment longer than it already is.)
React Hooks, SwiftUI and Flutter are modern choices that popularized the declarative approach and the author expresses its frustration that until now there was no interest in developing one for the JVM, which has all the pluses that it needs to create an ecosystem around one. Java, Kotlin, Scala and Clojure will all benefit from it. I think he is right, there is no modern graphics API on the JVM right now to do an UI toolkit or 2D/3D visualisations.
"The road to high-quality UI on JVM is a long one. We’ll need:
a graphics library, a window/OS integration library, a UI toolkit. Today I am happy to announce the first part of this epic quest: the graphics library"
Maybe you misread a bit? I do not see him suggesting, to use his first step for the UI. The idea is to build the UI kit on top of it.
I think you've got the wrong end of the stick. The author isn't suggesting anyone do this.
But most apps need to do some drawing of their own - if they're a charts library, or a CAD program, for example. Then you need a library like this.
https://www.jetbrains.com/lp/compose/ shows a code editor prototype.
Because the project is in alpha? And it says so on the page?
To quote from the article on skia:
--- start quote ---
We are so used to things we can hack together in a week, nobody is thinking in terms of years. And good UI requires years of work. It’s a big commitment.
The road to high-quality UI on JVM is a long one. We’ll need:
- a graphics library,
- a window/OS integration library,
- a UI toolkit.
--- start quote ---
Without going through the effort of installing and running it, it's easy to see that IDEA looks just as good as it did 5 years ago—which is to say not great. And without any evidence saying otherwise, it's reasonable to assume that it hasn't gotten any more lightweight or nimble since then, either.
People writing JVM apps who tout their quality never seem to understand that their firsthand experience does not translate to other machine/system configurations that other people are running. It very well may be the case that those apps look and feel worse than an Electron app. (And one doesn't have to be a fan of Electron apps to admit this.)
As for how it looks, well, it's an IDE. It looks fine to me. There's a dark mode if you want it, the look is modern yet dense: sparsity being a common issue with web apps. Plenty of people use and like it.
Its keyboard friendliness is also highly underrated due to being a GUI -- I found it's rivaled only by emacs/vim in that I can go an entire work day without clicking around with a mouse.
> As for how it looks, well, it's an IDE.
Not sure what this is supposed to mean. There are good looking IDEs. There's not something inherent to them that makes one look the way IDEA looks. It's the aforementioned blindspots and the "I don't see anything wrong with it" attitude that causes that.
I think this betrays a lack of understanding on the part of the author of how to write good web components. Yes, the DOM is tricky at first, but that's because it's trying to support things like resizing windows to arbitrary sizes.
I don't even understand what he tries to say with "draw the control directly". In component-based library, this is exactly how you would work. Put your component where it needs to be, and boom, you're finished (just like in all frameworks this is a lie, you probably still need to tweak).
I don't in general buy the argument that the DOM is low-performant and low-quality. Lots of great and performant UIs have been built on the web platform.
For comparison in GUI toolkits you use the existing feature complete dropdown. And if you need more customization you extend the dropdown and override it's render/paint function and you can painted as you want. What I liked about this powerfull GUI toolits is that most of the time you used the built in stuff so all application look consistent and only special apps would create custom stuff.
I wish browser makers would focus on improving the existing DOM elements and adding a few more so we could use native ones instead of having to implement custom shit because the designer wants the component to look in a specific way but you can't CSS the native element to get the result.
An example big issue I faced creating my own editor was getting the caret follow my mouse-clicks and key-presses. Then trying to highlight matching parenthesis. I know it is doable because I did it but I had to spend a lot of time on it and I'm not quite happy with the end-result. A standard high-quality text-editor component should be part of the web-platform but is not.
Isn't there already JS libraries to do that? If so, doesn't it boil down to the same issue as traditional OO UI toolkit, where the abstraction must be extremely precise to allow for any sort of customization?
> For comparison in GUI toolkits you use the existing feature complete dropdown.
Aren't you making the assumption here that GUI toolkits necessarily bundle a perfect implementation of this widget? Why would that be only possible for native GUI and not for Web UI?
The existing toolkits are not as limited as you think because you can most of the time override them and do whatever change you want , most of the time though you have enough built in customization that you don't need to do advanced overrides (I do not mean only visual customization, for example a dropdown can give you the option on how many items would be visible on the dropdown at once, a DataGrid can give you option about what columns are resizable, sortable and you can specify if you want a sort function for a column. And about DataGridView components, the native ones are implemented smart and can hold a million rows and have no performance hit because are smart enough not to create million GUI elements.
>Aren't you making the assumption here that GUI toolkits necessarily bundle a perfect implementation of this widget? Why would that be only possible for native GUI and not for Web UI?
Desktop toolkits are not perfect so if your designer asks you for super extra fancy stuff you can either extend and existing one or you can create it from scratch but for visual stuff just changing the paint/render function would be enough.
For WebUI, let's say I need a good dropdown, calendar, and DataGrid where do I go and get this components? If you say bootstrap those are too basic, if you say some React stuff maybe I am not suing react, if you link me to some Angular version N stuff maybe I am using N-1 version etc.
I think if you ask 3 developers to go and find me an X component for my framework Y I would get back at least 3 different results.
Other issue with non native components is that if you do not read the code you might not notice bad quality, components that do not clean after themselves or that run code each time you move your mouse around the page.
Not really. That's the point of making components in React/Vue/Svelte/etc, you can create reusable modular parts.
As an example you say have a DataGridView , a giant component with a lot of features and you need to modify something, can you do it in React using inheritance like functionality and not risking breaking anything where the component is already used ?
Custom rendering is not most of the time painting on a canvas. A simple example , you have a Dropdown, each item is rendered with a simple component that is something like
<text>item.text</text>
and you might want to change the render function to be
<icon>item.icon</icon><text>item.text</text>
I think ATM you still can't use the HTML select to have a dropdown with the countries and the flags or a dropdown with the fonts and each font it is painted with it's own font family, or customize the numeric spinner arrows or scroll bars colors.
Again , I prefer using native widgets, but I am forced to implement designs and I have to replace a native component with a pile of netsted divs,js and css.
Yes, I am forced to use is, as we all are. But, I tell you, I miss Swing and actual GUI component libraries that were designed, and implemented, from the ground up to be used as GUI.
I could rant until the end of my career for this mistake of a path we all took in the 90s. HTML/Hypertext was a game changer. But, bastardizing this implementation into what we have to deal with today was a total and utter mistake.
DOM, CSS and the way they interact with JS where designed for mostly immutable "documents" with mostly but to complex design.
Then it was bend and extended to somewhat extend somewhat more complex designs and more interaction.
That step was repeated again and again until now where is used for application graphical user interface instead of just displaying documents with some forms in them.
The foundation is fundamentally unsuited for the task it's used for by now.
CSS might seem simple but has crazy amounts of hidden complexity and until recently lacked trivial/simple ways to do some layouts common for GUIs but unnecessary (and bad) for displaying documents.
In recent years thinks have gotten better, e.g. CSS grid makes GUI layouts SO much simpler, but still the foundation is broken.
As consequence many of the promises the foundation gives are in practice often broken, too (like accessibility, like free resizing and zooming which often doesn't work correct, like cross platform as web apps are often designed for chrome relying accidentally on chrome specific behavior especially wrt. CORS, ...)
It's been some years that I don't do anything web so I'm not sure if I'm familiar with its problems.
still waiting to see them, at least for performance levels comparable to 2007 desktop apps
This must be some strange usage of the word 'performant' I wasn't previously aware of.
At the risk of simply mirroring dmitriid's comment, and without wishing to come across as snarky: which ones?
I don't think I've ever seen an Electron app that couldn't have been implemented in C++ to run appreciably faster and use at most a quarter of the memory.
Also, does the DOM have a ListView/TreeView?
This statement betrays the commenter's lack of understanding understanding of both limitations of the Web model and the freedom afforded by almost every single one of UI libs and frameworks.
> I don't even understand what he tries to say with "draw the control directly".
Aaand here it is: "I don't understand".
In a GUI framework/lib you usually have the ability to skip the provided primitives and draw whatever you want directly. A framework/library doesn't provide a control you need? You just draw it yourself.
So, instead of re-inventing, poorly, a virtual list, or a calendar, or a customisable drop-down with a few thousand divs, z-index issues and layout thrashing, you can (relatively) easily implement those controls yourself. At easy 60 or 120 fps.
> I don't in general buy the argument that the DOM is low-performant and low-quality. Lots of great and performant UIs have been built on the web platform.
Name a few, please. And when you look into those "performant UIs", you'll see on or more of:
- skipping the DOM entirely and building everything on top of canvas or webgl
- going through great pains to: avoid mutating DOM, avoid repaint/reflow (which can happen by simply querying the DOM [1]), reducing the already laughably small amount of updates even further to prevent DOM updates, layout thrashing, JS GC pauses etc. etc.
And this will still not come even close to, lets say, displaying a million objects on screen at 120fps (any modern game engine), or any significantly complex UI layout (any professional app).
[1] https://csstriggers.com and https://gist.github.com/paulirish/5d52fb081b3570c81e3a
> You just draw it yourself.
This is disingenuous. It might be ok in Games not to have decent interop with the OS but for productivity tools, it is a requirement.
Which means you need to implement OS native interop (for multiple DE's in linux perhaps), accessibility for screen readers and you need to be smart with your rendering because having a function called 60+ times a second is a surprisingly big foot gun. All this across 2-3 very different (and currently diverging) operating systems.
Yes, you have to do all of that, and I never said it was an easy task. That is, it's relatively easy compared to the web. This task is close to impossible on the web, especially if you want decent performance.
HTML5 canvas?
--- start quote ---
... when you look into those "performant UIs", you'll see on or more of:
- skipping the DOM entirely and building everything on top of canvas or webgl
...
--- end quote ---
I think the author is trying to get to a wonderful future but their heading in totally the wrong direction.
Of course I'm biased, because I helped build the IDE, but I think it looks and feels great. It has a 3d modeling view that does pan, rotate, dolly, all at somewhere between 30 and 60 fps.
Also NetBeans.
I'm not convinced that JavaFX is too slow for use in real-world GUIs. The article doesn't really back up this claim. It also ignores the SWT toolkit, used by Eclipse.
Unfortunately I find the last part a bit confusing: is this the lower level of the stack that beneath Compose Desktop? How is skiko related, or is it unrelated? Apparently Compose Desktop is built on Skijo (the github readme is much less confusing). Apparently the skiko build is also consuming skija as a dependency (in some very interesting ways, apparently planet kotlin still does enough java to lombok it), but the presentation on the blog would benefit a lot from a healthy dose of clear "that uses this" bragging.
All in all as a slowly greying java guy, it's amazing to see this entirely unexpected breath of fresh air for the JVM. In this age of new desktop apps having been given up completely to electron and the like, desktop JVM could see a surprising renaissance as a lesser evil.
Not so, SWT uses its own bindings to the OS's native GUI toolkit, using JNI.
> desktop JVM could see a surprising renaissance as a lesser evil
I'm not convinced that a whole new toolkit is the solution, with all the challenges that brings (lots of widgets to create, internationalisation, accessibility, multiple platforms to test on, etc). I figure the better move would be to work on improving JavaFX. As far as I can tell it's a pretty solid GUI toolkit, albeit one with little adoption.
edit Also, I suspect one of the things holding back Java desktop GUIs might be that they're often clumsy to distribute. Expecting the user to install the JVM isn't good enough, the application should bundle a JVM, or use ahead-of-time compilation. The user should never be made aware of what language you built the program in. As I understand it, OpenJDK has been making solid progress on the latter option. (And Excelsior JET no longer exists.)
I just download Netbeans, this is 10+ years since I touch a Swing / Java apps. And nothing has changed, it still looks Java. It is still heavy, although start up speed are now better. But generally speaking an Electron Apps ( VS Code ) looks and works better than that.
Eclipse is still better look wise, as it was 10+ years ago. That was basically the reason why I choose SWT back then. But it is still not perfect.
So I decide to check out another consumer Desktop App from similar era, Vuze, or used to be called Azureus. And it is the same, Desktop Java Apps. And yes that was the reason why no many were using Consumer Desktop Java Apps. They dont look good, heavy on resources, need JDK etc....
As if nothing has changed in the past 15 years. I remember I was trying to use GCJ and SWT for Desktop Apps then, it was just too hard. I gave up. And it seems no one cares about decent, java desktop apps.
Many similar approaches have been done, but none became a conveniently dominant go-to solution. Perhaps AOT compilation will finally bring a JRE bootstrapper component that is sufficiently "java" to find a wide footing in the java dev community and sufficiently friendly to end-users to end all "but maybe that other tool is even better" that kept all existing approaches niche.
A right, I forgot that, thanks. What's the SWT approach to use cases where you basically want a pixel canvas? Falling back to AWT on a surface allocated from the native API or its own facade for native APIs?
In any case this property of SWT kind of explains the omission, SWT happens on a level that is two layers away from skija in the stack Jetbrains are building for Compose Desktop.
I would like to have an opinion on this myself but I've yet to find a JavaFX application in the wild.
There are many aspects to UI performance. Unlike IntelliJ, our app has only tens of widgets displayed at once - I can't compare in this regard.
However, we have very big models, namely tables with >100000 of rows. Scrolling is smooth and initialization as well. From my experience, JavaFX allows you to write elegant code which still caches a lot of components. This is a strong performance benefit.
My issue with JavaFX is a very well thought-out philosophy, translated into an API which is far from perfect. Once you go beyond "hello world" examples, you e.g. have to start type-casting. I'd love to see JavaFX v3 where these things would be sorted.
https://github.com/geokon-gh/corascope/
I even managed to make a little SVG backend for it
That said - this seems to be more of a " graphics library " while JavaFX is more of a " user interface library ". I'm sure there is a ton of overlap - but I wouldn't be making funky creative coding displays directly in JavaFX
My minor annoyance is that it's nearly impossible to make something that runs on Android out of that - which seems like a giant shame given it's all JVM
By this point, it should be table-stakes that any GUI framework must always be tapped into identical font rendering to native apps on the host platform.
Well, not exactly. https://github.com/JetBrains/skija/ is 30% C++ and of course requires native builds: https://packages.jetbrains.team/maven/p/skija/maven/org/jetb.... If you are lucky, Maven simply hides it from you.
UPD: no, it doesn't hide it. See https://github.com/JetBrains/skiko/blob/master/skiko/build.g... and search for 'lin'/'mac'/'win' and see for yourself.
UPD2:
@-moz-document domain("tonsky.me") {
body {
/* surovyi background color off */
background-image: none;
background-color: hsl(0, 0%, 85.9%);
}
}Ideally we won't when the JVM gets an FFI built-in.
These days, I'm not sure if fixing that is enough. I long for the days when minor UI inconveniences like Borland-ish button icons or that weird Basic thing in the early days of OS X were the worst offenders. Quite often it's _required_ that you deviate from your platform quite a lot, as we've embraced form over function with mobile- and web-like "experiences". Whitespace everywhere, mystery meat navigation and non-conformant widgets and shortcuts that make you long for the skeuomorphic mistakes of the late 90s. Neither Apple nor Microsoft seem to be too much into HIGs these days, and Linux never was.
So if this delivers the bricks, what kind of houses would we build with it?
I don't understand what you mean by this. I don't think desktop apps "look gross" at all. Or did you mean that Swing desktop apps looked gross because they didn't conform to the native look and feel of the platform they were running on?
[1] https://en.wikipedia.org/wiki/Processing_(programming_langua...
Oh BTW, you can do WASM with Blazor (C#) now.
I used SWT to create desktop UI prototypes. The biggest issue of SWT is the distribution channel: to use the usual Maven repo you need a non-official package (this was around 2017). But other than that is a decent UI lib: it uses native widgets, it supports HiDPI, the layout using attachments are easier than Swing.
I wonder why SWT is not popular in the JVM (my guess is the decision to distribute it using Eclipse p2 by default, and the lack of visibility outside Eclipse)
[1] Links under "Maven Artifacts": https://www.eclipse.org/swt/
[2] https://mvnrepository.com/artifact/org.eclipse.platform/org....
Using Haxe, the apps can be compiled for native or run in JS. That probably lands it in about the performance category of JVM or above, not that performance is the key factor here.
I worked awhile ago on Haxe UI's text field emulation, and there are many tiny details that are easily missed. Line wrapping, text selection, keyboard controls (Home and End), everything. I think those details being spot on are as important as UI styling for most real users.
I had an idea for a desktop app and wanted to try out something in javafx as that's what google pointed me to. The build setup for java projects seems to be incredibly complex and I don't find any sort beginner friendly tutorials related to javafx that work on windows without any issues. Then I looked at Android development setup and it's even more insane in size and complexity.
I think if the entry into java app development was as easier as electron it would be amazing! I get that it's a well mature platform with a massive ecosystem but it needs to be have something like npm or yarn for javascript development.
And importantly are there any thin and light JVMs that can be bundled with this? I'm thinking AdoptOpenJDK openJ9. It seems to be well suited for this use case. would it be efficient in the RAM and CPU usage? If not I'm not sure why this would be any good since we can develop stuff much faster with electron at the moment.
https://raphlinus.github.io/xi/2020/06/27/xi-retrospective.h...
If I could get an example written in Clojure that'd be even cooler :)
I noticed they have this: https://github.com/JetBrains/skija/blob/master/shared/src/ma...
Is rendering SVG in the pipeline? It seems within the scope of a graphics library.. or maybe not?
A trend that is interesting here is jetpack compose and swift UI, which are both inspired by react but better in the sense that they make full use of their respective type systems to make things like data bindings a lot less painful than they are in react. At least that being painful must be a reason why they keep changing how that works in every major release.
Add internal DSLs to the mix and you are basically looking at a nicer way to do UIs. That's only covering mobile currently unfortunately. However, Jetbrains just announced Compose Desktop which brings this to the desktop as well. If they figure out how to target web and IOS with this, they could very well have a winner.
For the web there is currently something called Fritz2, which runs via kotlin-js and basically adds very similar style bindings to a react like component framework. It's fully written in Kotlin and I've been meaning to give it a try so I can use my multi platform kotlin libraries there as well without having to figure out react and how to make that play nice with things like co-routines, data classes, etc.
For me the trend here is new UI frameworks originating outside of the javascript world gaining traction and eventually ending up running in a browser as well. IMHO it's that that is ripe for disruption.
--------
Is desktop still relevant?
I believe it is!
I watched an interview recently, between an Android developer and an iOS developer. One was asking:
“Does someone still writes desktop apps?”
To which the other answered:
“I have no idea… Maybe?”
Both of them were recording it on a desktop, in a desktop application, while having a call over another desktop application. Multiple other desktop apps were probably used for post-production. None of those were written by magic elves or left to us by a mighty ancient civilization. The desktop might be less trendy, but only because it’s harder to sell useless crap here.
-----------
"react type stuff" and iOS/Android do not cover this, but you probably knew that.
I'm sure there's a parallel world where enterprises still run JVMs on ancient windows XP boxes that are no longer supported where they feel compelled to commission new applications. Just haven't come across any such project. It's not just less trendy from my point of view but dead as a doornail. Not a thing anymore that people actively recruit for. What little UI I come across on my own desktop tends to be either web based (electron) or native (I'm on a mac so mostly objectiveC and swift these days).
But none of that will involve Swing or JavaFX etc., because these are just not performant enough for the type of apps that are still required to remain native/desktop.
I run a mid-size highly complex native/desktop FLOSS project, and it is just jaw-dropping for me to encounter people who say they have 5-16 years experience as a software developer but cannot consider compiling software. This happens regularly in the context of our project.
Patience, I think. We are so used to things we can hack together in a week, nobody is thinking in terms of years. And good UI requires years of work. It’s a big commitment."
That's quite an observation, thinking of the hundred thousands of man-hours probably spent on both Swing and JavaFX and SWT, and they power a huge lot of high-quality, highly polished applications, including real-time graphics.
I'm sure this work is great, but no need to put the competition down...
Is it?
Looking at these benchmark they seem to be in the same ballpark for most results:
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Those benchmarks don't cover this, but I wouldn't be at all surprised to discover that Electron can does actual UI drawing more efficiently than Java can. In Electron, that whole layer is a bunch of (presumably) carefully optimized C++ code, while in Java the bulk of it's still going to either be managed code, or be taking a lot of marshalling hits if it's calling into OS APIs.
Long story short, it would appear that, based on those benchmarks (which, we all realize benchmarks are a lie, but still) the only spot Java clearly beats JavaScript is in applications where someone who cares all that much about performance would choose neither Java nor JavaScript, anyway.
Also, when you look at UI benchmarks for web frameworks replacing/updating thousands of DOM elements per second, I have serious doubts the problem of web-based UIs is performance.
I agree Electron is a cancer, but not because it uses web-based UIs, but because every app ships its own version of Node + V8.
A couple of years ago I built a cross platform app using the native web view on each platform (WKWebview on macOS/iOS, WebView on UWP, Chrome web view on Android and ChromeOS). The app for macOS was like a 4MB download from the Mac App Store and it consumed like 15-20MB or RAM.
The performance of a non-memory-safe language is usually 0; if you don't care about the time to get a correct result rather than just any "result" then why would you use a programming language at all?
Especially in a world where C is still the most popular language in domains such as spacecraft control software or operating system kernels where correctness is of the most paramount importance. One doesn't need to meditate on that for very long to realize that choosing a non-memory-safe language is not a decision that correctness is not important, it's simply a decision that the programmer must be personally responsible for yet another aspect of correctness.
Also, needing to make a hard choice between "faster than Java" and "memory safe" was a problem for the late 1990s. 20 years later, we have a lot more options.
(But usually the much bigger speed problem is in the programming phase, better to optimize for programmer performance than runtime performance or risk not delivering anything due to time/money limitations)
There are of course examples of slow, heavy java applications, but I don't think it has to be that way. I'm not totally sure what I did differently aside from consider my dependencies (e.g. using a lightweight dependency injection framework rather than something like Spring), but it's definitely not a given that Java desktop applications have to use a bucketload of RAM.
Skia stands out as the obvious choice as a rendering library, Our team though is essentially a JS/Java workshop and writing C++ will be shooting our own foot.
I found Skija a while back but it looks like we need JVM and the JVM story on iOS is complicated (non-existent even?)
Fluttter does a good job at abstracting away Skia and exposing Dart APIs that is truly cross platform (Web/Desktop/iOS/Android) – but Flutter will never expose low level Skia APIs because that's not their goal. The abstraction is too high to write a word-processor.
I'm yet to find a reasonably iOS friendly abstraction over Skia that targets both iOS/Android and desktop platforms.
Its pretty fun. Also its javascript cousin p5.js
I'm thinking this is more UI focused.
Lol what? After years, Apple is already on to the next user interface. All the "good UI" happens in Figma, you're just programming it, hopefully fast & without bugs, what is taking so long? And as a fellow programmer, no thanks, I would not like to spend years developing a UI that could be done in weeks.
We had an engineer that said it was going to take 3 months to add a sticky header to the site, because he needed to do it "right", using his home grown state machine library on Github with 3 stars. He was shortly let go.
https://blog.jetbrains.com/cross-post/jetpack-compose-for-de...
https://www.reddit.com/r/java/comments/jrqjex/whats_being_us...
It's true that Oracle has mostly divested here but I'm excited to see what teams like Gluon do with it, especially for mobile development. It's nice (though perhaps a mixed blessing) to be spoiled for choice in Clojure land, since you also have great access to the React Native ecosystem.
ok. js css html won the web platform. and they have an increasing piece of native. oops! this is not a random trend, but for a good reason.
java for GUIs is not going to be popular again. it's already been tested and it failed the test.
the old timer java mindset still wants the web but it does not want to learn web.
working with the web is not a "hack", nor is the DOM only suitable for representing "documents". you left in 1995 and failed to catch up with modern standards. it's a flexible system, but does not come with all the batteries. but to counterweigh that it has a massive ecosystem, a package manager with plenty of off the shelf parts, if you want them. performancewise, the browser engines are getting faster and faster every day, optimised for rendering. v8 is hugely successful natively. the DOM is very suitable as a generic GUI model to work with. back in 1995 it was not.
wake up Java devs. your arguments are getting increasingly flaky..
Until I found the J-editor, I sort of agreed. I never understood why that project didn't get any traction; very well made IMO, and it looks good too.
That does not help of course. To be honest it did have a website (he has written a lisp implementation which comes with the editor as well ABCL - [Armed Bear Common Lisp]). I'm pretty sure the build instructions don't work either, and all sorts of other problems. But if you just download the binary distribution from sourceforge, and start it up (java -jar j.jar), you will hopefully see what I mean. It looks nothing like a Java desktop app. He has an excellent icon set, and he overrides the rendering of all sorts of components (scrollbars etc.) making it look superb.
In a past life I created a video game in JavaFX. Its on Steam. It was hard to do, but I really didn't know what I was doing when I started. I also do not know if JavaFX was missing any features that would be desired for video games, that maybe other libraries have. Nonetheless, for selfish reasons more libraries in this space is welcomed.
The very few games that run on the Java platform are very resource hungry, even more than some alternatives made in JS which is supposed to have a worse performance.
All that while C# is booming on indie game dev.
The repo seems to have very recent activity, has commits from today! https://github.com/openjdk/valhalla
Also, Java doesn't have as many bindings to gamedev C libraries, so it's harder to get started, and the interop with C is harder in Java than in C#. C# has some cool features like sequential StructLayouts.
C# is actually rarely used for making game engines, but it's popular as an embedded scripting engine for games. I think C# has a better embedding story, because I've never heard of any projects embedding Java (I am sure they exist though).
Lastly, Java has a bit of a stigma for being a low performance language. While that may or may not be true, and there's been many popular games written in Java, such as Minecraft or most of the Android games, the stigma still remains and jokes about Java being slow are very popular.
Is this a windows/linux specific problem?
My point being that, Skia is great but is not the most important ingredient at play for Flutter achievements.
Also being a good choice will not pay for the bad choice that is choosing JVM as a primary platform for this which targets UI application consumers.
[1] https://docs.oracle.com/en/java/javase/11/tools/jlink.html
Some do, some quite the opposite. Me personally i want to have as few desktop apps installed as possible. They are warranted only in few special cases - browser, video & music player, Excel. Other than that there really is no need to have any desktop app nowadays.
> Both of them were recording it on a desktop, in a desktop application, while having a call over another desktop application.
Yeah this can be easily done from browser also
> it’s hard to select text, hard to search on a page, hard to have multiple tabs, hard to move data between apps
excuse me? It's harder to select text or search text in browser than in desktop apps? What? Text search is one ctrl-f away on ANY web page. Switching between tabs in a browser is alt-num.
Desktop apps have no tabs and a lot of times you switch between completely different UIs.
Moving data between apps depends completely on the app itself. It either offers some kind of data export or does not. It doesn't have to do anything with desktop apps or web apps in general
> For example, you are adding an event to the calendar. You need to lookup an address for the event in the mail, which has a link that opens a browser.
Yeah in a web apps you at least have some unique link to it. Linking to something on your local computer in some desktop app isn't even possible
> Ability to have multiple windows open at the same time is the desktop’s superpower.
You know you can have multiple tabs open in one browser right?
I like Nikita's articles and if he or anybody prefers desktop over web that's fine. Also the library he is starting - great. But the announcement could really omit the nonsensical comparisons and generalisations of web vs desktop
> And I’ve been on both sides. I lived without a desktop for a few weeks once.
Mobile platforms, on which selecting and searching text is hard, switching between tabs is slow and multitasking between apps is made complicated by:
> By the time you found what you needed and returned to the calendar, it has been unloaded from memory and all context is lost
> excuse me? It's harder to select text or search text in browser than in desktop apps? What? Text search is one ctrl-f away on ANY web page. Switching between tabs in a browser is alt-num.
That is clearly about mobile in contrast to Desktop.
But on a seconds thought - there are people who really "work" on phone? I just can't do anything serious from phone be it native app or web app. The experience is so much worse for me that it didn't even cross my mind it's about phones.
Nope, there are lots of languages that compile to WASM. In fact, Kotlin compiles to WASM, and you get the best of both worlds, able to interop with the JVM, and compile to WASM (and C++/ObjC, and JS)
WASM will be awesome to bring great tech that is only available in native platform to the web, like FFMPEG, or to accelerate some code that uses a lot of math. But i think that people that are going way down into this WASM rabbit hole will have a wake-up call pretty soon.
WASM will open some blue-seas for sure, but they are limited to some niche scenarios and using WASM for application development for the web, desktop and mobile wont be one of them.
This is why you see it starting to be used for "serverless" deployments.
For cloud like scenarios WASM probably will be a hit, given its safer and a good target for providers to let developers to create customized apps in any language they want.
Also there's centralized decision on which tech should be used. And this make the adoption of new tech much faster.
Sure its a portable IR, but is a very limited one and therefore it will be sub-optimal in a lot of scenarios compared to the traditional native applications.
In the web alone it will be sub-optimal to the state-of-the-art optimized javascript of today in a lot of cases, even having a much better performance in some special cases. And in the case of desktops, mobile, etc, this will make it even better for javascript applications, which will profit the most in this scenario, with hybrid apps (javascript + WASM).
Of course, the FAANG that control the platforms would love to limit more and have absolute control over the platform which will probably be the only native app allowed or that people will run. But the day WASM take the world and we are not allowed to run native applications anymore except the ones the walled gardens allow us to, will be a dark future compared to the freedom we once had.
Clean-room monopolized innovation and big tech mammoth's..
Do you mean .NET would do too?
https://news.ycombinator.com/item?id=21192321
Admittedly this was a year ago! Time flies...
Now on the JVM front, I think one problem it has for desktop apps is the memory usage of the JVM is just terrible for desktop apps. It's clearly optimized for backend services assuming they are the only app running trying to squeeze all performance out. But a desktop app needs to be lean, and currently I'm not sure the JVM is tuned to those use cases, and Java is missing a few features for lightweight objects that could help as well with memory usage.
I like yellow, and I like this website: it is simple and to the point.
Though did anyone else notice the little "sun" slider at the top of the page for the spotlight in html? Useless but fun.
There is some truth in this sentence.
>Why not Electron?
> The first reason is performance. JS is a great language for building UI, but it is much slower than JVM. Wasm can be fast but implies C++ or Rust.
> The second is the DOM. It is a horrible collection of hacks that make simple things hard and hard things impossible. I have thought many times “if only was I drawing this control/layout directly, I would’ve finished hours ago.”
> That means there’s a very low ceiling, performance-wise and quality-wise, of what a web app can do. I believe we can, and should, do better.
> Electron taught us two good things, though:
> People crave for native apps. Nobody wants to work from the browser. People don’t care if apps don’t look native to the platform as long as they look good.
Regarding Electron, I think we "should" start to talking about more like "Browser Apps for Desktop" instead of just "Desktop Apps" which is broad term.
That gave me a chuckle
Ah the irony
An electron app of that complexity would require a supercomputer to even start