14 ms·
TeaVM: Build Fast, Modern Web Apps in Java
- phpisatrash 6y ago> without the difficulties of a JavaScript development stack. Yes. It's very difficult to write a full stack application using JavaScript. I cannot find tools or frameworks.
- speedgoose 6y agoI don't know whether it's sarcasm or not.
- throwaway-42808 6y agoThe frameworks and tools aren't all that stable, reliable, or intentionally designed compared with what Java programmers might be used to. I don't fault anyone for trying to get off the bus.
- holoduke 6y agoCome on. Even if you dispise the js world, plenty of examples of well written JavaScript frameworks and successful end user products.
- throwaway-42808 6y agoSounds easy enough: Use the well written frameworks as needed, and you can make successful end products too. What would be your advice to someone seeking to do this? e.g. - is it simply a matter of intelligence, perseverance, attitude? - is there a technical or social practice you find helpful?
- forgetfulness 6y agoIs JS tooling less of a Rube Goldberg machine nowadays? I remember that the people I knew who got into it but not fully used to use these humongous auto-generated boilerplates that glued together webpack, gulp, babel, had build processes involving native dependencies that would fail with weird errors vaguely related to Node JS versions, and this all to develop in the frontend. Compare: Clojure. You have the project.clj file and put your dependencies there. The you do lein run or build a fat jar and run it like java -cp your.jar your_app.core. The end.
- gdubya 6y agoNot really (any less). A couple of years ago we migrated a project from Spring + GWT to Spring + Vue. The Vue part is nicer, but everything around it feels messy. The team is primarily backend / java developers (we had a frontend expert at the time too), but we felt that the JS frontend part shouldn't be that hard to master. Maybe Vaadin would have been a better option after all?
- dmingod666 6y agoAfter all the shebang out comes an html with tables instead of divs.
- michaelcampbell 6y agodivs + css in yet another file, you mean. Tables at least do something in and of themselves; divs do not.
- dmingod666 6y ago1999 called, it wants it's html structure back. lolz!
- michaelcampbell 6y ago<eye roll> For tables, tables are fine. The only thing worse than jumping on a new thing because it's new is completely abandoning something because it's not. And "lolz"? 2010 called...
- yepthatsreality 6y agoNo it’s even more so with the rise of framework frameworks like Next.JS and Cypress. These frameworks are just wrappers around other frameworks. JS will never escape this as its primary reason for existence was a glue layer between Browser and HTML/CSS.
- nicoburns 6y ago
- isbvhodnvemrwvn 6y agoI don't see how using TeaVM, which is not stable at all, has very little activity (a handful of commits since summer) and is going to be extremely niche since most people don't have that weird aversion to modern JS tooling, is a solution.
- pjmlp 6y agoMy last four projects, changed from Angular 6 and Ionide, just Angular 6, followed by Vue.js, now doing one with React. Who knows what the FE team will remember to come up on the next assignment.
- marktangotango 6y agoI used to work at a large F500 corp and managed a legacy app that used raw js/jquery on the front end. Every two years like clockwork we'd get a mandate that "all apps will now use X" where X was [ext-js, ember, angular]. As the person in charge of the app I ignored all those directives and saved myself a boatload of work. App is still using jquery today last I heard.
- dmingod666 6y agoGenius
- pwdisswordfish0 6y agoWhy does everyone keep lumping jQuery in with vanilla JS, in exalted reverence, as if jQuery wasn't a massive source of bloat during its heyday? The practice of pulling in all of jQuery just to add an event listener for showing and hiding a div is _why_ web development looks the way it does today. Normalization of deviance is the vehicle, and jQuery was the payload. I come across stuff "only" using jQuery today, and every time, I end up ripping it out because it's totally unnecessary and often ends up being the source of breakage and logic errors. What's worse is that its APIs are awful, and it's impossible to debug in its blob form. The fix always ends up being to just get rid of it.
- JAlexoid 6y agoThat's not the point of the comment above. FYI: The point is that every year or two you get a new "revolutionary" framework. Unless you're working full time on FE - you're not going to be "in with the cool kids".
- bestinterest 6y ago
- SamoyedFurFluff 6y agoI don’t think this is the definition of difficult the author is using. I find JavaScript intimidating and difficult due to too many tools and frameworks. I cannot rely on any of their documentation, either on their site, or the peripheral collective experience of stack overflow, to be accurate to the actual thing I’m trying to use. This makes it difficult to me.
- dexterdog 6y agoFinding them is not the problem. Figuring out which one to use is.
- SomeHacker44 6y agoThe obvious way to me for full stack JavaScript is to use JavaScript on the server with node.js and JavaScript on the client via a... Browser.
- MaoTheMeow 6y agoJava is too slow. Just because modern hardware allows for software to be very heavy doesn't mean that it should be acceptable for you as a developer to produce heavy software.
- oweiler 6y agoWhich type of slow?
- ta988 6y agoDon't engage just someone repeating the same FUD from 20 years ago...
- patates 6y agoI'm sincerely wondering how you came to that conclusion. Java has one of the fastest VMs, but maybe you mean the startup speed?
- throw2838 6y agoSlow startup from command line
- pjmlp 6y agoAll free JDKs now offer AOT compilers and JIT caches.
- coldtea 6y agoWhich is relevant for a server how?
- forgetfulness 6y agoThis is on the comment thread of a tool to make client-side applications. However, it's all besides the point because this tool takes Java (JVM) bytecode and translates it to WebAssembly, there's no JVM involved for end users at any point.
- svrma 6y agoHow does Java pricing work these days (after being bought by Oracle)?
- Tomte 6y agoYou can use OpenJDK (via adoptopenjdk, Redhat or many others) and it's free. Or you pay Oracle for support. Or some other company. Oracle isn't special.
- coldtea 6y agoWell, on the other hand OpenJDK is 99% Oracle's work repackaged. If Oracle decided to stop putting out new FOSS-licenced versions, there would be no new OpenJDK releases (since all the core Java devs are Oracle employees). So it's like a no-community project, where you get a dump of FOSS code every now and then from a vendor.
- hocuspocus 6y agoIn recent Java versions, there's roughly 20% of external contributions: https://blogs.oracle.com/java-platform-group/the-arrival-of-java-15 https://blogs.oracle.com/java-platform-group/the-arrival-of-... Oracle seems to pursue GraalVM EE as a way to monetize Java. It would be insane for them to change the license, piss off companies with deep pockets, risk a hard fork and see most employees working on the JDK leave.
- coldtea 6y ago>In recent Java versions, there's roughly 20% of external contributions: Have to check your link to find out, but is it by number or by impact? (Asking cause many projects have seemingly many "external contributors" but if one looks almost all real work happens by a core team, and the external contributors just do some change here and there, or even clerical work, like fixing comments and documentation and such).
- 6y ago
- themaninthemud 6y agoMaybe having a SSL cert would made it more presentable for a web framework. Maybe
- villgax 6y agoLol Java in 2020 for performance & that too with front-end? I can only imagine the wait-times between changes to source.
- kaba0 6y agoYou do realize that the JVM is like one of the best performer out of the high-level languages?
- dariosalvi78 6y agoJava applets reinvented
- jtheory 6y agoNah. Java applets involved running an actual JVM on every client computer, which meant basically doubling the risk surface of the browser... plus you had a completely different UI (that couldn't match the browser UI) sitting inside a web page. I confess I wrote a bunch of Java applets back in the day; but I can't say I'm surprised they died, and I don't think they'll be back.
- macspoofing 6y ago>I confess I wrote a bunch of Java applets back in the day Heh. Nothing to confess. Before the HTML5 set of standards (circle 2008), there were certain things you just couldn't do in the browser with JavaScript. That's why there was space for plugins like Applets, Flash, ActiveX, RealPlayer, etc. I did quite a bit of Flash/AS3 (along with the Flash wasm/asm precursor named 'alchemy') development back in the day. If I was able to do it with JS/HTML/CSS I would have done that instead - but you just couldn't.
- abeppu 6y agoAnyone who has actually tried this have any comments? I think it's interesting that they seem to position themselves as an alternative to programmers of jvm languages needing to switch to javascript for browser-side work, but they don't make a clear comparison to eg scala.js or kotlin js, where js code is generated, but not from class files. I've tried playing with those, and one source of challenges is working with js libraries, which need some wrappers expressing method signatures, which is sometimes a challenge. TeaVM has a bunch of annotations for js interior, as well as the ability to deal with js code as just strings. But I can't see that it clearly solves the issues I find most annoying about scala.js or kotlin js. Is this only a great fit if you're in a polyglot jvm team that also wants to run that code in the browser?
- pojntfx 6y agoI've used it because my uni still forces us to use Java (https://github.com/alphahorizonio/jnebulark https://github.com/alphahorizonio/jnebulark) but the experience hasn't been that great for the actual framework (bindings are way to hard to do; I haven't found a way to do Promises yet, see https://github.com/alphahorizonio/jnebulark/blob/main/src/main/java/space/nebulark/jnebulark/bindings/WebnetesNode.java https://github.com/alphahorizonio/jnebulark/blob/main/src/ma...). In general, docs are lacking quite a bit as well (you have to use the development version for most things now, which isn't in sync with the docs). We just took the sane route, wrote the backend in TypeScript (and ported to Java for Uni), and used React for the frontend. The WebAssembly support of TeaVM is fun to use for small modules though, we integrated it into a WIP project: https://docs.webnetes.dev/getting-started/develop/java.html https://docs.webnetes.dev/getting-started/develop/java.html
- shannah78 6y ago"I haven't found a way to do promises yet". TeaVM provides Java wrappers for most JS APIs, including promises (https://github.com/konsoletyper/teavm/blob/master/core/src/main/java/org/teavm/common/Promise.java https://github.com/konsoletyper/teavm/blob/master/core/src/m...). If you require an API that doesn't have a wrapper yet, it is dead simple to create your own wrapper. Or just use the @JSBody annotation to write your own ad-hoc Javascript.
- macspoofing 6y agoIs this a Java alternative to Blazor?
- shannah78 6y agoYes, you could describe it that way, I suppose. TeaVM is just the "VM" part of it. The developer has a "sister" project called "Flavour" that provides a UI framework. https://github.com/konsoletyper/teavm-flavour https://github.com/konsoletyper/teavm-flavour
- TeaVMFan 6y agoTeaVM + Flavour makes a superior alternative to Blazor. * TeaVM supports threads, Blazor does not. * TeaVM apps can start in 3s, Blazor apps cannot. * TeaVM eliminates unused code for fast startup, Blazor is architecturally limited to download an entire VM at startup. Details: https://frequal.com/java/TeaVmVsBlazorWasm1-0.html https://frequal.com/java/TeaVmVsBlazorWasm1-0.html Comparison chart: https://frequal.com/java/TeaVmVsBlazorChart.html https://frequal.com/java/TeaVmVsBlazorChart.html
- oweiler 6y agoI always thought of TeaVM as a toy project, but boy, was I wrong!
- chrismorgan 6y agoI have Firefox’s “HTTPS-only” mode enabled. teavm.org is only served on HTTP. This gave me a rather bad first impression of a thing for making modern web apps—TLS is table stakes that you should never be without. (I tend to find something HTTP-only about once a day, normally on sites that have been around for over ten years. Normally I’d just shrug if it’s a content site, but this being for making web apps, I figured it was worth commenting on.)
- josho 6y agoTell me again what the threat mode TLS protects against for a marketing site? The only thing I can think of is my ISP injecting some HTML at the top of the page. Something that I haven’t seen for years.
- nayuki 6y agoLetting the ISP inject stuff is the threat model, and it has happened in real life. https://www.theregister.com/2015/03/27/github_under_fire_from_weaponized_great_firewall/ https://www.theregister.com/2015/03/27/github_under_fire_fro... Every connection that happens over unsecured HTTP is a connection that can be hijacked by middlemen for nefarious purposes, both for spying and for attacking. Encrypting as many connections as possible is a form of herd immunity. Encrypting even unimportant "marketing" websites protects everyone on the web by raising the cost of interception and lowering the benefits.
- jtheory 6y ago100% yes. It's also about the entire internet & its users, not just threat models on specific sites. We can't ask the general public to consider threat models and evaluate what sites should need HTTPS or just HTTP. General, non-technical intuition is basically useless for this eval; it's not a good path. It's much smarter to just make HTTPS the default, make it easy & free for any site to provide it, and then let browsers show big warnings for any site that's not secured. (Browsers are moving this way already)
- ev1 6y ago
- exabrial 6y agoThis is pretty danged slick. I especially like the API to create your own components very intuitive. One rotten egg I can spot: "Supported subset of Jackson". Ow. Jackson is unfortunately a land mine, rattled with CVEs over the years. This was mostly fixed by taking the best ideas from Jackson and standardizing them as JsonB, which not have several good implementations. I would highly suggest they drop Jackson support in flavor of JsonB just so the Jackson libs don't have to be on anyones class path.
- willvarfar 6y agoAny more details? A quick googling doesn’t find many talking about comparative performance and security of Jackson vs jsonb vs gson? Have seen Jackson in parts of my code base (internal, but still)
- jillesvangurp 6y agoThese 3 issues basically. https://www.cvedetails.com/vulnerability-list.php?vendor_id=15866&product_id=34008&version_id=&page=1&hasexp=0&opdos=0&opec=0&opov=0&opcsrf=0&opgpriv=0&opsqli=0&opxss=0&opdirt=0&opmemc=0&ophttprs=0&opbyp=0&opfileinc=0&opginf=0&cvssscoremin=0&cvssscoremax=0&year=0&month=0&cweid=0&order=1&trc=3&sha=0b83cc9c136be1365ed375c86d44c64feaea0002 https://www.cvedetails.com/vulnerability-list.php?vendor_id=... As Jackson is used in Spring, you can assume most banks, big corporations, etc. use it. So, update your dependencies and it's fine. Gson is kind of to be avoided for the simple reason that it seems to be no longer maintained by Google. I've used it in the past and its fine but wouldn't pick it for something new because of this. If you are using Kotlin, kotlinx serialization is worth a look. I've been using that recently. One of the nice things is that it relies on compiler plugins and code generation rather than a lot of reflective magic at runtime. From a security and performance point of view, that's a good thing.
- listenallyall 6y agokotlinx.serialization has a learning curve, but it is quite flexible and very fast. I've only used it on the JVM but obviously its cross-platform nature is a big plus as well. It could use some simplified syntax (similar to how Kotson improved on Gson), perhaps a JPath parser. But for something that just went 1.0 very recently, it is terrific.
- comick 6y agoForget about web development for a second. TeaVM is primarily a JVM byte-code to JS (and WASM, and plain C code) compiler. It is so effective at this, that not long ago I was able to bring a byte-code only proprietary JVM library to the web and it just worked. This thanks to an almost complete classpath library (based on Apache Harmony) and a macro system [1] that allows to produce POJO to JSON conversion code at compile time. [1] http://teavm.org/docs/runtime/metaprogramming.html http://teavm.org/docs/runtime/metaprogramming.html
- abiro 6y agoHow does this compare to Google Web Toolkit?
- steve_taylor 6y agoIt compiles JVM bytecode. GWT compiles Java source code. Therefore, GWT requires source whereas TeaVM doesn’t. It also means TeaVM will work with any language that compiles to JVM bytecode.
- TeaVMFan 6y agoTeaVM and Flavour are an improvement over GWT. Why is TeaVM better? * Full threading implementation * Fast builds * Designer-friendly HTML/CSS Detailed comparison: https://frequal.com/TeaVM/TeaVmVsGwt.html https://frequal.com/TeaVM/TeaVmVsGwt.html
- manishsharan 6y agoHow big is the js for ToDoMVC generated by TeaVM ?
- TeaVMFan 6y ago31.55KB transferred according to Chrome for the sample app here: http://teavm.org/live-examples/todomvc/#/ http://teavm.org/live-examples/todomvc/#/ Compared to React, GWT, Vaadin, and CheerpJ, TeaVM comes out on top for Lighthouse scores and JavaScript size: https://renato.athaydes.com/posts/comparing-jvm-alternatives-to-js.html https://renato.athaydes.com/posts/comparing-jvm-alternatives...
- franklampard 6y agothe word GWT gives me PTSD
- dzonga 6y agono doubt. was once involved at a place that had a GWT codebase and I was a react dev, right there then I decided to quit my job. surprised why the industry continues to regress backwards and not embrace html and the web as they should be.
- TeaVMFan 6y agoTeaVM, especially when used with its Flavour toolkit, fully embraces HTML and CSS. Flavour templates are HTML5 with a small number of extra elements to allow dynamism and interactivity. Templates can be styled with CSS and worked on by designers and developers alike. A good way to think about it is a new single-page app framework for the web that lets you code in a popular, safe, statically-typed language with great IDEs and tools.
- flowerlad 6y agoThe hard part about WASM is passing data in and out. You can't pass JavaScript numbers, strings, arrays or objects, because WASM only understands bytes. Does TeaVM make this easier? Update: TeaVM does make it easier: http://teavm.org/docs/runtime/jso.html http://teavm.org/docs/runtime/jso.html
- CamouflagedKiwi 6y ago> Its close relative is the well-known GWT The thing that is (somewhat) well-known for being an awful mess, which Google eventually realised and moved away from? Those who do not learn the mistakes of history...
- cromwellian 6y agoOnly the UI toolkit part was a mess. Google still uses Java to JavaScript compilation, through GWT’s successor J2CL.
- dang 6y agoAll: please don't take threads like this on generic tangents, especially not generic flamewar tangents, including programming language/framework flamewar tangents. Those are repetitive and tedious. We want interesting, curious discussion. That usually comes from engaging with the specifics of the article. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- dang 6y agoIf curious see also 2018 https://news.ycombinator.com/item?id=16075933 https://news.ycombinator.com/item?id=16075933
- Sophistifunk 6y agoOn-topic questions: If it's generating wasm, how's the collector work? If it's generating JavaScript, what happens to weak refs?
- konsoletyper 6y agoThere are separate compiler backends for Wasm and JS. JS BE does not support WeakReferences (or rather supports them as a class, but does not support weak reference semantics). For Wasm BE I written my own GC, which supports weak references.
- d0paware 6y agoWhat's the recommended way to drop into blocking code? For example, if you already have a worker thread pool executing some blocking code. I am guessing it will automatically look for static occurrences of park(), wait(), etc anything that goes into a blocked state and yields to the next handler on the event queue? Even with the coroutine support, it doesn't seem smart enough to make something like "while (true) { ... }" auto-yield to other functions or handlers on the event queue. To be fair, it's not like javascript does this for you either.
- shannah78 6y agoTo use "blocking" code you must be running in a Java thread. You cannot "block" the main javascript thread. Generally all of our code runs on a Java thread. For JS events (which always occur on the main JS thread, I just wrap in new Thread(()->{...}).start();