7 ms·
Show HN: 300k lines of Java UI code running as JavaScript in browser
- yuchi 9y agoThis is… actually not bad. :shocked:
- recursive 9y agoUhh... It seems very bad. I clicked "Run RMStudio DOM" in Chrome. It loaded dozens of java packages for half a minute, and then showed me a 90s looking splash screen with three buttons on it. None of them do anything. I'm assuming I'm supposed to be seeing something else. Edit: I tried "Run RMStudio Swing". That one actually loads eventually. I don't understand what kind of app it is, but it appears to leak DOM elements. I see 99 DOM elements when the editor first loads ("New"). Mousing back and forth over the menus for a few seconds makes the number of elements increase by hundreds, and it never goes back down.
- megamindbrian 9y agoThat's the not bad part! Half a minute for a Java app to load is twice as good as most. And it loads in your browser. Can you do the same thing to eclipse? That is still widely used despite how long it takes to load and how "90's the UI looks"
- wwweston 9y agoCongratulations! Sounds like the 90s Java applet experience to me.
- imron 9y agoYes. Yes it is. I mean as a technical feat it's impressive (in the same way as running Linux in the browser via JavaScript [0]). At the same time I'm horrified that someone would seriously do it (though I can understand the business reasons for wanting to do so). 0: https://bellard.org/jslinux/ https://bellard.org/jslinux/
- throwawaydbd 9y agoAh, the cycle is complete. Straight back to Java Applets now that we have 8000000 layers of abstraction in the middle. Good riddance horrific ball of JS/HTML/CSS
- kizer 9y agoAs long as the app performs well, who cares how many layers of abstraction exist between the app logic and hardware? If it took like 2 seconds a button to register a click, then I would say the layers of abstraction are too numerous. But this app seemed very responsive - and all I would have to do to start it is navigate to a page in my browser.
- topspin 9y agoThis is exactly the thought I had. Applets were always a crashy mess. Who knew Java would eventually get into the browser via transpiler (if that's what this is...) Anyone have a thought on how one might pronounce CheerpJ?
- _pdp_ 9y agoJava and JavaScript are not that different. We used to have a security testing engine that was written in Java and transpiled into JavaScript with our own compiler. It works and it was OK in the days when static typing was one of those things that were missing from modern JavaScript. We do not do this any more. Everything is JavaScript these days.
- kizer 9y agoPeople often emphasize that their etymology is just incidental, but the similarities are definitely deeper than just the names. Why else would the creator have named it JavaScript?
- kizer 9y agoRuns smoothly - almost indistinguishable from native. With webassembly (and I know this is in JS) and the general progression of the web platform and JS engines it seems to me that web apps will continue to grow in number and in popularity. I don't see why the web app should die.
- le-mark 9y agoAppears the tech behind this "cheerpj" a java transpiled to javascript[1] system that appears to contain all of openjdk including swing(!?!). That's kind of cool actually. But creating applications with such a system seems highly problematic. See for example GWT (google web toolkit)[2] which also transpiled java to javascript. I only see legacy GWT apps around nowadays, the world moved on. So I really don't see the appeal of this; unless you're a java shop hell bent on NOT learning modern frontend development. [1] https://www.leaningtech.com/cheerpj/faq/ https://www.leaningtech.com/cheerpj/faq/ [2] http://www.gwtproject.org/ http://www.gwtproject.org/
- gschrader 9y agoLegacy systems that haven't migrated to some other front end yet. There would be a lot of companies in this situation. That said, I'm not convinced this is the best approach. I think I'd prefer rewriting parts at a time of a system that big.
- ramses0 9y agoThink bigger. Start a consulting company that just runs around and recompiles all people's old Java Swing crap into "web apps" like this one. Charge $10-50k / pop. Get on the consulting gravy train by somehow allowing piecemeal callouts to "real dom" (kindof like an IFRAME from within JAVA) which lets you start rewriting bits and pieces into some angular.next framework. By the time you finish converting the majority of their Swing to Angular conversion, angular will finally be deprecated (or dart-only, lulz) and you can set yourself up with a new and improved consulting company which will convert Angular to React as soon as the Java to Angular contract finishes up! /s
- CamperBob2 9y agoSounds like a great instance of the old adage "Consulting: If you can't be part of the solution, there's good money to be made in prolonging the problem."
- 9y ago
- bsaul 9y agoruns on my iphone, but text input doesn't seem to trigger the appearance of the keyboard. Other than that, it's pretty impressive.
- yomansat 9y agoEven on a browser, not taking in inputs, until I realised I needed to press on the "A" to insert text. So probably just a UX thing...
- TheAceOfHearts 9y agoThis is really nifty as a proof of concept, major kudos to the authors. However, it completely kills accessibility, so it's probably best to avoid for any serious projects. I've gotta ask, since I've never used Java applets... Wasn't this already possible back in 1995? Have we come full circle?
- pavlov 9y agoYes, around 1996-97 there was a lot of hype around desktop applications delivered as applets. E.g. Corel Office for Java: http://www.edm2.com/index.php/Corel_Office_for_Java http://www.edm2.com/index.php/Corel_Office_for_Java
- jeffreportmill1 9y agoIt was possible, but there were issues with performance, compatibility, security and configuration. Everyone had a different version of the Java plugin implemented with different platform Look-And-Feels (if you had the plugin at all). And then the browser vendors went to war against plugins. CheerpJ is a much better approach - doesn't require a separate plugin, doesn't have version problems, has inherent JS-sandbox security, uses the same look-and-feel and performs great (after initial download). For a large project, it's nice to have all the benefits of desktop development with a strongly typed language, but still have the ability to publish to the browser.
- switchbak 9y agoOne of the biggest impediments was that Microsoft had this crappy implementation of Java on IE that was simply useless. Making a portable (modern at the time) applet that worked in IE was essentially impossible. I have no doubt MS did that on purpose. All said, I think having a standardized binary ASM model in the browser is the right way to go, even if it is a couple decades later :)
- jimbokun 9y agoFind it amusing this product was originally written in Objective C, converted to Java, now to JavaScript. http://www.reportmill.com/company/ http://www.reportmill.com/company/
- mattnewton 9y agoJava finally made it on my iPhone. "Java uh.. finds a way." -Goldblum This is actually pretty cool, though something about seeing my taskbar containing a window that contains an jvm that contains another window drawn in swing makes me think we've lost our way somewhat.. better we make the computers do it than rewrite everything by hand I suppose.
- throwawaydbd 9y agoI see it another way... It's actually a Holy Grail in a way. OS makers have made things intentionally incompatible since the beginning of time. Developers are finally finding effective ways to fight back. We could have had Java/whatever everywhere ages ago if the OS makers were not purposely segmenting the market. We might finally have a way out of the tyranny of OS makers taking 30% of the revenue in apps stores for example. WASM will change everything. Every platforms will be compatible somewhat against the will of OS creators. Expect some kind of backlash or walled gardening to commence shortly...
- malkia 9y agoI won't mind IntelliJ on the web - even if it takes some time to load, or CLion - which targets emscripten/webasm/something Imagine a bit more powerful Chromebook with that..., but then where the files, projects, etc. would get stored?
- switchbak 9y agoI've wanted this for a while - have my ThreadRipper box at home, and use a remote IntelliJ on a wimpy laptop that just runs a light UI through the browser. Real latency benefits vs running remotely, especially on a typical coffee shop wifi. Ahh, but I don't see that happening any time soon. Edit: or spark up a really powerful instance on something like Hyper.sh when you need it, close it down when you're done. Pay more to get a well provisioned instance when you need real horsepower.
- mattnewton 9y agoFor the second point, I've had a lot of success doing this with a Jupiter notebook. It's not an IDE by any means but it's very productive for exploratory work, and when you need horsepower you just spin up the kernel on a beefier cloud machine.
- SunboX 9y agoTry https://c9.io/ https://c9.io/ or https://shiftedit.net/ https://shiftedit.net/
- slig 9y agoThat's impressive. Now it's only a matter of time for the Java app compiled to JS running on Electron.
- JBiserkov 9y ago...Electron x86 running on Windows-on-ARM.
- quuquuquu 9y agoEwwwwwwww lol. That would be like me hopping on my bike, pedaling for hours, which charges up a battery that is attached to it with an inverter, putting it into a carboat, driving onto the water, to get into my seaplane. The original goal was for me to be in the air. LOL
- kenoyer130 9y agoSee also GWT if you are just hell bent on running Java in the browser. As one of our developers commented, 'it is webforms all over again'. Also see https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/ https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-a... For legacy apps or if your back end is Java and you need to share code, GWT and this concept is a good solution. If you are just trying to avoid learning JavaScript/CSS this will leave you very unhappy.
- rpeden 9y agoYou don't have to use GWT webforms-style: you can also use something like GWTReact[1]. It ends up being more verbose than JS or TS, of course, but might be useful if you've got a lot of business logic in Java that you want to be able to use easily in a modern web app. There's also JSweet[2], which compiles Java to TypeScript. I believe it can automatically convert TypeScript definitions into Java, so it's a good way to write Java that calls existing JS libraries. Granted, writing Java to run in the browser probably isn't the best solution for most people. But there are certain situations where it makes sense, and it doing so doesn't mean you're condemned to write an application that feels like crufty legacy garbage. [1] https://github.com/GWTReact/gwt-react-examples https://github.com/GWTReact/gwt-react-examples [2] http://www.jsweet.org/ http://www.jsweet.org/
- jackmott 9y agono
- kelvin0 9y ago"We test extensively on the latest versions of Chrome and Safari. For the best experience, we recommend Chrome." Why no FF? What could possibly cause them not to support it? Any specialists out there?
- hxtk 9y agoI'd imagine it's a large codebase and they're trying to maximize the number of people that can access it while minimizing the number of supported browsers. There are very few platforms where firefox is available and Chrom(e|ium) is not. FWIW, it actually does work on Firefox Quantum; it's just not guaranteed to work.
- nneonneo 9y agoI’m on a 2G mobile connection right now, and that site refuses to load. I’m going to guess this has something to do with bundling all of Java, but surely there must be a better way to write UIs that doesn’t involve downloading the whole JDK to my browser cache. This is not a joke - webpage size is a real issue. Even on this connection I can browse a lot of pages normally, but something like this Java UI toolkit just goes way over the edge. On this connection I can’t update any native apps because they’re all much too big - but the ones I have continue to work fine. But web apps generally don’t guarantee persistence in the same way. If an app I need is suddenly removed from cache at an inopportune time, I’m screwed. That’s why web apps really need to be leaner.
- jeffreportmill1 9y agoI don't disagree it's not for general web pages, but it's more than fine for any non-trivial app. Downloads less data than 60 seconds of YouTube. The runtime is CDN shared, so the more apps that use it, the less it will matter.
- throwawaydbd 9y agoIronically Java apps would ideally be much leaner than JS. Once WASM support is done for CheerpJ the bundles should be quite small. JavaScript developers are foaming over "tree shaking" which is child's play compared to how much dead code you can remove from a compiled language. If you don't use tricks like reflection you can eliminate basically all dead code from Java. This is done routinely on Android via proguard and Android apps would be very lean if people didn't take the opportunity to jam tons of crap into them. It seems the natural way of things is to bloat your app up to at least 5mb by tacking on crap until it's "too slow" for normal users. The Java Applets of ye old days were basically desktop apps and only took about 3 mb, huge for back then but probably below average for a site these days. And this was before Java had Proguard and related tools to strip unused code.
- wolco 9y agoIs there anything like this for php?
- LeanderK 9y agoit's impressive, granted. But it feels like a parody, the long loading-time, the horrible UI, the weird scrolling. It just screams Java.
- fenesiistvan 9y agoHow file and network I/O works here?
- jeffreportmill1 9y agoThe standard java.io.File and java.net.URL work as normal. CheerpJ provides a choice of filesystem access methods. This includes a read-only filesystem based on HTTP, a local read-write filesystem based on indexDB which is persistent across sessions, and a facility to access JS strings as files, useful to pass input data to target converted Java programs. DropBox and Google drive are also available.
- whipoodle 9y agoSeems to perform pretty well. Much more usable than I was expecting.