Java 21: Focus on Virtual Threads and Pattern Matching

Поділитися
Вставка
  • Опубліковано 27 вер 2023
  • Java 21 is coming with many new features, two of which will have a tremendous impact on the way you write Java code. This session covers these significant topics: virtual threads and pattern matching that enables data-oriented programming for the Java platform. First, you’ll learn how virtual threads fix several problems with the executor service pattern and propose an alternative programming model to asynchronous programming. This model lowers the maintenance cost of your application code and also improves its observability.
    Then, you’ll see how data-oriented programming can improve the quality of your architecture. It is an alternative to object-oriented programming, a paradigm on which Java has been built from the beginning. It relies on three features: sealed classes, records, and pattern matching. Records and sealed classes are already final features, whereas pattern matching is still under work, with some elements already there and more to come.
    Speaker: José Paumard
    Join us:
    Website: jb.gg/website
    Blog: jb.gg/blog
    Twitter: / intellijidea
    Facebook: / intellijidea
    Download IntelliJ IDEA: jb.gg/download-intellij-idea
    Top 15 IntelliJ IDEA shortcuts: jb.gg/Top15IntelliJIDEAShortcuts
    #java #intelliJ #jetbrains
  • Розваги

КОМЕНТАРІ • 25

  • @yashverma7084
    @yashverma7084 9 місяців тому +5

    so exited for virtual threads I've dying to use a similar thing like coroutines in java

    • @lufenmartofilia5804
      @lufenmartofilia5804 4 місяці тому +1

      It's actually even better than coroutine and more lightweight

  • @yashverma7084
    @yashverma7084 9 місяців тому +3

    oh yeah the the coffee

  • @khaled.noordin
    @khaled.noordin 9 місяців тому

    👍🏼

  • @gleitonfranco1260
    @gleitonfranco1260 9 місяців тому

    🔝‼☕

  • @AndreTiconaRollano
    @AndreTiconaRollano 9 місяців тому +4

    Great presentation. I've read the final nature of records make them incompatible with the JPA specification for entities. Are there any future plans to introduce something similar to records that could work to reduce the verbosity of writing JPA entities?

    • @JosePaumard
      @JosePaumard 9 місяців тому +2

      Records are basically immutable. So to make it a JPA an Entity doesn't seem possible.

    • @Mig440
      @Mig440 9 місяців тому +2

      Records are better suited to be value objects in DDD terms. I dont think we can get around the fact that JPA entities must be mutable in order to make Hibernate and orms work in general. Hibernate 6.3 already has something in the works for using records as embeddable value objects. Now C# 12 will have support for a feature like what you ask for in the form of canonical constructors for classes in general, but I am not sure it would cut down on the boilerplate needed for JPA annotation based configuration, there is simply no way around that fact. Unless you want to go back and use hbm xml files for configuring jpa entities.

  • @MrSoufianebo1
    @MrSoufianebo1 9 місяців тому +3

    Wich use lombok or Record ?

    • @JosePaumard
      @JosePaumard 9 місяців тому +7

      Record is a language feature that opens for Pattern Matching / Deconstruction. Lombok doesn't allow that.

    • @Ambusher306
      @Ambusher306 9 місяців тому +1

      Lombok is not as efficient as Record since it cannot access JVM internals. It just writes the code for you.

    • @Mig440
      @Mig440 9 місяців тому

      ​@@Ambusher306lombok does use internal features of javac, that is why it breaks every so often with newer jdks. It is quite a maintenance headache in the long run. And please do NOT use @Data on jpa/hibernate entities. It is bound to go wrong and you will shoot yourself in the foot!

  • @tarphuer
    @tarphuer 9 місяців тому +1

    Hey Jose. I would like to point out CompletableFuture APIs are not like asynchronous framework. because it will block the thread from the threadpool(if you pass a pool) or the commonpool . Hence completeableFuture APIs itself will not be able to achieve 1 million concurrency, without the help of virtual thread. Do you agree?

    • @JosePaumard
      @JosePaumard 9 місяців тому +1

      Absolutely. You should not pass blocking lambdas to the CompletableFuture API, as you should not do that to any asynchronous framework.

    • @tarphuer
      @tarphuer 9 місяців тому

      @@JosePaumard I think most async framework are actually async IO framework since IO is the main source of blocking. The example you gave is also an IO blocking case. CompletableFuture api cannot solve async IO problem, can it?

    • @JosePaumard
      @JosePaumard 9 місяців тому +1

      @@tarphuer Oh yes it can. You can even specify in which executor service you want your task to be executed. So if you have a specialized I/O ES, you can use it too.

  • @haryanvi_vocal
    @haryanvi_vocal 4 місяці тому

    trying to using virtual threads in jdk 21. when i am using Thread.ofVirtual().factory() and compiling throw jdk 21 . it's giving error ofVirtual() is a preview API and is disabled by default. Is it not the permanent feature. i got the information in this video that you can start using this. Kindly help me with this. IDE is intellij

  • @eNtrozx
    @eNtrozx 9 місяців тому

    How does one work with records without a mapping API (so called "with"), it's pretty much useless.
    Only useful for situations when you don't need mapping, but what happens when you suddenly need to? You will need to write a robust copy with 1 modified argument.

    • @JosePaumard
      @JosePaumard 9 місяців тому

      This is a feature that could be coming in the future. Brian Goetz talked about it in this talk: ua-cam.com/video/TIHx6MNt79Y/v-deo.html

  • @brandpcalderon5343
    @brandpcalderon5343 9 місяців тому +7

    Indian english accent it´s difficult to understand -__-

    • @ClariNerd
      @ClariNerd 9 місяців тому +2

      No such thing in tech!

    • @cosmowanda6460
      @cosmowanda6460 9 місяців тому +1

      it's always funny when someone in computer science or math complains about accent.

    • @poojapatole3573
      @poojapatole3573 8 місяців тому

      Why?

    • @sournois90
      @sournois90 6 місяців тому

      ​@@cosmowanda6460what do you mean? what's the problem with simply not being used to the accent and having a hard time understanding it?