289 points · by jeffreportmill1 · 7y ago · 236 comments
If we would travel back in time to the nineties and tell them we have technology that compiles Java to JavaScript they would put us straight to a psychiatric hospital :D
Do you have any insight or ideas on where the performance increases and size decreases are coming from?
Also, did you have to work a lot to get it working in TeaVM? The last I looked at it (which was admittedly over a year ago), it still required some non-trivial changes for the Java app I was working with at the time.
My app cross compiles to JVM and browser easily now, but I did a lot of work on the SnapKit UI framework, which is like Swing but abstracts out graphics and user input. My app used to be all Swing - that would be almost impossible with TeaVM. There is product called CheerpJ which does Swing with almost no modification, but it has a larger runtime.
This post links to the TeaVM version. TeaVM is also awesome - but it has a reduced runtime, conditional compilation and better built-in DOM support. The whole app + runtime is 1.2mb (compressed) and loads in seconds (instantly once cached).
This will not be easy to fix. AFAIK, if you're using Canvas or WebGL, the only way to make the application accessible is to construct a parallel accessible HTML tree that's completely covered by the canvas via CSS. Note: Don't use "display: none" to hide the accessible HTML tree, because then screen readers will ignore it.
I'm reluctant to rain on your parade, because as I said, this is an impressive piece of engineering. But for the best accessibility and performance, I believe it's better to accept that the Web platform won, and target it directly with a UI that's native to that platform.
There is a public domain within which most disabilities should be catered for but you can't expect that every non-private thing is made public so it's usable by all.
Just because something is 'in the web' doesn't mean it's a public service, access to which is a basic right.
It's good to be reminded to take into account disabilities, of course, since those are not obvious to people who do not have disabled people nearby.
Of course it's a good thing to be mindful of from a humanist perspective, but if fear of lawsuit is driving the change, it's not a very "love thy neighbour" kind of thing, but more of a fascist dictation, no? Especially if you are not in the US.
I'll be doubling down on my efforts to ensure better compliance nevertheless.
I presume the web standards you mention are part of some US legislation, yes? :S The web is becoming a crazy place, it seems that every country is writing laws that affects the whole web... and we as developers are assumed to know them all, from UI requirements (US) to security implications (Australia), to privacy concerns (GRPR)...
Imagine using this for a new B2B app and then losing sales because prospective customers have ADA requirements or blind employees who use other web apps just fine. It’s extra engineering work sure, but it’s hardly a crazy ask, and it’s the right thing to do for large to medium size companies who can afford it IMO.
So the real question is always whether the technology to make something accessible exists and whether it can be deployed reasonably in the particular instance involved.
Plus years of stupendously painful physical therapy and Herculean will.
BS, we can and already have. here's a paraplegic person dropping in on one of the steepest in-bounds runs in the US.
quit being so dismissive.
I was not implying people with disabilities should stop doing things, rather, that it shouldn't stop a non-disabled person to do a thing just because a disabled person can't do the same thing.
This is not correct and may result in very costly class action lawsuits.
Furthermore, now that this toolkit is available, companies will use it for applications that are required for job functions that ought to be perfectly accessible to blind people. An inaccessible application can lead to a blind person losing their job.
Also, I mentioned other disabilities. A person that can see but has a severe mobility impairment should still be able to use this app.
That's almost exactly what this tool is for.
I'm not being dismissive I'm just wondering how far your beliefs go.
It really didn't seem like he was all that inflamatory, either. He just pointed out the accessibility challenges that I myself face every single day because, what, blindness isn't all that common? Great, so either kill me off[1] or give me enough UBI to not need a job, because there's really no other path for me and my uncommon condition other than, it seems, to constantly assert my existence. Should we make hammers accessible to the disarmed? Ugh, should I have to waste any more of my time because someone on the internet put up yet another straw man for me to knock down?
Look, I'd get it if his initial message was like mine, and I fully expect and don't care that I'll get downvoted for this. And to be clear, this comment is more about the intolerance and dismissiveness I've seen in the replies of what appeared to be a fairly constructive piece of criticism of someone who does accessibility work professionally and gave out free advice. Hell, how often does a Show HN get pissed on because the design looks outdated, and that's just taken as par for the course? People criticized the Thoughter design a few days ago (I don't recall how it was spelled and don't want to look it up) and no one said "Damn, the guy made a product and all you can do is complain about how it looks?" Yet someone voices accessibility concerns and look what happens. I myself have held off on posting some Show HNs because I can't make a website look good. But someone makes a constructive comment about a thing not being accessible along with tips on what might fix it and it's like "OMG get teh blinds outa here!" And now we know why I don't even seek out tech work anymore. Queue up the "maybe you'd have better luck if you behaved better" comments. :)
And to be more constructive, I am a bit worried about the "render everything to a canvas and call it progress" trends I've seen with Web Assembly lately. It isn't just this, but the projects to compile QT and other native GUIs to wasm. Do that and you lose access to the native OS accessibility layers these tools use. I've wondered if there might be a way to create parallel HTML versions of these same widgets so your GTK button might compile to a <button/> with GTK-like styling. But I don't know anyone working in that direction, and I'm not smart enough to pull it off myself. I'm just worried that one day we'll have a pile of thin clients all running in their own canvases. My girlfriend's law firm uses timekeeping software written in the 90s with a web interface. I imagine it's a GUI app running on some basement server with a VNC client in front of it. That's an outlyer, but wasm makes it likely that it won't be, and Matt's concerns as an accessibility professional are completely on-point.
1. To be clear, not a cry for help or anything, but it sort of blows my mind that on one hand people dismiss disabilities because they're not that common. On the other, a large subset of society expects us to try harder to compensate for that apathy. So you either do, and become exceptional, or you just give up to some degree or other and accept that you'll likely never have the nice salary and such. On the gripping hand, most of you are likely to have one of these "uncommon" disabilities when you age. Hope you enjoy whatever you do while you can do it. It's going to be fun learning how to keep coding in your 70s when half the tools you took for granted aren't accessible to the screen reader you use because your glasses no longer cut it. :) I don't expect folks to bow and scrape when a thing isn't accessible, but to shit on someone for politely pointing that out is quite an unfortunate reaction.
In a parallel universe, someone might have said "You're right, it isn't accessible. That wasn't my goal, and if this ever does take off then I might have to investigate other options."
But that isn't what happened, it's a bit of a double standard, and that double standard has real consequences for some of us. The bulk of the pile-on doesn't seem to be coming from my friend, but rather from a bunch of folks criticizing him for daring to politely suggest that there's another perspective worth considering.
If your response is "because more people care about the visual design of a technically sound concept than whether it is accessible because looks matter," then I'd agree with that, and we can just leave it there without casually dismissing an entire group of real people who matter. But again, that isn't what happened here.
I wish I could post web apps I've made here without contending with the half dozen "your design sucks" comments I'd likely get. But if I got them then I'd expect them, and that frustrates me to no end.
FWIW, I'm not actually all that upset. I'm kind of used to this, actually. And I know you're just trying to explain why things are what they are, which is exactly what I'm doing. :)
The "Web platform" is not a single thing. It is a bunch of things that are constantly evolving, that are also implemented differently by different browser vendors that have their own issues.
Just because the web purports to have a (sometimes) working UI that is accessible to some percentage of users on some percentage of devices doesn't mean that we should stop there and not experiment anymore in other directions (even if those new directions could, initially, not support all a11y functionality that 'the Web' already provides, for screen readers or what else have you).
There is no "the Web won, accept it"- many things are terribly broken, before even taking a11y into account. Just note how many dysfunctional UI paradigms exist that don't support what we call 'responsive web design', often from the biggest companies in the world!
A11y isn't anywhere close to a solved problem on the Web any more than responsive layout is -> it should not be the target specification to work towards just because.
As a final thought experiment: what if we are going about a11y all wrong? What if screen readers and tree hierarchies of components aren't the right way to approach building these things and instead the better solution is to completely do away with that approach and instead make new screen "readers" that use AI to better visually determine elements on screens after the fact. AI is definitely at a point where it can classify buttons from text and images, as well as read out text in several kinds of fonts. If this becomes the future, it'll render all of our current web 'standards' to look like an unnecessary hassle of working with the more disingenuous and restricted (in the sense of, you can only use such and such component in such and such way) methods of today.
What I'm saying is, encourage people to experiment with new UIs that don't yet conform to standards. By all means, mention that you wonder about a11y and ask what the plan might be going forward. But don't dismiss these experiments too early cause they're not built in the "right way".
> The "Web platform" is not a single thing. It is a bunch of things that are constantly evolving, that are also implemented differently by different browser vendors that have their own issues.
Maybe The Web, as a platform won?
EDIT: Formatting
doesn't work that well because the event model between web and desktop is radically different. if you don't have complex interactions or expectation about your widgets it kinda works.
That sounds like a use case for @media queries
A11Y is not the bottom line to judge everything by. That dilutes it's importance as a niche. Judging by a11y is a power that should be used responsibly, not as a last resort to just find something critical to say.
It's inaccessible to non English speakers and that's not a problem because it just doesn't matter enough. Same thing with disability. There's just not enough disabled people to justify critiquing everything that's not usable with screen readers.
The world is not accessible to every group within it, and that's okay, that doesn't mean everything that isn't able to be used by some group is somehow bad or deficient. To discriminate against apps that don't have certain abilities is just the same bias as discriminating against people with different abilities. Be more tolerant of apps that are serving their special niches and nothing more.
So now we have a framework running on a VM running on a VM running inside a sandbox running in microcode (did I miss a level?). Can't wait for the next abstraction!
Doing that is just harming a11y efforts, by insisting software must be the fix, when there are plenty of other solutions that don't involve rewriting / redesigning a piece of software, likely to deliver solutions faster or better than changes to software.
At this point, I really don't know why you keep advocating this path as your goal can be achieved through other means. Get off the idea that a11y critiques are the ultimate trump card. They are not.
That's a problem with the employer, not the application. Applications do not need to cater to every edge case of humanity.
We may see more of this with WASM. And JavaScript can get a little unwieldy beyond 100k lines of code.
[ Found the issue. https://github.com/electron/electron/issues/673 ]
I used to give demos of the Swing version of this app 15 years ago, and people would try to convince me that my app was written in C, because a Java app can't run that fast. Those were weird conversations. I'm not even that clever - I just try to write simple code.
Fortunately, CPUs have caught up with Java, eventually :)
My understanding is in this high performance CPU landscape Java apps should work well on all popular desktop platforms and to have it compiling to a web UI like this makes it even more powerful.
How does including existing Java libraries like GeoTools http://docs.geotools.org/. What are good resources to read to understand the limitations of TeaVM?
I find it really impressive that desktop applications can now run quite smoothly in a web browser. In like 15 years we've made it from phpbb forums through 56k modem, to this.
Congratulations
[0] http://example.qt.io/qt-webassembly/widgets/richtext/textedi...
Similar effort in Clojure or ClojureScript - https://github.com/oakes/play-cljc
It's more intended towards Game development though.
The pattern that Electron and such are continuing is that they do a base set of things well, but then integrating with OS services is non-existent, even though for any given OS it's relatively trivial.
Don't be too impressed that it can run anywhere at acceptable speeds; Java solved that 20 years ago.
Rather, it's more fundamental: as you add in all the functionality provided by various OS's you have to model all that functionality and it has to be comprehensible to your users and maintainable by you.
Some of that functionality is flatly contradictory and much of it is peculiar to a small audience. You can theoretically engineer around it, but in practice, you won't be able to maintain it and no one will want to use it. That's an intractable problem.
That's why I think cross-platform framework authors have consistently been leaving various bits of functionality out for decades. They'd rather deliver "second class" applications than nothing at all, and that's a smart trade-off.
But that does leave a lot of space for native apps.
When you think about it, iOS and Android apps are desktop apps (in full screen mode), not browser apps. And they may be more popular than web apps, for now (though I hate the toll imposed on them).
Maybe someday soon, you'll be able to click on a web app and turn it into a desktop app, with better native platform integration. That might be a reason to stop desktop development.
I know for myself (15-ish year Java dev), even if software I'm writing will only ever be used on my local laptop, if I need UI I'm likely to do a Spring Boot app with a web frontend and Bootstrap.
Anyway for me it looks good and very fast!
That said, it's better than a lot of legacy apps that either don't upscale (and are too small), or half-upscale and end up unusable.
On Firefox it's even worse, looks like it was rendered by 4 MHz Apple II. :|
But if it allows easy porting of a Java app to a browser, then this is still great stuff. Not the most responsive UI, but in case of emergency, why not?
Maybe we can get Spring Boot running in TeaVM instead of Docker. ;)
It's unfortunate Oracle hasn't adopted the approach of treating the browser as a target platform. TeaVM and CheerpJ have just a couple engineers working on this and they've done great things. A fully supported effort could really make this take off.
There's a product called CheerpJ that compiles Swing apps to the browser. I'm not sure when/if we'll see JavaFX.
I also could not use any keyboard shortcuts, and the edit menu options did nothing at all.
Despite that, it really exceeded my expectations.
OpenJdk in wasm might become a thing actually. The download size is not going to be very nice of course but might be acceptable for an intranet type thing that people want to keep alive for whatever reason.
Wasm might soon enable a lot of things that are currently hard and make them both feasible and common again. Flash, silverlight, and shockwave could be kind of nice back in the day and it used to do a lot of things (some of which hopelessly misguided) that are still quite hard to pull off with modern web applications. Most games have better looking and more responsive UIs than many websites. Stuttering laggy divs with broken animations, hover effects, etc. are not a substitute.
I recently got involved in some front end work as I inherited some of that when one of our people left. I must say I find this stuff super tedious to deal with and disappointingly primitive after basically not having done any serious UI work for most of this millennium (usually stick to backend). I suck at this obviously but it seems things could be improved in many ways by rethinking a few things.
IMHO, some native UI kits adapted to WASM combined with modern yet powerful languages like Kotlin, Swift, C#, or Rust should be running circles around most frontend teams in terms of performance, productivity, and quality once this stuff matures a bit.
Scriptable DOM trees as a side effect of browsers exposing their internals to a hacked together bit of scripting language seems to have snowballed into this everything is a document but not really paradigm where you have this unholy mess of nodes and events tied together by a language that is continuously patched up to make this less painful but hopelessly stuck in its own history.
Apologies for the Friday afternoon rant but I've been staring at some example of modern web development the whole day and have a stiff neck from shaking my head in disgust.
Are we talking about the same app?
The UI here is better than most web SPAs (and where it's not, it's not because of the libraries used), and indicative how more uniform, streamlined, and familiar web apps could be if we had gone with a rich widget set and layout engine (like Java has and this uses) from the get go.
And I agree: if your app only needs to run in the browser - use browser tools. But if you really use an app all day long, you're going to want a dedicated desktop version. The browser app-in-an-app model is convenient for casual use, but not optimal for long stretches and doesn't integrate as well with the desktop for real workflow.
Also, if your app exceeds 100k lines of code, there are some languages that might be better than JavaScript.
I'd love to hear more about your idea for web based ireport. Send me a note at jeff at reportmill if you want to chat (or call the main line).
I use it daily at work. It's an impressive feat of engineering with a lackluster ecosystem and inconsistent documentation. Although it's not dead yet (at least technically) as it still has (slow) active development happening.
However, there are other, better (than vanilla Java) languages that generate class files for the JVM which this tool can apparently convert to WASM. Might have some redeeming features. Clojure to WASM maybe???
It’s not like CSS is all that fun — this approach gets rid of DOM manipulation for use-cases where a more pure graphical layout is appropriate.
In no way is that true.
E.g. - https://ramdajs.com/docs/#partial
Of course, I’m assuming that the JS programmer is exploiting FP and dynamic types, and not just transliterating Java style static OOP code.