No video

Java Language Futures - Spring 2024 Edition

  Рет қаралды 21,938

Java

Java

Күн бұрын

The Java Programming Language is evolving fast! Watch this video for a whirlwind tour of recent changes as well as a peek into the future. Discover the features you’ll be using when coding Java code next year and beyond!
Check inside.java/ta... for more information on the Java Programming language.
Make sure to also visit dev.java, the destination for all Java developers.
Video recorded during Java Day™ London
Tags #Java #JDK #OpenJDK #InsideJava #programming

Пікірлер: 76
@keineangabe8993
@keineangabe8993 Ай бұрын
The pattern showed for AsyncResult looks exactly like a Rust enum, a shortcut to get that kind of thing would be great.
@lepingouindefeu
@lepingouindefeu Ай бұрын
Yeah but I guess Java never was about syntax sugar. 😢 Maybe the syntax sugar was the friends we made along the way?
@personalaccount1515
@personalaccount1515 9 күн бұрын
Let me be clear, I am REALLY HAPPY that my loved Java could copycat the good things of other languages.
@peacemakerle
@peacemakerle Ай бұрын
Still crying for the Elvis operator. For business and database logic, this is the most missing Java feature. We don't want to wrap everything in Optional and lambdas.
@MrHamsterbacke756
@MrHamsterbacke756 Ай бұрын
Without null safety the elvis operator is just Syntax sugar wihthout much use.
@vinterskugge907
@vinterskugge907 Ай бұрын
They are instead going for nullness markers, so String! will be a String that cannot have null assigned to it. This is a better solution IMO. With the Elvis operator, you have to constantly remember to use it.
@lepingouindefeu
@lepingouindefeu Ай бұрын
I honestly don't mind the Optional pattern. In fact I like the way the code looks with the functional-like API it uses. I just wish it actually did its job and couldn't be null itself.
@peacemakerle
@peacemakerle Ай бұрын
@@vinterskugge907 Well, this are two different things. We need both. The Elvis operator is for writing shorter code, especially when navigating through nested data structures.
@vinterskugge907
@vinterskugge907 Ай бұрын
@@peacemakerle Different but related: With nullness markers, the Elvis operator will be less useful, as many elements in those data structures will be marked non-null. So much less useful that it would not make sense to prioritize it. And I don't think they will (or should).
@greatso9018
@greatso9018 Ай бұрын
It took me an embarrassingly long amount of time to userstand that this was not about new features applied to the spring framework..... I really like the new data oriented philosophy. The way to represent future's state with sealed class makes me think of rust's enums ! I wonder if the rest of the APIs will shift this way. I'm thinking about optionnals, and maybe even an error type ?? (Since we still can't handle exceptions in a functionnal way without creating some custom "Try" type. It really is a pain point I experienced
@6konrad6
@6konrad6 Ай бұрын
AsyncReturn looks great! good to know about that
@shadeblackwolf1508
@shadeblackwolf1508 Ай бұрын
I think the design of AsyncReturn is a great alternative for some situations, but not a great showcase of the problem this solves. after all, this solution conflates happy and error paths in a way that is very much problematic for pure java code... however, when you call a rest api from your code, this could be really powerful, cause you may want to for example examine returns to see what exactly went wrong, and if it's worth retrying
@greatso9018
@greatso9018 Ай бұрын
​@@shadeblackwolf1508I don't get why mixing the happy path and the error path would be a problem. Error as value is coming back strong in modern languages
@alexgorodecky1661
@alexgorodecky1661 Ай бұрын
No. Stack traces are gone. Have a luck to debug in production
@n_lisper
@n_lisper Ай бұрын
@@alexgorodecky1661why would stack traces be gone? The exceptions should be stored in the records for you to do whatever you want with them
@lepingouindefeu
@lepingouindefeu Ай бұрын
​@@alexgorodecky1661 You should still be using exceptions for cases where the application should not recover from. If the error is actually expected and you can recover from it, it makes sense to return it as a value, and you don't really need a stack trace any more than you need it for the happy path.
@rtorello75
@rtorello75 Ай бұрын
The "with" thing seems like a great addition to records. I live in Java 11 World right now, but will be moving up to JDK-21, hopefully, soon. I simply do not understand the massive amount of fan-fare about records, although the most interesting concept about that is that all records are "Read-Only" which seems like a reasonable addition. I know that while something (anything, really) is under development it will seem a lot more important to the programmers until they are finally finished with it.
@valcron-1000
@valcron-1000 Ай бұрын
37:50. I fundamentally disagree. You could have made the exceptions on the original signature checked and get the same benefits of the compiler telling you if you miss any case plus: - Avoids the additional boxing due to the `AsyncResult` type, plus better performance in the happy path - You get stack traces in the cases of failure (`Failure`, `Timeout` and `Interrupted`) - You can quickly propagate to the caller unlike `AsyncResult` (no `?` operator or similar) - Compositions comes for free. If a function `f` throws `X` and function `g` throws `Y`, then a function that calls both functions can throw `X & Y` due to the fact that `throws` supports a union of exceptions. With a sealed interface you don't get that, meaning that the dev now needs to create a wrapper for the result types (see `anyhow` in Rust for example) I don't think we're gaining anything valuable with this. I would much rather have proper support for Nullable types or a better `catch` clause for multiple exceptions types (syntax sugar on top of multiple `catch` clauses)
@Rajput-vv9vs
@Rajput-vv9vs Ай бұрын
सब।? 😊
@CYXXYC
@CYXXYC Ай бұрын
you are looking for JEP draft 8323658
@personalaccount1515
@personalaccount1515 9 күн бұрын
The "Better Return Type" looks like Result Pattern with steroids!, i like it
@robertomalatesta9143
@robertomalatesta9143 Ай бұрын
The unstoppable train marches on. 🍾👍
@adilsheikh9916
@adilsheikh9916 7 күн бұрын
I am still not sure why do we need JEP445 when Jshell is there...
@avalagum7957
@avalagum7957 Ай бұрын
2:04 "we've been delivering quite a lot". No, that's not a lot. Scala delivered all of those features in one shot. 4:08 Productivity-oriented language features: Scala can pattern-match on lists. I think that's very productive. Java doesn't need to copy Scala if it has better features. 22:11 looking at the 2 aligned arrows on the `case` lines, I wonder if there's any tool that can align those arrows for me (something like scalafmt). 44:21 suppose that record A contains record B which contains record C ... which contains record Z. Now I want to create a new instance of A from another instance of A where a field in the record Z changes its value, how do I write that? Does "record with" create more garbage for the GC to collect that a mutable class?
@knm080xg12r6j991jhgt
@knm080xg12r6j991jhgt Ай бұрын
Thank you, I'm glad someone else agrees with me on this. A lot of this has been done, and done better, already. Java the language is not innovating, it's copying, and not doing a good job at it. They invented a new escape character for template strings which they yanked out in JDK 23 - all this for a feature that has been in other languages for decades. Heck, records were done already with Lombok, and they worked with all the existing libraries using reflection like Jackson because they used standard bean methods for properties. These new record types don't. All the innovation is being poured into the JVM. The rest of us are moving on to Kotlin, Scala, or really anything else.
@forKotlinsky
@forKotlinsky Ай бұрын
@@knm080xg12r6j991jhgt valhalla... one day...
@lepingouindefeu
@lepingouindefeu Ай бұрын
Yeah they're moving way too slow and the only thing that kind of paid off so far was Project Loom (Virtual Threads.) 😢
@lepingouindefeu
@lepingouindefeu Ай бұрын
But regarding GC pressure, I'm assuming this will become a non-issue once Project Valhalla ships in 2099. 😢
@avalagum7957
@avalagum7957 Ай бұрын
@@lepingouindefeu project Valhalla sounds like a magic then 😊
@delanym
@delanym Ай бұрын
Whats the benefit of records and sealed interface vs an enum?
@peacemakerle
@peacemakerle Ай бұрын
This question makes no sense. Those things have completely different purposes.
@delanym
@delanym Ай бұрын
​@@peacemakerleit's because the sealed interface can model heterogeneous values and avoid unrepresentable states, while the enum is forced to include constants that do that. Otherwise it's overkill: just use enum
@millodev
@millodev Ай бұрын
Why Java is becoming more and more like Scala Language ?
@yilativs
@yilativs Ай бұрын
it does not. Java slowly introduces new useful features that increase productivity without making code unreadable and keeping backward compatibility.
@viacheslavpivovarov6767
@viacheslavpivovarov6767 Ай бұрын
I can compile java 17 project with java 8 dependencies but I cannot compile scala 3 project with scala 2 dependencies 😢 (maybe because I'm butterfingered idk)
@cobrab1978
@cobrab1978 Ай бұрын
Why records not return implicity in the accesors a defensive copy of a mutable fields?
@dispatch-indirect9206
@dispatch-indirect9206 Ай бұрын
There's no single, correct way to defensively copy objects. Object.clone(), when it works, only makes a shallow copy. If you need e.g. a List as a field, you can do this to force it to be immutable: record R (List x) { R { // shorthand skips the arguments x = List.copyOf(x); } }
@peacemakerle
@peacemakerle Ай бұрын
Using records widely here in business logic. But I really dislike that the canonical constructor of public records can not be private. Now, people are exposing constructors which should be private because there are static create-functions or builders which should be used instead.
@udayaprakashk
@udayaprakashk Ай бұрын
Record pattern matching looks very verbose, why can’t we just shape instanceof Circle c and just use it?
@simonmassey8850
@simonmassey8850 Ай бұрын
I thought string templating just got dropped? (which is actually a success story in a way)
@alessioantinoro5713
@alessioantinoro5713 Ай бұрын
Not dropped, just saying that this version of it is not what they want, and they'll take their time to find a better solution
@bentels5340
@bentels5340 Ай бұрын
​@@alessioantinoro5713 That's still dropped. They're starting over completely.
@alessioantinoro5713
@alessioantinoro5713 Ай бұрын
@@bentels5340 Starting over is a big word, they do have experience over what they did already, so it dont think it would take too long
@Galzysoft
@Galzysoft Ай бұрын
❤ am the first to comment
@B_knows_A_R_D-xh5lo
@B_knows_A_R_D-xh5lo Ай бұрын
😊
@ricardojlrufino
@ricardojlrufino Ай бұрын
AsyncResult is useless ... Try .. catch will be more clean . I will forced to implementar all egde cases ? ( Timeout and interrupted )
@JoeBrigAI
@JoeBrigAI Ай бұрын
“Only use immutable data”, my database would like a word.
@lepingouindefeu
@lepingouindefeu Ай бұрын
It's not referring to databases.
@JoeBrigAI
@JoeBrigAI Ай бұрын
@@lepingouindefeu I write Java enterprise applications that are all about modifying and managing mutable data.
@lepingouindefeu
@lepingouindefeu Ай бұрын
@@JoeBrigAI Yes, I understand. But doesn't everybody? I think the point is that, at least in code, the representation of that data should be immutable where possible, so you leave the mutability points very restricted to only where it's necessary. For instance, if you're using a record that represents a database entity, instead of mutating the record in-place, you can create a (trivial) copy with the updated fields. That makes behavior more predictable, and the code becomes more maintainable when you're working with large teams. I've worked for companies where the devs would have so many unnecessary issues because the code was mutating state in so many different places, and that would've been a non-issue if instead we embraced an immutability-by-default approach. And regarding GC pressure, it won't be as much of an issue as you might think, especially with escape analysis and Project Valhalla coming soon.
@lepingouindefeu
@lepingouindefeu Ай бұрын
Also, mutable records introduce pesky bugs regarding identity comparison and hash code generation.
@guttormvik6335
@guttormvik6335 Ай бұрын
Record still pisses me of. Start with a record. Then you need mutable state, so you have to change it to a class, and then you have to add in all the junk code that records got for free.
@qdeqdeqdeqde
@qdeqdeqdeqde Ай бұрын
why do you need mutable state?
@Mig440
@Mig440 Ай бұрын
With expressions should help with that
@peacemakerle
@peacemakerle Ай бұрын
Yes, I thought the same. The generation of default equals/hashCode/toString should be a feature which isn't bound to a specific supertype or immutable state. Better would be, for example, to control it by annotations. It also sucks that arrays aren't compared by value (but that is only in rare special cases a problem, usually we are using collections).
@alexgorodecky1661
@alexgorodecky1661 Ай бұрын
For me, component accessor for immutable state is pure dumb. It is not FP, it's crazy Frankenstein of OOP and FP
@Mig440
@Mig440 Ай бұрын
@@alexgorodecky1661 then you clearly have no understanding of the theoretical underpinnings of FP. Ever heard category theory?
@bluemeriadoc
@bluemeriadoc Ай бұрын
33:12 lol, guy has never heard of multicatch from Java 7
@BloodnutXcom
@BloodnutXcom Ай бұрын
Java is ancient in terms of features. All of this presentation is just copying the low hanging fruit of Scala which is a JVM language - 10 years later! Talk about "last mover advantage"
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 16 МЛН
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 30 МЛН
Modern Java in Action
50:32
Java
Рет қаралды 36 М.
Java 21 new feature: Virtual Threads #RoadTo21
33:35
Java
Рет қаралды 60 М.
Java in 2024 - Constant evolution, delivered.
44:00
Java
Рет қаралды 8 М.
How Netflix Really Uses Java
50:31
InfoQ
Рет қаралды 48 М.
The Worst Programming Language Ever - Mark Rendle - NDC Oslo 2021
1:00:41
NDC Conferences
Рет қаралды 1,3 МЛН
Spring Tips: Useful Annotation Processors
25:51
SpringDeveloper
Рет қаралды 10 М.
Is Java the NEW COBOL in 2024?
6:06
Stefan Mischook
Рет қаралды 9 М.
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 16 МЛН