Java 19 in Action - Inside Java Newscast #33

Ғылым және технология

Java 19 is released on September 20th and, among other things, ships with virtual threads, structured concurrency APIs, sealed types, and pattern matching in `switch` - all of them as previews, but still very cool! We're using these features here to create a GitHub crawler.
The code on GitHub: github.com/nipafx/loom-lab#gi...
__ Chapters __
0:00 ➠ Highlights
0:21 ➠ Intro
1:04 ➠ Meet The Crawler And Warm Up With Records
IJN #32 on string templates: • String Templates, Java...
JEP Cafe #11 on virtual threads: • Java 19 Virtual Thread...
4:12 ➠ Virtual Threads - Blocking HTTP Client?
7:19 ➠ Virtual Threads - "Interception by Project Amber!"
JEP Cafe #13 on structured concurrency: • Java Asynchronous Prog...
9:02 ➠ Structured Concurrency - StructuredTaskScope
13:05 ➠ Structured Concurrency - Concurrent Data Structures
16:13 ➠ Structured Concurrency - Records With Collections
20:48 ➠ Structured Concurrency - Debugging Glory
25:13 ➠ DOP - Type Hierarchies
IJN #29 on DOP: • Data-Oriented Programm...
27:32 ➠ DOP - Type Pattern Switches FTW
31:23 ➠ DOP - Deconstruction Patterns
IJN #26 on deconstruction patterns: • Deconstructing Records...
32:24 ➠ DOP - Isn't `instanceof` Bad?
27:19 ➠ Outro
Tags: #Java #Java19 #OpenJDK #InsideJava

