15 ms·
JDK 15
- mjb 6y agoNice to see ZGC marked as production-ready. With Shenandoah, ZGC, and G1 the options for garbage collection in Java are so much better than they were just a couple of years ago. Even better, the need to do a bunch of brittle tuning and tweaking has mostly gone away. Java still makes the GC work harder than other languages. In some of my testing, idiomatic "microservice" Java code makes ~10x as much garbage per request as equivalent idiomatic Go code. Some of that is the language, and some is just that libraries and frameworks are super allocation-heavy. If the ecosystem can tighten that up, then these great GCs will have even more impact.
- jillesvangurp 6y agoDepends, if you look at projects like Elasticsearch, you see a shift towards using a lot of off heap memory and less reliance on heap over time. Mostly the JVM and languages on the JVM are evolving towards things like having immutable data structures, async processing and IO, using data classes/structs, etc. A lot of my recent projects have actually been fairly modest in terms of memory requirements compared to a few years ago where I'd have thought nothing of using 4GB heap on a simple spring app.
- darksaints 6y agoFully agreed about java libraries and frameworks being more allocation-heavy than they need to be. The problem is that the libraries and frameworks are built using the abstraction capabilities it has, and in Java, those abstraction capabilities are very allocation heavy. I'd love to see a jvm or graal implementation of ASAP memory management. The idea generally being having extremely aggressive analysis on your code, reducing heap allocations where possible, statically managing objects where they can provably infer object lifetimes, reference counting everything left over that provably can't result in cycles, and then garbage collecting everything else.
- specialist 6y ago"ASAP memory management" Do you mean this? ASAP: As Static As Possible memory management https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-908.pdf https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-908.pdf
- higerordermap 6y agoGuess so. That paper is pretty well known.
- darksaints 6y agoYes. To be clear though, the idea is already hard enough to implement, but it would be incomprehensibly hard in the JVM ecosystem. The JVM directly implements allocation decisions, but the analysis necessary for ASAP is done mostly in higher level reprensentations of code, and there is no direct API in java byte code to tell the JVM to statically allocate or reference count a specific object.
- thu2111 6y agoHardly incomprehensibly hard. It's been done already, it just never got out of the lab into the product. http://codrutstancu.com/p81-stancu.pdf http://codrutstancu.com/p81-stancu.pdf SVM has support for snapshots/isolates, where you can ~instantly instantiate a new JVM with a fresh heap. If you set your GC params such that it never really collects, you get something close to that but without the complexity.
- MrBuddyCasino 6y ago> Fully agreed about java libraries and frameworks being more allocation-heavy than they need to be. Much to the chagrin of Martin Thompson, even the standard library is affected. Avoiding allocations is something most Java programmers don't even think about, because they are not aware it might be an issue and because there is no alternative - in Go and Rust you can stack-allocate instead, in Java you can't (not really).
- nicktelford 6y ago
- ragnese 6y agoI thought the rule of thumb was that only live objects matter for GC performance (mark-and-sweep only counts what's alive and just purges everything else). Is that not true in modern era?
- nicktelford 6y agoThe more allocations you have, the more frequently your young-gen GC has to run (or the larger your heap size needs to be to keep GC frequency constant). Allocations are cheap, but they aren't free, and you definitely pay a cost in GC.
- nicktelford 6y agoI believe the main reason for this is that Golang is heavily "value-oriented". Combined with escape analysis it causes most of the short-lived objects to actually be allocated directly on the stack. While the JVM also has escape analysis, because everything is a pointer the chances of an object escaping is considerably higher. I'm hoping that when Project Valhalla eventually lands, it'll help greatly with allocations and reduce memory pressure even further.
- vbezhenar 6y agoWhat is idiomatic in Java? Netty does little-to-no allocations. One can implement very thin layer on top of Netty to provide API similar to Go standard HTTP server.
- tomlu 6y agoYou have to work extra hard and give up language niceties to reduce allocations, more so than certain other languages that are more value oriented. You want an List<T> of objects? It's now a list of pointers to individual allocations. You want a Path class instead of just passing strings around, for type safety? One extra allocation per object.
- specialist 6y agoI haven't been this excited about Java since JDK 1.2. Especially Project Loom. Virtual threads will be a game changer. A return to original Java's rallying cry of programmer productivity. There's always been steady progress, sure. But it seems like Oracle is much less risk adverse. Or maybe the governance changed. Or maybe Sun, IBM, other had been holding back a lot of progress. I'd love to know the backstories. To better inform future efforts. Regardless, Java today is amazing and rapidly getting better.
- chaostheory 6y agoIsn't much of the excitement gone due to Oracle's license for its JDK?
- kasperni 6y agoWhy? There are at least 10 other vendors that provide a free version?
- _ink_ 6y agohttps://adoptopenjdk.net/ https://adoptopenjdk.net/ fixes most of the issues.
- pjmlp 6y agoNo because anyone that actually works with Java knows the difference between various Java implementations.
- nobleach 6y agoThat might not be completely fair. In our sister organization, we had a 20 year Java veteran switch his teams to Elixir because he was concerned about Oracle's licensing. Even though it was a misunderstanding, I wouldn't assume "anyone that actually works with Java knows the difference". Furthermore, it's a little bit of gatekeeping for those who may be entirely new to understand the difference between something like OpenJ9 vs AdoptOpenJdk vs Amazon Corretto.... you get the point.
- geerlingguy 6y ago/me nervously glances at all the production infrastructure I manage that's still on JDK 7 or 8. I've just recently been able to upgrade some things to JDK 11.
- watt 6y agoNot to worry: next LTS release will be Java 17, scheduled for September 2021 - next year.
- krzyk 6y agoAnd you know that LTS in case of Java is meaningless if you don't have a support bundle bought for real money? The only free of charge LTS is the latest java version, all versions n-1, n-2 are out of free support, you can only buy one.
- elric 6y agoJDK 11 is the current LTS version, so that's probably fine. With 2 releases per year, it's hard to follow the bleeding edge. Especially if you have to ship stuff to clients.
- Freak_NL 6y agoYeah, this seems to be par for the field. Java 11 is what you should be targetting now. We're in the middle of the 8 to 11 migration as well. I got the impression (but please correct me if I'm wrong) that only this year most major libraries got all the kinks worked out for Java 11. In particular, when using them together. Guice is one that only recently got the nasty (but relatively harmless) warning you get when using it with Java 11 under control. Java 17 is the next long term support release, so most of us working on longer lived code bases will probably skip all the releases in between. It doesn't seem worth the effort, because if the Java 9 and 10 experience is anything to go by, you will be hunting down issues with Maven plugins, transitive dependencies, and libraries holding back for now all day.
- 6y ago
- kentosi 6y agoI'm so happy that we finally have multiline text blocks in Java: String query = """ SELECT "EMP_ID", "LAST_NAME" FROM "EMPLOYEE_TB" WHERE "CITY" = 'INDIANAPOLIS' ORDER BY "EMP_ID", "LAST_NAME"; """; It's one more step closer to scala/kotlin/etc.
- jen20 6y agoDoes this result in a string with a hanging indent, or is the common prefix removed? (Sorry, being somewhat lazy, I could pull up the spec).
- curtis3389 6y agoThe common prefix is removed: > Incidental white space surrounding the content, introduced to match the indentation of Java source code, is removed.
- hashhar 6y agoI hate such kind of magic. Very convenient at first but can cause countless hours spent on debugging in some cases. I like how Scala does this via the indent marker and strip.
- e12e 6y agoI was going to answer gp "probably not" - but I would've been wrong. It looks to me like Java now has some of the most sophisticated in-line multi-line strings/here-documents that I'm aware of in any language. More details in: https://openjdk.java.net/jeps/378 https://openjdk.java.net/jeps/378 I'm not entirely sure "most sophisticated" is entirely a good thing - but the jep looks pretty thorough at least. Ed: how does Scala do it? Java uses the indents for the closing triple-quote to determine stripping/indent + cutting trailing spaces. Ie, if my reading is correct: a = """ OK. """ Is "OK.\n" (even if there are any spaces after the dot).
- FriendlyNormie 6y agoCool but how fucked are we at this point if we use Java for anything? Normal people will never read Oracle’s bullshit agreement and won’t think about it until the lawyers show up with a twelve inch spiked dildo and a bucket of astroglide.
- suyash 6y agoAlso check out Tribuo - Machine Learning library in Java announced today during the keynote : https://tribuo.org https://tribuo.org
- mabbo 6y agoI've got a few very specific use cases where I'm going to be so glad to have sealed classes[0]. Oddly not mentioned in the release notes, but they're like a final class, except you can say "These classes are allowed to be subclasses of this class". Why is that useful? Because now you can do a switch statement that matches on type: int getCenter(Shape shape) { return switch (shape) { case Circle c -> ... c.center() ... case Rectangle r -> ... r.length() ... case Square s -> ... s.side() ... }; } As long as Shape is sealed, the compiler can be confident that these are all the possible subclasses of Shape. [0]http://openjdk.java.net/jeps/360 http://openjdk.java.net/jeps/360
- benmller313 6y agoMaybe your example is just too simple, but why would you do that instead of overriding the getCenter method in each subclass?
- rcfox 6y agoI would assume the Shape family lives in a third-party library and getCenter lives in first-party code.
- estebank 6y agoYou're right that in the simplified example you have probably nicer alternatives, but having sealed clases where you know that others can't expand has its benefits to design some nice APIs, like state machines and type safe builders. The benefits of enums (as these are referred to in some languages) is that after the safe downcast you have access to the fields and methods of the specific type just by invoking them. Pattern matching also makes this construct even nicer to use (and I would argue that having one without the other is worse than not having either), but that doesn't seem to be included in the language yet, very probably for good reasons (I just don't follow Java development closely so I don't know about them).
- jdc 6y agoPattern matching is available as a preview feature: https://openjdk.java.net/jeps/375 https://openjdk.java.net/jeps/375
- ducktective 6y agoAnyone has any idea about the current state of JavaFX?
- suyash 6y agoIt's being developed in the open source now as it is out of JDK - https://openjfx.io https://openjfx.io
- deleted 6y ago[deleted]
- rubyist5eva 6y agoWhen is the next LTS release? I'm stuck on 11 until then.
- suyash 6y agoin 2 years with Java 17
- The_rationalist 6y agoYou being stuck is a poor technical decision
- sydd 6y agoWhy?
- karmakaze 6y agoFor some context--I had to look it up for myself Release GA Date Premier Support Until 11 (LTS) September 2018 September 2023 12 (non‑LTS) March 2019 September 2019 13 (non‑LTS) September 2019 March 2020 14 (non‑LTS) March 2020 September 2020 15 (non‑LTS) September 2020 March 2021 Ref https://www.oracle.com/java/technologies/java-se-support-roadmap.html https://www.oracle.com/java/technologies/java-se-support-roa...
- CydeWeys 6y agoIt's pretty hard to believe that I've been writing Java now for over two decades (not continuously mind you, but I'm not currently in a gap either) and with no signs of slowing down. I've been writing Java for longer than I've been driving, and way longer than drinking actual java. Geez. There's a certain fluency I have with this language that I don't have with any other language, not even Python/PHP/JavaScript/C#, all languages that I have 1k+ hours experience in.
- touisteur 6y agoRecently been going back to it a lot, I feel the same. The code flows right out my hands, I can see all the refactor paths and still learning new things with it (recently AOP, doing new optimized next-level introspection stuff, having fun with mappedbytebuffers... I know I'm late to the party but hey...)
- voodooranger 6y ago> Removal of Nashorn JavaScript Engine anybody know why a javascript engine was ever included in core java in the first place? seems... niche. and yet core java never included a simple web server (officially).
- hansjorg 6y agoIt's been replaced by GraalVM JavaScript which has Node.js built in. Performance is supposedly on par or better than the V8 version of Node.js. There's also support for ECMAScript modules directly from Java (without Node.js). GraalVM offers interop between JavaScript, Python, Ruby, R, C/C++ and of course Java and other JVM languages. I think GraalVM has the potential to make the JVM something of a universal platform. I guess that was the goal with Nashorn as well, but now it seems much closer to fruition.
- chromaton 6y agoI once used it for an embedded expression evaluation language in a Java application.
- vbezhenar 6y agocom.net.sun.httpserver looks like standard enough for practical purposes: https://stackoverflow.com/questions/58764710/is-package-com-sun-net-httpserver-standard https://stackoverflow.com/questions/58764710/is-package-com-...
- Macha 6y agoThis is the 3rd JS engine with its replacement. The idea I think is that it would be embedded in for scripting like uses, like many C++ games used Lua or Flash.
- sjwright 6y agoIt’s great for web development when I want the same code to run client side and server side.
- koreth1 6y agoI mostly don't work on web stuff, so maybe this is a dumb question, but can you give an example of what benefits that gives you? What code do you want to run in both places? In my limited experience writing web code, the client side concerns itself with rendering and user interaction, the server side concerns itself with efficiently supplying dynamic data to the client, and other than request payload definitions the two have no logic in common.
- leoh 6y agoIt feels like there's a new JDK every five minutes these days
- alphager 6y agoEvery 6 months, actually. In practical terms, unless you want to test out Java features (which can be removed with the next release), you only need to track the LTS-releases every 3 years and actively upgrade every 6 years to stay on a supported version.
- leoh 6y agoThe average cadence, over the lifetime of Java, is actually something like a new version every 2.5 years. They have really ramped up.
- carimura 6y agoUp until 10, releases were feature-driven, meaning, based around the delivery of something when it was done like Generics in 5, Lambdas in 8, modularity system in 9, etc. With 10 and on, Java is now a time-based release cadence, every 6 months in September and March, like clockwork. What's ready goes in, what's not waits for the next train.
- leoh 6y agoI'm not sure this is ideal for users, no? Each time something is deprecated (e.g. nashorn in JDK15), I have to go check the long term support schedule, etc. And I have to imagine it's much harder to maintain, creating the potential for patchwork fixes across various JDKs.
- chromedev 6y agoDoes this include JRE? I've noticed that the OpenJDK Docker Hub images and variants have a hard time releasing the latest JRE.
- hocuspocus 6y agoOracle doesn't offer a standalone JRE anymore. Several OpenJDK distributions do (Adopt, Azul, RedHat, Debian, ...) and I assume the version 15 builds will be available soon.
- ramon 6y agoI worked with Java in the past so glad NodeJS arrived and Golang.. productivity is the key.
- The_rationalist 6y agoYou should give a try to Kotlin then
- ramon 6y agoI was going to but then since Android also accepts Java I gave up on the Kotlin since I'm confortable with Java already, but I do like a lot golang recently I've also developed in C++ and I'm frankly learning a lot of golang and liking each day more and more.. it's fast to process and there's no hick-ups like in NodeJS, it's like the best of C++/Java with the best from NodeJS and no hick-ups at least for now.. I'm very impressed with the golang performance it's outstanding and what I got impressed too is that VSCode installs all the Golang extensions so it seems like I have all the typo verification on the fly without compiling remembering me a lot of Eclipse days with Java.. Good old compiling.. haha. We never get away from compiling.. I think Golang is under-marketed it deserves a lot of attention.
- x87678r 6y ago> Remove the Solaris and SPARC Ports https://openjdk.java.net/jeps/381 https://openjdk.java.net/jeps/381 Wow this is the end of an era.