8 ms·
Java 23: The New Features Are Officially Announced
- elric 3y agoWhile the Stream Gatherers will be very nice once they're out of preview, and the Vector API seems very useful, I'm most excited by (finally!) being able to execute some statements before calling super(). It was always possible to call super(Foo.bar()); , but it was never possible to call foo = Foo.bar(); super(foo); I'm digging this steady progress.
- lostmsu 3y agoC# needs to introduce super() for the same reason.
- gigatexal 3y agohttps://openjdk.org/jeps/469?ref=coderoasis.com https://openjdk.org/jeps/469?ref=coderoasis.com vector api looks nice what resources exist for say a half-way decent python dev like myself to get into java development?, I'm mostly a back end dev / data engineer from the article:"Overall, these changes will make it easier for beginning programmers to write programs without needing to understand the programming language features designed for larger or enterprise application development. "
- neonsunset 3y agoIf you care about portable SIMD and performance, you may be better served by Vector APIs in C# instead which has low-level but cross-platform abstractions stabilized since .NET 7 and an extensive guide to using those: https://github.com/dotnet/runtime/blob/69110bfdcf5590db1d32c2a4a39f12b50b09dbc4/docs/coding-guidelines/vectorization-guidelines.md https://github.com/dotnet/runtime/blob/69110bfdcf5590db1d32c... CoreLib and many new libraries are using it heavily to match performance of manually intrinsified C++ code.
- gigatexal 3y agovery cool I've come around to C# use of composition and the repository pattern since it's first introduction to me where I balked at it It's probably time to revisit C#
- neonsunset 3y agoGenerally speaking, JVM favours more high-level languages, while .NET is the low-level focused counterpart in many of its areas, so if that's what you are looking for, it might pleasantly surprise you :)
- Xeamek 3y agoWhen it comes to language itself, I don't see there being any good reason to pick java over c# these days. If you compare ecosystems then maybe, but it terms of language features I don't know why would any1 ever pick java from scratch in this day and age.
- darthrupert 3y agoOnly Windows developers should pick C# for anything, though. From my privileged point of view, that's a tiny minority. But not sure why anyone would choose Java over Kotlin now that Kotlin exists.
- neonsunset 3y agoThis stopped being the case eight (8) years ago. This what .NET is often used with today (in terms of dev, user and hosting stories): - Linux containers with ASP.NET Core - AvaloniaUI and Unity/Godot/Stride (all cross-platform) - Rider (on macOS in particular)
- forty 3y ago"Often" seems a strong word. I understand that it's possible, but I haven't seen many projects using C# or other CLR languages for containerized Linux app
- neonsunset 3y agoThat's the default deployment target for any new or migrated application. I'm saying often because it is not the only one.
- phito 3y agoYou're very out of date then :)
- darthrupert 3y agoWell, if these are valid arguments, I'd rather go with Swift for a more modern language.
- cess11 3y agoIntelliJ Community Edition. That'll give you tooling for generating boilerplate projects and handling some of the issues around build tools and project management that can be off-putting to a newcomer. In general Java development is much more brutal and violent than Python. The VM is very performant, it's like a huge ship engine, thousands of horsepowers. When a library is lacking in some way and you're in a hurry you just crack it open with reflection and edit the parts you want. The type system has quirks and sharp edges that'll cut you in ways you don't expect in the beginning, and it's a very strong type system, you need to work with it to make things manageable, no way around it. Maven is a daunting mess, but it's also a relatively robust mess. At first it'll feel slow to develop in, then you get the hang of code generation and figure out how to use the type system to get out of having to maintain the code and being able to make changes with confidence. At that point maintenance turns into routine tasks related to libraries and deploy environment. It's also multiplatform for real, not like C# where some things are but the goodies are MICROS~1 exclusive. A problem is that there is so much of it, both the language itself and libraries. Some common libraries have an API surface you could study for years without feeling you're running in circles. Start off with some well-defined, rather small projects. Connect to a database and crap out a PDF report. Install Wildfly and boot up a ping-API. Create the number guessing game as a Swing or JavaFX application. Stuff like that.
- phito 3y ago> It's also multiplatform for real, not like C# where some things are but the goodies are MICROS~1 exclusive. That's absolutely not true. Everything except the old GUI frameworks is multiplatform and even runs better on Linux.
- ptx 3y agoThe part about making it easier for beginning programmers probably refers to JEP 436 [0] which allows you to leave out some of the tedious boilerplate around the entrypoint for simple programs, just like in Python (well, there is still some extra boilerplate compared to Python). It has nothing to do with the vector API. The article confuses these two things because it's AI-generated word salad and plagiarized the phrase from somewhere else. (Also, why does the article include a "ref" parameter in its links? Does openjdk.org have some sort of affiliate program?) [0] https://openjdk.org/jeps/463 https://openjdk.org/jeps/463
- divan 3y agoJava doesn't have enough features?
- larschdk 3y agoArguably, it doesn't. New features can be necessary to stay competitive, such as the Vector API to utilize vector instructions.
- Sharlin 3y agoIt has fairly few features compared to most of its peers and has always been very conservative in adding more.
- brabel 3y agoAt which point does a language have enough features? Does any language have? It really depends on your preferences and what you're trying to do. I would say most languages do have enough features for most usages, to be honest. In the rare occasion the language does not, why not learn another language that fits your needs better? I know maybe 5 or 6 languages well enough to know their pros and cons and between them, I normally know exactly which language I would use depending on the objective, sometimes it may even be Java, but it could be any of the other 5 as they all have slightly different advantages.
- Mrdarknezz 3y agono
- fire_lake 3y agoIt has too many of the wrong features and not enough of the right features. This is the problem with bolting stuff onto old languages - a lack of cohesiveness.
- pjmlp 3y agoThere is always Go for those that don't like features.
- vbezhenar 3y ago
- joachimma 3y ago> These include statements before super(…), which would give developers greater freedom in expressing constructor behavior – meaning string templates. This would make it easy to express strings that include values computed at run time – meaning scoped values. This would enable sharing of immutable data within and across threads; and implicitly declared classes and instance main methods. I don't like the restriction on code before super. But I don't have a clue what they are referring to here. The code example doesn't use a template either. PositiveBigInteger(long value) { if (value <= 0) new IllegalArgumentException("non-positive value"); super(value); }
- DarkNova6 3y agoOnce you call super, you invoke the base constructor. This can cause issues beca not all fields in the sub class has been set yet. Setting the fields before calling super prevents this issue. Trivial method calls such as „toString“ can already cause issues and it’s worse once you want to guarantee certain value types properties.
- usrusr 3y agoThe intention for "nothing before super" is clear, but that rule never delivered on its promises. Because all those footguns are still in place, in field initializers as well as in function calls inside the super() argument list: class Sub extends Super { int field = footgunA(); Sub() { super(footgunB()); } } It's a zero merit headache factory and good intentions alone cannot change that.
- DarkNova6 3y agoAs far as I know `footGunA` can only be a static method and cannot leak `this`. This is perfectly fine as far as I'm concerned.
- usrusr 3y agoI should have checked instead of replying from memory: It's actually footgunB that is refused by the compiler. footgunA is accepted and will even call happily into an overridden implementation from a field initializer in the superclass. That way you can get a method to see a final field null on one call and non-null on the next.
- vaylian 3y agoStatements are now allowed before `super`: https://coderoasis.com/java-23-new-features/#statements-before-super https://coderoasis.com/java-23-new-features/#statements-befo... At long last!
- cies 3y agoIs there any estimate on the % of code running on the JVM that was Java code? Kotlin, Clojure, Scala, Groovy, Jython, JRuby to name a few. Then: this announcement is only about new features in Java-the-language right? Projects like Loom, Panama, Amber, Valhalla are then the JVM projects iirc.
- pjmlp 3y agoContrary to what vocal Kotlin advocates might believe, Kotlin only matters on Android, and that is thanks to Google pushing it no matter what. https://spectrum.ieee.org/the-top-programming-languages-2023 https://spectrum.ieee.org/the-top-programming-languages-2023 https://snyk.io/reports/jvm-ecosystem-report-2021/ https://snyk.io/reports/jvm-ecosystem-report-2021/ And even so, they had to conceed Android and Kotlin on their own, without the Java ecosystem aren't really much useful, thus ART is now updatable via Play Store, and currently supports OpenJDK 17 LTS on Android 12 and later devices. As for your question regarding numbers, mostly Java 74.6%, C++ 13.7%, on the OpenJDK, other JVM implementations differ, e.g. GraalVM is mostly Java 91.8%, C 3.6%. https://github.com/openjdk/jdk https://github.com/openjdk/jdk https://github.com/oracle/graal https://github.com/oracle/graal Two examples from many others, https://en.wikipedia.org/wiki/List_of_Java_virtual_machines https://en.wikipedia.org/wiki/List_of_Java_virtual_machines
- pzo 3y agoAny reason Kotlin is not being adopted outside android? I haven't used Java for like a decade - is it that Java improved well enough to kotlin not being competitive anymore? E.g. Spring Boot seems to have kotlin support. Kotlin 2.0 compiler seems also around the corner, same with jetbrains-compose.
- matsemann 3y agoWhen I was a consultant, what I saw was that almost all new code in java codebases at multiple projects/clients was entirely Kotlin. No idea what the person you're replying to is on about.
- SpaghettiCthulu 3y agoI'm very disappointed by the non-announcement that the String Templates preview feature is being completely removed.
- microflash 3y agoIt is removed in Java 23 but hopefully will be back in Java 24 once they finalize the ergonomics around template processing.
- jpgvm 3y agoIs it? Last I checked (https://openjdk.org/jeps/465 https://openjdk.org/jeps/465) it was being proposed for finalisation. Where did you read it's being removed instead?
- vbezhenar 3y agoThey completely rehauling this feature. It won't be finalized in the current state.
- jpgvm 3y agoOk interesting, where I can I read about why they decided to back it out after 2nd preview?
- kaba0 3y agoThey found a better/simpler abstraction. Here is the mailing list (I link to the reddit thread, because there are some useful comments): https://www.reddit.com/r/java/comments/1ba0brh/update_on_string_templates_jep_459/ https://www.reddit.com/r/java/comments/1ba0brh/update_on_str...
- jpgvm 3y agoThanks!
- 3y ago
- sitta 3y agoThe article makes it sound like the feature set has been finalized, but is that really the case? I'm struggling to find evidence for this, and the official page does not seem to indicate this at all: https://openjdk.org/projects/jdk/23/ https://openjdk.org/projects/jdk/23/
- mkurz 3y agoNo, the feature set is not finalized. This is just a random blog post, nothing more. Like who says "New Features Are Officially Announced"? Which source? They make it look like Java 23 is done, but it's not. If you want see what's coming in Java 23 you have to check https://openjdk.org/projects/jdk/23/ https://openjdk.org/projects/jdk/23/ - the only source of truth. If you look at the Schedule of that page you will see at least before Rampdown Phase One there still is time to add new JEPs. And there will more JEPs be added for sure, that's how it was done in the past.
- decafninja 3y agoWhat is the best way to get up to speed with modern Java? My background is having taught myself a very long time ago with Ivor Horton’s books but zero professional experience with the language.
- pjmlp 3y agoSomething like this, https://4comprehension.com/busy-developers-guide-to-java-9-10-11-12-13-and-above/ https://4comprehension.com/busy-developers-guide-to-java-9-1... https://ondro.inginea.eu/index.php/new-features-in-java-versions-since-java-8/ https://ondro.inginea.eu/index.php/new-features-in-java-vers... https://advancedweb.hu/a-categorized-list-of-all-java-and-jvm-features-since-jdk-8-to-21/ https://advancedweb.hu/a-categorized-list-of-all-java-and-jv...
- 62951413 3y agoCore Java by Cay Horstmann (https://horstmann.com/corejava/ https://horstmann.com/corejava/) is a well-structured and concise review of major features. Historically, the most interesting chapters were scattered across both volumes. So completely skipping the "Fundamentals" volume was ill-advised while the "Advanced Features" volume had some boring and mostly unnecessary chapters.
- roenxi 3y agoIt is weird to me that as of the 2010s every major programming language (Python, Javascript, Java, C# and C/C++ has settled in to a regular release cadence of ... I think C++ is the conservative representative at one new version released per 3 years. It'd be fascinating to know if this is helping or hindering programmer productivity. None of these new capabilities seem to be step changes (all the oomph for programmer productivity that I've seen have been IDE tooling, LLMs and GPUs). I'd be impressed if they even managed to be incremental changes - in this case a vector API sounds nice enough gor example but the projects that need this must be on the margins. These changes come with costs - tutorials obsoleted, version fragmentation introduced, huge new surface areas for bugs and security problems. Most of these languages became popular without fast release cadences (or in spite of them, Python 3 looking at you). It is quite amazing that none of them have decided to leave well enough alone. Is it the classic of programmers not being able to defend that position against people with ants in their pants, or is there a genuine community will to keep revising this stuff? Surely there has to be some popular language where the custodian would think it is good enough to set in stone bar hardware-forced updates.
- ativzzz 3y ago> where the custodian would think it is good enough to set in stone While it's nice to be able to have a "complete" language, a language that receives no updates or changes is a dead language. When people use the language, are interested in making it "better" (in their mind at least), they are building community, holding discussions and overall generating interest and keeping the language alive and useful. If you don't allow people to make any changes, then these people will lose interest and abandon the project, and slowly over time it will die. There are some exceptions, like C that are so embedded in everything that it doesn't matter (it still gets updates sometimes), but languages like python or java or ruby where there is no clear "best" have to be competing with one another for people to choose that language
- roenxi 3y agoHas the buzz for Java ever come from Hot New Features? As I recall that buzz was 80% marketing budget from Sun then Oracle, the stability of the platform and the ready availability of programmers. If anyone ever picked Java for its features, their judgement should be questioned. The thinking might well withstand that questioning, but it isn't an obvious choice on the basis of features. I mean, Java itself is an obvious choice - but not because of its features. You can show me languages with much better feature-sets and I'll nod, agree then recommend Java for production use. The features just aren't the selling point.
- mmaniac 3y agoUntil recently Java always seemed conservative. That's not "fun" or very interesting for a programmer, but it does offer some certainty. Java 8 bucked the trend with some major but highly useful additions, and ever since it seems like it has been going down the C++ path of accreting everything under the sun.
- thomascgalvin 3y agoJava has always been conservative about maintaining backwards compatibility and introducing new keywords, but the java.* and javax.* packages have been growing larger and larger since day one. I do think Go and Kotlin have kicked the Java community into high gear, though. A lot of the recent (or upcoming) features are direct answers to features found in those languages.
- mmaniac 3y agoA bigger standard library is one thing, but new classes and methods are easier to get accustomed to than additions to the core language spec with features like type inference or pattern matching. I think Kotlin especially is responsible for this change. All that effort almost feels pointless now that Java has kinda stolen its USP.
- stickfigure 3y ago> accreting everything under the sun Maybe you're thinking about Scala? What I see is that Java is conservatively incorporating the established, proven good parts of other languages. The changes have been great - if perhaps a bit late, but that's by design.
- Tainnor 3y agoMaybe it's worth noting that a very similar looking article from the same website was recently flagged and is dead because it appeared to be AI generated nonsense: https://news.ycombinator.com/item?id=39872271 https://news.ycombinator.com/item?id=39872271 I haven't checked if this one is correct.
- omajid 3y agoThis one is partially nonsense too. Here's a snippet that starts talking about super() and then abruptly switches to string templates. > These include statements before super(…), which would give developers greater freedom in expressing constructor behavior – meaning string templates. This would make it easy to express strings that include values computed at run time – meaning scoped values. This would enable sharing of immutable data within and across threads; and implicitly declared classes and instance main methods.
- cryptonector 3y agoAll of that stuff about strings is utter nonsense. And it doesn't link the JEP for statements before super (https://openjdk.org/jeps/447 https://openjdk.org/jeps/447).
- ptx 3y agoThe conclusion of the article is clearly nonsense. How would the features presented, which include an API for generating JVM bytecode, "make it easier for beginning programmers to write programs without needing to understand the programming language features designed for larger or enterprise application development"? It might be plagiarized from an Infoworld article [0] which also talks about these features and uses a similar phrase – "make it easier for beginning programmers to write programs without needing to understand language features designed for large programs" – but there it specifically refers to "implicitly declared classes and instance main methods", i.e. JEP 463 [1]. [0] https://www.infoworld.com/article/3714933/jdk-23-the-new-features-in-java-23.html https://www.infoworld.com/article/3714933/jdk-23-the-new-fea... [1] https://openjdk.org/jeps/463 https://openjdk.org/jeps/463