Пікірлер: 65

  • @bmw328driver
    @bmw328driver Жыл бұрын

    Showing examples of the actual new features of JDK 19 in action "live" helps me get a better understanding of how to use them. Still using 17 for private hobby projects and 11 at work. I really like this format. Maybe just slow down a TINY bit when explaining things for old guys like me trying to follow along.

  • @shady-xgottwald4053
    @shady-xgottwald4053 Жыл бұрын

    🙂Thanks for the glimpse of what more advanced ,modern java looks like.♥I've grown sick-tired of channels with 10h+ tutorials that spend a considerable amount of time going through if-statements and for-loops.(Tutorial hell!) Keep it up!

  • @nipafx

    @nipafx

    Жыл бұрын

    Thank you! While we're not generally averse to tutorials, we're focusing almost exclusively on what's current and what changes, so you don't have to worry about tutorial hell (lol) here. 😃

  • @onebeartoe
    @onebeartoe Жыл бұрын

    This show has a great format and the demo helped me understand structured concurrency more. Thanks!

  • @java

    @java

    Жыл бұрын

    Great to hear!

  • @ubaidrehman3430
    @ubaidrehman3430 Жыл бұрын

    Nice presentation. Can't wait to fork and test in my local.

  • @laurentjeanpierre3662
    @laurentjeanpierre3662 Жыл бұрын

    Hi, nice presentation, as usual. Debugging the thread stack this way is interesting, but I would expect IntelliJ to give you the information while stopped at a breakpoint. The only downside I found is the music. Combined with the lack of subtitles, it makes you barely understandable at some times. Keep on this nice work!

  • @nipafx

    @nipafx

    Жыл бұрын

    Hi Laurent, sorry that there are no subtitles this time (this episode wasn't scripted). If there's something you couldn't make out, feel free to ask here. :) Re: IntelliJ, yes, it should display this information soon. It could also allow for easy navigation and it probably needs a better way to let you select a thread than in a drop-down menu. 😉 Plenty of room for cool new features. You can track this issue: youtrack.jetbrains.com/issue/IDEA-301409/Support-virtual-threads-project-loom

  • @VisruthCV
    @VisruthCV Жыл бұрын

    Excellent 👌, thanks for publishing!

  • @java

    @java

    Жыл бұрын

    Glad you liked it!

  • @levinie5081
    @levinie5081 Жыл бұрын

    Great video! By the way, you can let intellij idea complete the "var" keyword instead of full type declaration by click the gear icon which appearing after input the .var + Tab and then choose "Declare var type"😊

  • @nipafx

    @nipafx

    Жыл бұрын

    Thanks! I felt like an idiot replacing the types with `var`. 😂In a past version, there was a checkbox there - not sure since when that's gone.

  • @FiveNineO
    @FiveNineO Жыл бұрын

    Amazing content 😊 thanks guy

  • @nipafx

    @nipafx

    Жыл бұрын

    My pleasure! 😁

  • @echoturing7334
    @echoturing7334 Жыл бұрын

    Amazing!

  • @stcattc
    @stcattc Жыл бұрын

    @java pretty sure the CHM compute / merge etc. Methods only lock the map on the key. @nipafx also interesting to see the new thread.dump_to_file from jcmd. Can't find that in any of the reference pages though. Any good resources for the jdk tools that have had improvements in recent java versions too?

  • @sandeepthakur7795
    @sandeepthakur7795 Жыл бұрын

    Please try to zoom in as much as possible while explanation

  • @vixdc
    @vixdc Жыл бұрын

    Thank you for this very useful video! Here my feedback hoping it helps: - I would increase the font of the editor and maybe the presentation mode provided by IntelliJ IDEA is the way to go :) - I would keep your pretty face in a corner as small as possible :p - I would show for more time transitions with titles and notes :| - Sometimes I found the music overwhelming :/

  • @BeepDerpify
    @BeepDerpify Жыл бұрын

    Love the video! The music is a bit distracting though 🥲

  • @LeandroCoutinho
    @LeandroCoutinho Жыл бұрын

    Please make the code larger and your picture smaller.

  • @AleksandarT10
    @AleksandarT10 Жыл бұрын

    So now instead of using a thread pool and creating Futures to submit a task, we are going to use a StructureConcurrency - scopes in order to achieve this with Virtual Threads? And also use the Sync versions of methods along with Virtual Threads? Am i following correctly? Also when would it make sense to use thread pools and platform threads after Virtual Threads are used all over the place?

  • @ESGreenie

    @ESGreenie

    Жыл бұрын

    Probably when you are using a pool not because of creating too many threads but because creating too many concurrent processes might be problematic. For example, creating too many concurrent requests against a DB or a web service (DOS attack yeah!) or creating too many CPU intensive jobs. We create pools for many reasons, and virtual threads has done a fantastic job of removing one of them, too many heavy threads at the same time is a no-no, the rest still exist. Cheers!

  • @DevMultitask
    @DevMultitask Жыл бұрын

    Virtual Threads or Real Threads - you need to know what are you doing. Great demo, thanks!

  • @kamalhm-dev
    @kamalhm-dev Жыл бұрын

    the code is way too small

  • @Unix404
    @Unix404 Жыл бұрын

    good vid

  • @lovetyagi5266
    @lovetyagi5266 Жыл бұрын

    Java is love

  • @BrettRyan78
    @BrettRyan78 Жыл бұрын

    Love your videos Nicolai. Could you maybe make them more viewable for us visually impaired folk? The code portion was tiny. When zooming that part to full screen is still a little small for me on my desktop (I use 18pt editor font).

  • @AlLiberali
    @AlLiberali Жыл бұрын

    Wicked

  • @cosminmargarit9875
    @cosminmargarit9875 Жыл бұрын

    Hello, this is awesome, can't wait for java 19. Still a lot to learn though. I currently am using java 17, and I am trying to implement a dynamic/generic strategy pattern, that based on an Enum entry can define some lamdas functions and type accessors (to retrieve fields form an object) to apply some logic (it's a filtering systems, and the enum represent different types of filters available in the application, that are optional and sent by client). But I am having some brain fogg issues trying to clearly define this code and make it as easy to be used further. Any tips/ideas/videos/tutorials helpful on this topic? I need to learn more :D

  • @nipafx

    @nipafx

    Жыл бұрын

    Can you boil your problem down to a small example, maybe post a gist ( gist.github.com/ )? Then I can take a look.

  • @cosminmargarit9875

    @cosminmargarit9875

    Жыл бұрын

    @@nipafx hey, I am trying to comment but seems like my comment is not posted. May it be because of the gist link?

  • @nipafx

    @nipafx

    Жыл бұрын

    @@cosminmargarit9875 I don't see anything in the list of comments that are held for review. 😕 Here are a few ways to get in touch with me: nipafx.dev/contact/

  • @nipafx

    @nipafx

    Жыл бұрын

    @@cosminmargarit9875 Maybe, yeah. I can't find it in the list of comments under review, though. If you're on Twitter, you can DM me there (my user name is also nipafx).

  • @danthe1st
    @danthe1st Жыл бұрын

    I'd say the statistics are wrong because the same page can be a child of multiple different pages resulting in it being accessible under multiple pages hence counted multiple times.

  • @nipafx

    @nipafx

    Жыл бұрын

    We have a winner! Exactly! The proper version of this code ( github.com/nipafx/loom-lab/blob/main/src/main/java/dev/nipafx/lab/loom/crawl/Statistician.java#L40-L42 ) accounts for that but I forgot to include it in the live-coding session and only noticed in editing. As promised, here you go: 🏆 😉

  • @martinsam16xyz
    @martinsam16xyz Жыл бұрын

    Good

  • @ccsnethlage
    @ccsnethlage Жыл бұрын

    The only time someone is disappointed that his code compiles...

  • @nipafx

    @nipafx

    Жыл бұрын

    😂 True.

  • @berndeckenfels
    @berndeckenfels Жыл бұрын

    I would stick with interfaces like „PageWithLinks“ instead of relying of implicate knowledge. You still can use sealed types and instanceof casting. (And probably for the specific case of a crawler which needs to limit parallelity also a normal Executor. And caching the unresolved futures with ifAbsent)

  • @mustafaider3421
    @mustafaider3421 Жыл бұрын

    Tell soft soft I love what they did with the $15 doallors one %

  • @edwinamoakwa5409
    @edwinamoakwa5409 Жыл бұрын

    Is the code hosted ?

  • @nipafx

    @nipafx

    Жыл бұрын

    Yes, but I initially forgot to add the link to the description 🤦🏾‍♂ - added it since.

  • @lapissea1190
    @lapissea1190 Жыл бұрын

    Only thing that I feel could be better is the resolve links. A virtual parralel stream would do the same job so much cleaner

  • @nipafx

    @nipafx

    Жыл бұрын

    That's an interesting idea. Do you have the opportunity to give it a try? Maybe the exposed structured concurrency APIs suffice to build a streaming API on top of it (outside the JDK).

  • @lapissea1190

    @lapissea1190

    Жыл бұрын

    ​@@nipafx Hmm. I've never written a Stream implementation but that could be a way to do it. Another way would be telling the stream what worker to use by running the stream inside the worker task. (The worker would just need to spawn virtual threads) But that's certainty not the cleanest solution.

  • @bobonaut
    @bobonaut Жыл бұрын

    My goats are too precious to sacrifice to the capricious algorithms...

  • @nipafx

    @nipafx

    Жыл бұрын

    😂

  • @Ambusher306
    @Ambusher306 Жыл бұрын

    Clear cache :)

  • @nipafx

    @nipafx

    Жыл бұрын

    Or `mvn clean`? I think it was running old bytecode...

  • @Ambusher306

    @Ambusher306

    Жыл бұрын

    @@nipafx yeah that’s most likely. Cache is for IntelliJ but it can detect the switch error in the first place. So it is mvn clean

  • @jerzyterski4896
    @jerzyterski4896 Жыл бұрын

    Too small txt/code for mobiles

  • @nipafx

    @nipafx

    Жыл бұрын

    On the one hand I'm sorry to hear that. On the other hand, coding with a large enough font so that it's readable on mobile would be very frustrating for me and also for everyone watching on a larger screen. I don't think I'm gonna aim for that. But most Newscasts come without live-code (in fact, this is the first one that doesn't), so this shouldn't come up very often.

  • @saiupadhyayula4837

    @saiupadhyayula4837

    Жыл бұрын

    @@nipafx IMO it's more about the space allocated on the screen for the code. During the code explanations it will be good to have the 90% of the screen allocated to show the code. As of now it's 60-40, which makes the code hard to read on mobile.

  • @nipafx

    @nipafx

    Жыл бұрын

    @@saiupadhyayula4837 I understood Jerzy's comment to mean that the font size should be larger. That necessarily means fewer lines of code as the IDE has (almost) 100% height of the screen. Making the IDE wider is a different proposal - I will consider it.

  • @bluemeriadoc
    @bluemeriadoc Жыл бұрын

    19 has no production-ready JEPs except Linux/RISC-V Port. JDK 20 releases in 6 months but has no JEPs targeted to it yet. lol

  • @nipafx

    @nipafx

    Жыл бұрын

    Indeed, these are all preview features. I pointed that out in my other Java 19 video, but should probably have repeated it here - it just happens sometimes. 🤷🏾‍♂ 20 not having JEPs at this point is normal. Give it a few weeks after 19 got released and we should see them trickling in.

  • @fernando-2160
    @fernando-2160 Жыл бұрын

    First 👍

  • @pixelslate9979
    @pixelslate9979 Жыл бұрын

    Start practice TDD, dude!

  • @alexop5919
    @alexop5919 Жыл бұрын

    Please make code bigger

  • @tanveerhasan2382
    @tanveerhasan2382 Жыл бұрын

    Third

  • @zoladkow
    @zoladkow Жыл бұрын

    Oh man... 😑 i SO much preffer videos by Josh Long, laidback and zen... no excessive and pointless gesticulation, no chaotic music(?) in background... but hey, whatever 🤷

  • @nipafx

    @nipafx

    Жыл бұрын

    Everybody has their own personality and style and it's good that you found somebody who matches your preferences - and Josh in particular is a fountain of knowledge. 👍 If you're looking for somebody else who's a bit calmer, check out Jose Paumard's JEP Cafe: kzread.info/head/PLX8CzqL3ArzV4BpOzLanxd4bZr46x5e87

  • @user-zq8bt6hv9k
    @user-zq8bt6hv9k Жыл бұрын

    you should switch to rust tbh. I did two years ago and I've not been impressed about any of the things I saw here, except man there's still a ton of boilerplate in java.

  • @prdoyle

    @prdoyle

    Жыл бұрын

    You do know whose video you're commenting on, right?

  • @_SG_1
    @_SG_1 Жыл бұрын

    11:00 The necesscity and inconsistent API of scope.throwIfFailed() bothers me greatly. I can almost guarantee you that it will be another source of bugs if that makes it into the final release.

Келесі