13 ms·
I haven't been following Java community in a while, can someone clarify this for me please: so the benefit of "thin" JVM comes from GraalVM or Vert.x? I looked
by old-gregg 8y ago
I haven't been following Java community in a while, can someone clarify this for me please: so the benefit of "thin" JVM comes from GraalVM or Vert.x? I looked at https://vertx.io/ https://vertx.io/ and it says nothing to me, I have no idea what a "reactive" application is. Is it an async event loop library? And then there's Polyglot, so now there are 3 new things in the picture.
What do I need to have a simple "hello world" CLI Java app which starts within 25ms and doesn't eat more than 10MB of RAM? Is GrallVM enough?
- deleted 8y ago[deleted]
- yunyu 8y agoVert.x is a framework for developing server applications using an event loop (think Node.js but for the JVM, with the ability to fallback to normal threads). If you've heard of Spring Boot or Spark, it's a lighter/faster alternative to those (which are generally based off of heavier webservers like Tomcat or Jetty). Graal compiles JVM bytecode to native code, so that's the critical factor for your CLI app use case. You'd only need Vert.x if you were writing a server.
- dominotw 8y ago> Spark I thought u were talking about big data spark. But I think you are talking about http://sparkjava.com/ http://sparkjava.com/
- needusername 8y ago> Spring Boot Vert.x is nothing like Spring Boot. Spring Boot combines Spring with autoconfiguration and the ability to run in its own container. Spring Boot can run on Undertow which the other branch of JBoss marketing promotes a lighter weight than Netty.
- Areading314 8y agoBut they're both frameworks for writing a server right?
- needusername 8y agoNot Spring Boot. Spring Boot is a framework for implementing a server side application. For example you use Spring Boot to implement a RESTful server side application including persistence and security. You do not use Spring Boot to write an HTTP server, instead Spring Boot uses an existing HTTP server.
- threeseed 8y agoVert.x uses an existing HTTP server as well: Netty.
- needusername 8y agoI look at Netty as an async IO library. You use Netty to build your own servers. Yes, I know, Netty ships with an HTTP client and server.
- chrisseaton 8y ago> But they're both frameworks for writing a server right? reply > Not Spring Boot. Spring Boot is a framework for implementing a server side application. 'server side application' and 'server' or 'web server' are two terms for the same thing in many people's vocabulary. You two are arguing at cross-purposes.
- needusername 8y agoThen people need to use these words more carefully. 'server side application' and 'web server' are not even close to being the same thing.
- jsight 8y agoRight, but you don't use Vert.x to "write an HTTP server" either. In both cases you use the server from the framework, though in the case of Spring Boot that is also pluggable.
- yunyu 8y agoSorry, Vert.x web would be a more appropriate comparison.
- needusername 8y agoEven Vert.x web has no equivalent to Spring which forms the basis of Spring Boot. Spring is a complete application framework that combines dependency injection, AOP and enterprise integration. To my knowledge Vert.x and Vert.x web have no equivalent to Spring Boots autoconfiguration. I am not saying Vert.x or Vert.x web are worse than Spring Boot but they do very different things.
- signal11 8y agoSpring's WebFlux is the closest analogue I could find to Vert.x web (https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html https://docs.spring.io/spring/docs/current/spring-framework-...). However WebFlux is quite new and looks like it's targeted to existing projects that use Spring and need some reactive features.
- repolfx 8y agoYes it's SubstrateVM that gives the small fast starting binaries, if you can accept its limitations.
- BenoitP 8y ago> What do I need to have a simple "hello world" CLI Java app which starts within 25ms and doesn't eat more than 10MB of RAM? Is GrallVM enough? Yup. Here is another tutorial [1]. There are limitations, though: * It's AOT, which means you don't get the JVM peak performance that come from JITting to your wordload profile. (but maybe in the future we can have startup in AOT then transition to JIT?) * You're getting an embedded generational garbage collector. Not the sweet stuff like G1/ZGC/Shenandoah. * You can't do dynamic class loading, or you have to declare (and know) beforehand which classes are reachable. A fair amount of frameworks use this and will not work with native-image. I suspect these will provide mechanisms to help in this regard in the future (for JSPs: generating the code of all classes-pages that are reachable at compile-time). * There are other limitations [2]. All in all, great for CLIs and cloud lambdas. [1] https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-ed6f14ff7692 https://medium.com/graalvm/instant-netty-startup-using-graal... [2] https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md https://github.com/oracle/graal/blob/master/substratevm/LIMI...
- deadc0de 8y agoAOT implementation in the JDK, that we call the "HotSpot AOT" implements tiered compilation (look for $JAVA_HOME/bin/jaotc). It is also based on Graal, but with a different set of plugins. You get reasonably good startup and re-JITing afterwards. Of course it doesn't give you compactness on the SVM, but it supports regular java code with class loading, reflection, etc. A talk about HotSpot AOT: https://youtu.be/n5DCg6M2MDM https://youtu.be/n5DCg6M2MDM
- agibsonccc 8y agoTo answer some of your questions (I use vertx and mainly focus on the JVM world) - reactive is actually a widely used term in the java world to mean "event loop with async programming. Origin of the term here: https://www.reactivemanifesto.org/ https://www.reactivemanifesto.org/ Graal is an R&D effort by a few folks in the java community driven by oracle right now to allow AOT compilation among other things for the JVM: http://www.oracle.com/technetwork/java/jvmls2015-wimmer-2637907.pdf http://www.oracle.com/technetwork/java/jvmls2015-wimmer-2637... Java is generally not for apps that require fast VM spin up times. That being said, for what the JVM ecosystem can do it isn't bad in practice for heavy server applications. I know gravitational mainly works in the go ecosystem which has its own trade offs there, but considering what else java already has a mature ecosystem for (big data, well understood native internals, other language built on top of it) the startup times and weaknesses while not ideal haven't been a show stopper. GraalVM is an attempt to address a wide variety of problems you get with JVM startup time, GC etc. At most it's simplistic right now and will be for a while. The fact they are working on it is really cool though! Hope that helps!
- old-gregg 8y agoThanks, that's very helpful
- nimchimpsky 8y agoWith java 9 modules, you can create a basic application as a complete Java run-time taking under 37 MB. You don't need the jvm preinstalled. https://www.linkedin.com/pulse/hello-world-java-9-modular-era-eric-kolotyluk/ https://www.linkedin.com/pulse/hello-world-java-9-modular-er...