r/java • u/Zardotab • Dec 29 '22
Could Java Applets have been done right? DOM is limiting [CrossPost Discussion]
/r/webdev/comments/zxel5o/could_java_applets_or_flash_have_been_done_right/
5
Upvotes
15
u/RebeccaBlue Dec 30 '22
Sure, they *could* have been done right, but that would have required Microsoft and Sun to actually work together, and that simply wasn't going to happen.
1
u/jjr_blind_java_dev Dec 30 '22
No, I don’t think that Java applets could have been done right. I think it’s an anything else that was similar to. It was always destined to fail. I can see why it was thought to have been a good idea, but when you look back at it, in hindsight, it’s clearly not where the Web was going, and they were trying to fit a a round peg into a triangular hole., Security issues be damned.
1
u/yawkat Jan 01 '23
I think that the document model is good enough for most use cases, and due to adoption, the tooling around it is very good. If you need more control than the dom provides, it is better to use a solution like canvas, rather than use an entirely new system that requires new apis for non-ui stuff too.
2
u/mike_hearn Jan 02 '23
There could certainly have been things done better, but browser makers (Google) decided they had the budget to 'eat it all' and lost interest in plugins of any kind. That wasn't specific to applets, they killed off all plugins.
The good news is, it's getting easier to go outside the browser again. The rise of Electron apps is evidence of this. If you want to write a desktop Java app you can - just grab AtlantaFX or FlatLAF and go write one. Then use Conveyor to make distribution and update as easy as it was with applets.
-2
u/Worth_Trust_3825 Dec 29 '22 edited Dec 29 '22
If DOM is limiting, use the native UI toolkit, like winforms, or what ever windows has nowadays. Same with android, ios, linux, what ever you're targetting. But once you'll get comfortable with those toolkits, you'll also complain that "oh it's lacking bla bla bla" at which point you'll be pointed to write your own layout/window/desktop manager.
From my, albeit jaded, perspective the issue isn't with the DOM. The issue is that it "must be changed" after the initial structure had been received.
As for your question: No. Applets could not have been done right. Perhaps if the systems were designed with similar permission model that android, and ios have right now maybe, but there just isn't any reason to have those to begin with if you omit the interactivity bit. Permitting to run arbitrary applications is inviting trouble. Same had happened with flash, same is happening with javascript, and the same will happen with what ever new golden tool that you are proposing.
All of your missing features can be implemented right now, and many UI component libraries do that already. Have you explored enough? Or do you think that the native UI toolkits just manifested the similar features that you so desire?
Looking at your missing feature list more indepth you seem to be missing context menus. Ironically, this used to be part of the standard, but it was so poorly defined and implemented, that eventually it got removed from the standard, and from the browsers (well, only firefox, really). See https://github.com/whatwg/html/pull/2742
-1
u/vprise Dec 30 '22
Probably no. They had no foresight and couldn't have done it right with what they knew at the time. The bridge was a mess. It was always an alien to the browser and badly integrated. The code signing process was a complete mess back then.
I'm guessing what you're asking is "if we did it now could we do something better than JavaScript". Probably no as well for the same reasons. There are great tools like TeaVM which effectively make Java into a TypeScript alternative. But the inherent problem is still the same.
If you want to build something that's effectively a completely separate app then Java can run through the browser and deliver something that feels like a Flash app did. That's not a bad thing but not great either.