12 ms·
A compact overview of JDK 21’s “frozen” feature list
- mooreds 3y agoI think the site is currently experiencing the hug of death, but doesn't have an archive.is link :( .
- idlewords 3y agoIt amazes me how many people still can't configure a webserver in 2023 to not fall down under a few queries/second load serving up a textfile.
- hn_go_brrrrr 3y agoIs the HN hug of death truly only single digit QPS?
- mooreds 3y agoI've had posts on the front page of HN (#1 or #2). That generated about 20k visits. Assuming: * 1 page/visit, which is the modal value based on my analytics * the period where it is on the front page is 6 hours (I don't know this, but I could if I could be bothered to go back and look; I don't have granularity down to the minute, though) That is 20000 requests/(66060), which rounds to 1 request/second. Of course, there are all the other assets (JS, images, etc) that you need to account for as well. And it might spike to higher.
- iudqnolq 3y agoI think that's completely useless? The whole point of qps is that it gives insight into spikes.
- fweimer 3y agoIf the entire page is 50 KB, it think within five minutes, it can be served 20,000 times over typical commercial broadband (assuming 30 Mbps net capacity)? 20,000 requests can't really form a huge spike. Most personal-ish sites won't be hosted on commercial broadband, so they should have more bandwidth than that.
- MBCook 3y agoThat assumes the hits are evenly distributed. I think it’s more likely that there’s a big flood at first and then it drops off towards a low number.
- idlewords 3y agoThat's been my experience. But even the tiniest pizzabox server should have no trouble at 40+ qps.
- sapiogram 3y agoGenuine question, what is it causes websites to keel over in a mild breeze like that? Surely not raw CPU, memory, or network bandwidth on the machine? Is it just some arbitrary limit imposed on whatever VM they are running?
- re-thc 3y ago> Surely not raw CPU, memory, or network bandwidth on the machine? Why not? It gets worse and worse as we aim for more abstractions and layers of tooling. Where the latest hype is server rendering React in NodeJs for what instead code by a static site...
- xyst 3y agoLess than 30 minutes after a post on HN and it’s not accessible. Lol
- mooreds 3y agoI had an article on the front page of HN, it melted my server and I ended up using a CDN. Useful lesson, but until you have massive traffic happen once, it's overengineering :) .
- ZephyrBlu 3y agoSetting up a CDN is free, quick and easy. It should be the default if you're deploying a static site. Definitely not overengineering.
- faangsticle 3y agoIf you consider sharing the browsing habits of all of your visitors with Cloudflare to be free, then yes.
- ZephyrBlu 3y agoUse Cloudflare? I would never! My blog uses a custom CDN I wrote in Assembly for maximum performance. I also wrote a custom browser (Guess what language) so my visitors browsing habits weren't shared with Google via Chrome. I will go to the ends of the Earth to protect my users' browsing habits.
- faangsticle 3y ago[flagged]
- mooreds 3y agoI didn't find it to be free, quick or easy, but then again, I used Cloudfront and had Wordpress on the backend. This was also a few years ago; wrote about it briefly here: https://www.mooreds.com/wordpress/archives/2565 https://www.mooreds.com/wordpress/archives/2565
- neonate 3y agohttp://web.archive.org/web/20230611150725/https://vived.io/a-compact-overview-of-jdk-21s-frozen-feature-list-jvm-weekly-vol-138/ http://web.archive.org/web/20230611150725/https://vived.io/a...
- gavinray 3y agoI wrote about how Record Patterns along with Pattern Matching for Switch can be used to write things like Tree-Rewrite rules in AST analyzers/program optimizers efficiently if anyone is curious: This is how Spark's optimizer Catalyst works in Scala https://gavinray97.github.io/blog/what-good-are-record-patterns https://gavinray97.github.io/blog/what-good-are-record-patte... Kind of wild to believe this is valid modern Java: return switch (expr) { // x + 0 = x case Add(Var(var name), Const(var value)) when value == 0 -> new Var(name); These two are my favorite new JDK features by miles, along with Sealed Types.
- speed_spread 3y agoIt's just too bad they could not come up with an extended enum-as-tagged-union syntax. Using sealed classes for that pattern works but is still messy to write. It feels like writing enums with classes back in JDK 1.4 days.
- gavinray 3y agoI think "sealed interface" with implementations used by "records" gets you pretty close though right? This is usually what I do, something like: sealed interface Tree { record Leaf(int value) implements Tree {} record Node(Tree left, Tree right) implements Tree {} } var tree = new Tree.Node(new Tree.Leaf(1), new Tree.Leaf(2));
- speed_spread 3y agoThis is what I was talking about. With pattern matching I now expect this exact pattern will be 98% of usage of `sealed` anything. It would be nice to have some sugar like tagged-union Tree { Leaf(int value), Node(Tree left, Tree right) } I used `tagged-union` because for backward compat I think using `enum` would not be possible but really it could be anything.
- kaba0 3y agoWhile I agree that some syntax sugar would be welcome here (AFAIK the best you can currently do is sealed interface Tree permits Tree.Leaf, Tree.Node { record Leaf(int value) extends Tree {} record Node(..) extends Tree {} } ), it is not too terrible. Also note that rust really mixed up the nomenclature here with their enums, these were known in every language previously simply as ADTs. It makes sense for these to not have identity, while java enums are always a single instance.
- syngrog66 3y agoI refuse to believe Java has gone through 20 major revisions since 1.0 I remember when 1.5 came out and Sun's marketing folks insisted it be called Java 5. I think thats when they jumped the shark, and haven't corrected course back since, versioning-wise And I wonder if someone keeps track of what the proper traditional Java major version should be now. I'd guess its on 2.x or 3.x at best
- too_damn_fast 3y agoWell, they were going with 1.5, 1.8 because the 5 and 8 are minor version numbers as it's all backwards compatible.
- emodendroket 3y agoIs there some kind of objective standard for version numbers I’m not aware of? Maybe you could call only LTS versions “major versions” if you wanted.
- erik_seaberg 3y agoThere’s https://semver.org/ https://semver.org/, which Java unfortunately has not chosen to follow. As joaonmatos pointed out, 8->9 was the most painful major version change, and I think there have been a couple others when deprecated features were (or will be) fully removed.
- emodendroket 3y agoProjects that follow semver in theory often don't actually follow it so why would we expect everyone else to?
- erik_seaberg 3y agoI think the attempt communicates a lot of useful info and succeeds pretty often. I agree they can’t guarantee it, as with any bugs.
- 3y ago
- arein3 3y agoIs it too much to ask for null safety in the type system?
- gavinray 3y agoNope not at all, here you go: https://openjdk.org/jeps/401 https://openjdk.org/jeps/401 It's part of Valhalla, as a pre-requirement for heap-flattening. Ctrl+F for "Null-restricted type". The strawman proposal syntax is "Foo!". When inlined, a null-restricted class type should have a heap storage footprint and execution time (when fully optimized) comparable to the primitive types. For example, a Point!, given the class declaration above, can be expected to directly occupy 128 bits in fields and array components, and to avoid any allocation in stack computations. A field access simply references the first or second 64 bits. There are no additional pointers. For a summary of current status and what it means for you as a developer, I recommend the linked email here and the author's comments in the thread: https://www.reddit.com/r/java/comments/13xtog3/valhallas_latest_plans_very_highlevel_accessible/ https://www.reddit.com/r/java/comments/13xtog3/valhallas_lat...
- arein3 3y agoThanks, hopefully it will be live sooner rather than later.
- ArturSkowronski 3y agoIn recent publication Brian Goetz explains why it is so complex to introduce one: https://mail.openjdk.org/pipermail/valhalla-spec-experts/2023-May/002276.html https://mail.openjdk.org/pipermail/valhalla-spec-experts/202... Great read. TLDR: It is hard to decide what the defaults should looks like, so they plan to add special markers (! and ?) to allow programmers to pass that detail to objects with "undefined nullability" (without ! or ?).
- gcau 3y agoAs a typescript developer who had to make something in java, it's so bizarre and alien to me that anything anywhere might be null, and I have to manually check if things are null everywhere, and then play a guessing game when I get a NPE. It feels like the most unsafe, unsound thing ever.
- dexwiz 3y agoI’m impressed. One of the big hurdles of extendable types is figuring out which subtype a parameter is. Overloaded methods are a blunt tool that involves lots of indirection. Generics force you to structure classes in a specific way. Pattern matching is the cleanish solution to the problem of “what type so I have here and what do I do with it?”
- soulbadguy 3y agoI am sure they are very good reasons for it, but even after reading part of the latest valhala design document i still don't quite understand by nullability and/or identity are used as key differential between value types and "regular" class type. It seems to make the design and integration of value object very convoluted and is basically representational flatness as a mere consequences instead of being the central defining factor of a value object.
- kaba0 3y ago> basically representational flatness as a mere consequences And that’s exactly what they are going for, AFAIK. You as a programmer should first and foremost care about the semantics that you want to express in your programs. In many cases it means that an object you use has and need an identity. But you may find so that it doesn’t make sense in a given case, like a date, or a coordinate — so you can express that it doesn’t have identity, allowing for more freedom on the compilers part. Finally, you may even say that an implicitly zeroed object makes sense as a default for your class, and when this particular case happens and your object can’t be null, the compiler can even completely inline/flatten your data. But the performance improvements are generally not the goal themselves, they are neat advantages you may get by restricting your semantics.
- soulbadguy 3y ago> You as a programmer should first and foremost care about the semantics that you want to express in your programs. I think what is semantics vs implementation details depends on the task at hands. From my understanding, the need for value types mainly originate from the need for precise control of memory layout, In which case the representation is part of the important semantic. C#/.Net seems to have a simpler approach by just providing representation flatness as a tool and let the developer chose what they want to do/focus on. > In many cases it means that an object you use has and need an identity. But you may find so that it doesn’t make sense in a given case, like a date, or a coordinate — so you can express that it doesn’t have identity, allowing for more freedom on the compilers part. If this is confusing it to me, the need to identity seems to be a property of a specific object instance, not really a property of a class/type. > But the performance improvements are generally not the goal themselves I am not sure how true this is, the design document itself reference numeral code performance as one of motivating factor. > when this particular case happens and your object can’t be null, the compiler can even completely inline/flatten your data As someone who have "worked" on quite of bit of runtime/compilers, "compiler can" always turns out to be "compiler doesn't". This idea of a compiler to auto-magically deciding and optimizing data layout sound great in theory, but in practice is very very hard to achieve in most meaningful ways.
- hamandcheese 3y agoI'm impressed with how Java is shaping up. With records, pattern matching, destructuring, and virtual threads all arrived or arriving, what advantages do Kotlin and Scala bring?
- jdm2212 3y agoThey're really great for making sure Java devs will absolutely never contribute to your project. (I say this as a Java dev who occasionally gets tempted to try to help out in repos that are Kotlin/Scala, and gives up very quickly.)
- the_overseer 3y agoIs this supposed to be a good thing or a bad thing?
- hamandcheese 3y agoDouble edged sword. Spring devs: stay far, far away from me.
- jdm2212 3y agoMostly a bad thing, at companies with lots and lots of Java devs.
- soulbadguy 3y agoIsn't that true for any other language as well ?
- jdm2212 3y agoI'm happy to take a crack at Go and C++, but coming from Java it is totally impossible to decipher wtf is going on in Scala. Kotlin is better, but still pretty awful. Also, devs who use Go and C++ usually have a good reason (embedded systems and such), but Kotlin and Scala use seems to be motivated mostly by vaguely hipster-y annoyance with Java 8. And, like, sure, if you are annoyed by Java 8 and then use a language designed to have nothing in common with Java 8 except that it can import Java libraries and run in the JVM... well, it's gonna be a pain in the butt for your colleagues who do Java all day. And some of them aren't going to make the effort to work with it.
- jayd16 3y agoI'm curious to see how structured concurrency feels in production. I'm still leaning towards C#'s async and TPL syntax. Manual context, fork and unwrap syntax might feel cumbersome. I enjoy the await sugar and implicit context handling but the explicit scopes solves the bugs you see in C# where the default thread pool is abused.
- pjmlp 3y agoDavid Fowler has tweeter threads about researching how Java and Go do it, including an experimental runtime. By the way, .NET already has structured concurrency via Dataflow.
- vips7L 3y agoGreen Threads Experiment if anyone is interested in what they've done in .NET: https://github.com/dotnet/runtimelab/issues/2057 https://github.com/dotnet/runtimelab/issues/2057 Personally Asyc/Await is the only thing keeping me from the C# ecosystem.
- jayd16 3y agoA bit ironic that the last post is a UI thread question. I would welcome green threads or a virtual threading system, but considering the UI work that C# handles, its no wonder async/await was implemented. If Java virtual threads are a success, I expect C# to follow suit.
- vips7L 3y agoIt seems appropriate that C# would include both models. The language design seems to allow you to choose what tool is best for your application.
- pjmlp 3y agoIt won't, this was discussed at BUILD 2023, and they have no plans to do so as they would need to duplicate the API surface of many low level capabilities. If I am not mistaken it was on this session, "ASP.NET Core and Blazor futures, Q&A" https://build.microsoft.com/en-US/sessions/4cfe374e-a9a0-4a82-a9b6-890bd90df931?source=/favorites https://build.microsoft.com/en-US/sessions/4cfe374e-a9a0-4a8...
- ArturSkowronski 3y agoHey, author there - HackerNews Effect killed our AWS hosted WordPress ;( You can find mirror on Substack: https://vived.substack.com/p/the-compact-overview-of-jdk-21s-frozen https://vived.substack.com/p/the-compact-overview-of-jdk-21s... EDIT: We did the redirection to the Substack mirror.
- gabereiser 3y agoYour pop-over to join the newsletter and continue reading won’t allow someone to continue reading without signing up for your newsletter. There’s no way to close the pop-over modal. This is user hostile behavior. When scrolling, it reappears over content. Very anti-user behavior. This is equivalent to forced purchase required to use the restroom at a venue. Don’t be like that. Compassion is good for business.
- ArturSkowronski 3y agoIt is default behaviour of Substack - to be honest I am not sure if it is even possible to change. However, you don't need to subscribe - you can close the popup and carry on!
- gabereiser 3y agoI know, not your fault, I’m just throwing a hail-mary in case they see it. It’s sooo frustrating. Once you leave and come back it doesn’t show. So obviously they are storing state on it and pushing it in your face when the MarTech gods deem it appropriate. Good write up though and appreciate the KotH meme.
- capableweb 3y ago> There’s no way to close the pop-over modal There is, you click outside the modal. Or hit Escape key.
- gabereiser 3y agoOn mobile viewing on safari, there was no such feature.
- nikeee 3y agoSeeing Java getting these features is a breath of fresh air. I wonder how this will impact Kotlin. Being compatible with Java was one of the goals for Kotlin. We soon have a lot of features in the JVM mother language that are solved different in Kotlin. For example: - Data Classes vs Java's Records - Nullability - String Templates Not diverging from the core language is what made TypeScript successful on a long term. This won't work for Kotlin (and was not a goal). It will be interesting to see whether the languages will diverge even more - maybe to an extend where they will become incompatible - or the interop will converge somehow. Diverging languages will certainly make the interop harder.
- LelouBil 3y agoKotlin still has a lot for itself, with the scope functions, the delegation with "by", the syntax that make it very easy and lightweight to create a DSL (infix functions are great for asserts). I think it's a very expressive and elegant language if you use its syntax properly. Maybe some of kotlin's "workarounds" will be converted into the JVM equivalents in the backend.
- unscaled 3y agoThe relationship between Kotlin and Java is not the same as TypeScript and JavaScript. TypeScript is intentionally a syntactical superset of JavaScript. It only adds type annotations and nothing else. This allows TypeScript to be easily compatible with JavaScript, with very little risk of future breaks in compatibility. Kotlin cannot choose the same route as TypeScript, since Java is already statically typed (even if that typing is not always very strong). There is no point in adding type annotations to it. Most of the improvement that Kotlin originally sought (and still seeks) to have on Java are in syntax and semantics. This means Kotlin has to modify the syntax and cannot just be a simple transpiler that naturally incorporates new Java language features. The interop strategy that Kotlin has chosen instead is: 1. Keep track on what Java is doing. 2. Add compatibility to Java language features when they are released. 3. Avoid introducing incompatible features too quickly when Java is developing the same thing. 4. If the Java development direction is settled but the feature is not released yet, introduce features that have a clear upgrade path for compilation and interop on new Java releases. Kotlin is already compatible with Java records (just add the @JvmRecord annotation to a data class). This annotation forces the Kotlin data class to be immutable and the compiler will generate a java record for you if you target the JVM. Nullability marking is not something that is currently being worked on for Java. Some publications have misleadingly modified the title for "JEP 401: Flattened Heap Layouts for Value Objects (Preview)" [1] to "JEP 401: Null-restricted types", because this very early proposal mentions possible interactions with null-restricted types - but the null-restricted proposal doesn't even exist yet. It's quite hard to predict how Kotlin would be compatible with a feature that may or may not come around 2030. String templates are still a preview feature in Java 21, so don't expect to see them in production before Java 25 in September 2025. String Templates, like string interpolation, is essentially syntactic sugar, but it provide a better story for type-safety and flexibility than classic string interpolation. Kotlin already solves the simple interpolation cases with its string interpolation, but I agree it leaves some things to be desired (multi-line handling is especially painful[2]). The type-safety/flexibility story is generally handled in Kotlin with type-safe builders[3], and it's often a better solution in my opinion, but there many cases where a string template would be more readable. The main reason Kotlin might need to support string templates, is that all this syntactic sugar has an interface: the StringTemplate interface. Java libraries may rely on it on the far future[3], and then Kotlin will need to maintain compatibility somehow. JetBrains are not ignoring this issue of course. You will find multiple tickets on their tracker talking about custom string interpolation, that even predate the String Templates JEP[5], but it's currently a wait-and-see-approach. I think the most important set of features for Kotlin to look at is Project Valhalla[6]. It's an even bigger revolution than project Loom. Kotlin is already preparing for this, with value classes[7]. I believe the main reason that value class usage in Kotlin is so highly restricted in Kotlin right now, is that they are waiting for Project Valhalla, and do not want to give up interop later. You can also think of other past examples when Kotlin did introduced a future earlier than Java, and then gradually made it interoperable. The best example is closures. Kotlin supported closures since its early beta versions (before Java 8 was released), and for a long time supported generating Java 6 bytecode. Since Java 8 closures relied on a new JVM bytecode instruction (InvokeDynamic), Kotlin used a different mechanism to implement closures. When Java 8 was released, they could easily maintain API compatibility with Java, since they are always invoked through an interface. Kotlin eventually added support for generating lambdas in the same style as Java, but they only made this default in Kotlin 1.9[8], to maintain maximum compatibility. This didn't affect interop (which was already resolved since Java 8 was released), it only had impact on bytecode size and perhaps a small performance impact in some cases. I think this list show that Kotlin is currently handling future interop quite well. [1] https://openjdk.org/jeps/401 https://openjdk.org/jeps/401 [2] https://youtrack.jetbrains.com/issue/KT-46365/Multiline-string-trimming-is-unintuitive-and-leads-to-confusing-bugs https://youtrack.jetbrains.com/issue/KT-46365/Multiline-stri... [3] https://kotlinlang.org/docs/type-safe-builders.html https://kotlinlang.org/docs/type-safe-builders.html [4] Java is a conservative language and most Java deployments are many versions behind the latest LTS. Until last year (https://newrelic.com/resources/report/2022-state-of-java-ecosystem https://newrelic.com/resources/report/2022-state-of-java-eco...), most of the Java systems in production were running Java 8, and only recently Java 11 started becoming the dominant version, with Java 8 strongly trailing behind. Java 21 is coming out this year, but Java 17 is barely deployed anywhere. For this reason, you'll find most libraries target still target Java 8 or Java 11, and avoid Java 17 features like record. Since String Templates will be out only in 2025, I don't expect to see libraries requiring them in production before 2030. [5] https://youtrack.jetbrains.com/issue/KT-16366 https://youtrack.jetbrains.com/issue/KT-16366 [6] https://openjdk.org/projects/valhalla/ https://openjdk.org/projects/valhalla/ [7] https://youtrack.jetbrains.com/issue/KT-42434/Release-inline-classes-as-Stable-secure-Valhalla-compatibility https://youtrack.jetbrains.com/issue/KT-42434/Release-inline... [8] https://youtrack.jetbrains.com/issue/KT-45375 https://youtrack.jetbrains.com/issue/KT-45375
- akkad33 3y agoJava sucks as a language and no amount of lipstick on a pig will make it look good
- akkad33 3y agoThis comment was childish but I'm struggling with Java at work. People who fight over whether to implement visitors, adapters, methods or services for the same thing