Become a Creator today!Start creating today - Share your story with the world!
Start for free
00:00:00
00:00:01
Java’s Cutting Edge Comeback (with Josh Long) image

Java’s Cutting Edge Comeback (with Josh Long)

Developer Voices
Avatar
0 Plays2 seconds ago

Java’s has been evolving faster than any 30 year old language has a right to do, and there’s probably no-one more pleased about it than my guest this week - Josh Long. He’s a Java & Kotlin programming, a JVM enthusiast in general, and an advocate for Spring, and he has chapters full of news about what’s been happening in Javaland over the past few years. Everything from new threading models to C interop changes, custom primitives to high performance computing and all the ways in which Java is modernising for age of AI workloads.


If you’re out of touch with the latest in the JVM, or don’t know how much its changed, Josh’s brain is full of all the news you need to catch up.



Project Valhalla (Value Objects): https://openjdk.org/projects/valhalla/

Project Panama (JVM’s new native code support): https://openjdk.org/projects/panama/

Jextract: https://github.com/openjdk/jextract

Spring Initializer: http://start.spring.io/


Support Developer Voices on Patreon: https://patreon.com/DeveloperVoices

Support Developer Voices on YouTube: https://www.youtube.com/@developervoices/join


Kris on Bluesky: https://bsky.app/profile/krisajenkins.bsky.social

Kris on Mastodon: http://mastodon.social/@krisajenkins

Kris on LinkedIn: https://www.linkedin.com/in/krisjenkins/

Recommended
Transcript

Java's Comeback and Innovations

00:00:00
Speaker
Here's a story that you've heard from Hollywood, but you've never heard from a programmer before. You've got an aging prizefighter, an old washed-up boxer. Everyone assumes his best days are behind him.
00:00:12
Speaker
And he enters the ring with a scrappy young upstart and loses. Loses several rounds quite badly, but then goes into training and comes back stronger than ever.
00:00:24
Speaker
Sylvester Stallone stars as the Java Virtual Machine. and I can't see Netflix picking that story up anytime soon, but I think that is the story.
00:00:35
Speaker
If you look back 10, 15 years, Java had stagnated. It was losing a lot of ground to Scala in particular, but other languages too.
00:00:46
Speaker
And it looked like while the JVM wasn't going anywhere, anything new would have to come from elsewhere. And then against all odds, and certainly against any of my expectations,
00:00:59
Speaker
Java the language and Java the virtual machine underneath seem to find a new lease of life. They started to pick up some momentum. Java and the JVM yeah recently have been changing with a speed I would absolutely not expect from a 30-year-old language.
00:01:16
Speaker
And I've tried to keep up. I've tried to follow the news from afar. I've heard the buzz, but I haven't really followed the details. So when it came up, I took the chance to speak to a man who must be the most enthusiastic proponent of the JVM that I've ever met, Josh Long.
00:01:35
Speaker
And I asked him, what is it all this new stuff?

High-Performance Java and Conference Highlights

00:01:37
Speaker
What have I been sleeping on? And his answer includes new techniques for high-performance computing, for data-oriented programming,
00:01:46
Speaker
for asynchronous programming without async await keywords, for a new threading model, and for a serious move for Java to get in the ring with Python and C and compete for the AI crown.
00:02:00
Speaker
There's a lot of new stuff to dive into. Before we do that, I will tell you that this episode was recorded live at the Code Remix conference in Miami. So thank you to Modern and Open Rewrite for hosting this title fight, this comeback special?
00:02:18
Speaker
Let's find out. I'm your host, Chris Jenkins. This is Developer Voices, and today's voice is Josh Long.
00:02:36
Speaker
I'm joined today by Josh Long, Josh, you are you've got your own reputation, but your reputation to me is i think you're the most enthusiastic Java person I've met since Java was launched. Cheers.
00:02:50
Speaker
You genuinely love it, don't you? I love the JVM. um I love the community. I love the technology ah atop the JVM. Java, the language, it's get it's growing on me. It's only been 30 years, I think. 30 years, and I think I'll be there. But yeah, it's ah it's a good language, just not the greatest.
00:03:05
Speaker
But that's okay. I think one of the greatest is actually within the JVM community itself. So again, you celebrate that, and you're still in a winning place. you know Which you going to pick? Kotlin?

Java vs. Kotlin and Language Evolution

00:03:13
Speaker
I think Kotlin. Yeah. has It scratches.
00:03:16
Speaker
no There's no perfect language. We agree on that, right? Sure. For 80% of all the itches I've got, it's that well that scratches them correctly. and Okay. maybe Maybe I'm going to ask you about that then. What is it about Kotlin?
00:03:29
Speaker
I mean, first and foremost, it's an elegant modern language on top of the JVM. yeah That's the crown jewel here. I stress the JVM because it doesn't matter if you like Java. Nice though it is and fast improving though it is.
00:03:40
Speaker
ah um you know The JVM is the crown jewel, that runtime, the garbage collector, the performance, the fact that even 10 years ago, before all this incredible stuff they've added, it was already one of the most energy efficient, scalable languages out there, you know competing with the likes of Go and other things like that in a lot of areas.
00:03:55
Speaker
The fact that that was true so long ago and it's just getting better, Yeah, the JVM is an amazing thing. But then Kotlin was done with a fresh coat of paint. it's ah It was done from a whole cloth 15 years ago. So it was able to sort of look 15 by now.
00:04:12
Speaker
I don't know, maybe even longer. It's 20, what is it, 2010, 2008, 2009, something like that. so but you know So I will say that I think the language designers behind Kotlin have done a remarkable job. And it shows a talent.
00:04:25
Speaker
you know but
00:04:29
Speaker
Let's just also agree that if you start something in 2010, you're going to avoid a lot of the mistakes that befell languages starting in 1995. That's just facts, right? I would hope that's the case. I would hope we're learning things as we go along.
00:04:41
Speaker
So even if you take nothing else from it than that, it's a fresh approach to a new language built from whole cloth in 2010, then it's already ahead. It has to be.
00:04:52
Speaker
It just by but from day zero. So there's a lot of idiosyncrasies ah that Java has that reflect its endearing and enduring commitment to backwards compatibility that you know in their approach to adding new features of language, they they sought to preserve backwards compatibility. And so there's all these other little things that were retroactively grafted into a language and they couldn't do whole cloth sort of essential refactorings of the way things worked because that would sabotage the the compatibility that they so sought to preserve.
00:05:21
Speaker
So they did these things that were like half measures. And it it works right 90% of the time. It works fine. you know Generics not being reified works enough. you know um And auto boxing kind of works okay. yeah and yeah Java not having proper you know ah functional style it operators for collections, you know they kind of kind offf fixed it with streams also preserving existing code and you know just all this stuff. you know Records are kind of there, but then you know that that syntax, that compact style is not there for all the classes and just all these little warts.
00:05:59
Speaker
work Yeah. Things that if you were doing it from clean room, you wouldn't do it that way. You'd avoid. In fairness, i mean like i remember I think the last time I was working in Java was probably 2012 with a couple of exceptions.
00:06:13
Speaker
And i the language had basically stagnated. Oh, for sure. And it's amazing how how they pulled out of that stagnation mind and how much they've done since then, right? I mean, yeah, to their credit, to their enduring credit, I think Java 8 was a... 2014 was, I think, one of the most ah important years for the Java community because that was the year both Spring Boot 1.0 came out and Java 8 came out.
00:06:35
Speaker
These two things just changed things for the better, I think. Java 8 gave us functional program... well, ish. We don't have tail recursion. We don't have, like, actual proper... There's no monad in Java suddenly, but... I'm a mint person, I bet.
00:06:50
Speaker
Yeah, it's but for the 80% where people just want functional iterators, operators on their collections and all that, yeah it's there. You get lambdas, but again, that's another one. Lambdas, structural types as a first class citizen, where functions are a first class high, top level thing, that doesn't exist, right?
00:07:05
Speaker
At the end of the day, they get Java as a nominal language, everything has to have an an identity, and so everything gets reified or or reconciled against ah an interface. Which is fine, you know, but but also I really just want to be able to have a variable whose type is a function of int and string.
00:07:20
Speaker
Yeah, yeah. That returns a Boolean. You know, i just, that's, I want that to be enough. I don't want to have to extract out an interface where there's an apply method that takes an int and a string or whatever. and This is the thing. Java, I still feel has that ceremony that you don't get quite with any other language. but no big But again, if you're trying to do two arguments,
00:07:37
Speaker
you know, there's a by-consumer, right? There are ways to do it that work. And for most people who ever write a lambda using two parameters and returning a single value, you'll be fine. Heck, I think it goes up to like three. There's even a third one. but But what if you want to do a thousand?
00:07:51
Speaker
yeah Not that you would, but what if you did? You know, like ah in theory, Java

Java's Memory Management and Native Integration

00:07:56
Speaker
just doesn't have that cleanliness of implementation. you know And so for the practical everyday use cases, Java will feel just as refreshingly clean and concise as any other language.
00:08:08
Speaker
But you'll find these little invisible walls. yeah you know You think, well, i can surely if I can have a collection of string, then surely I can cast, I can at runtime extract out rather the, ah what is the generic bound of this type?
00:08:23
Speaker
It's a collection of what? Well, at runtime, that doesn't exist. yeah It's erased, right? So there's no collection of string, it's just collection. Oh, okay, so it's only a compiler thing. okay Still feels like it's working for me, but also I would love to be able to do that.
00:08:35
Speaker
Yeah. It's it' interesting. It's a mixture of syntax and um implementation details yeah in ways holding it back. And some cultural stuff, I think. I think like the Java... You can you can tell me I'm wrong. Please tell me I'm wrong. but i don't know yet.
00:08:54
Speaker
But Java as a world, it feels like they've boiled the frog up to the point where ceremony is normal. No, they've gotten rid of a lot of the ceremony. Really? i The language, again, for the 80% case, you know I can do... Let me try again. um Hello, world.
00:09:15
Speaker
In... Java is a class, a void main method, public static void main method, and system out print line. So there's ceremony there. Agreed. That'll go away in Java 25.
00:09:26
Speaker
You can have just void main parentheses parentheses system out print line. Right? Okay. Okay. And no class, no nothing. So that's, good that's but and that's upfront ceremony. And I agree. If you take that versus like, you know, Python, just print hello world, then of course we're going to lose.
00:09:40
Speaker
But that isn't where people use either of those languages, right? Python is not a toy. You're not there to write Hello World and ditto for python for Java, right? Java, its strength is in the large.
00:09:51
Speaker
The beginner's experience is important, but and it's dwarfed by the expert experience. No, it's dwarfed by the day 0.5. Okay. okay It's not not your first, literally your first line of code, but you're like, I want to do anything at all non-trivial, right?
00:10:05
Speaker
And ah so you'll... learn the ceremony and hopefully move past that. And hopefully in in literally four months whatever, that won't even be required. You can just say void main parentheses, parentheses, curly bracket, curly bracket.
00:10:17
Speaker
It's still some ceremony. Like in Python, you're taught to do if underscore underscore name equals underscore underscore. Yeah, yeah. And print hello world, right? ah So there's that. you know but and But they're working on it, I guess is my point. they're They're appreciative of the fact that it's not great. They're fixing it. And that's all we can ask.
00:10:33
Speaker
a little more expediency would have been nice. like I think it's impressive how fast Java has been moving yeah given the weight and the history and the but amount of backwards compatibility they've had to deal with. Yeah. And and so I think for a lot of people, they're used to... and i rage against the public keyword.
00:10:50
Speaker
They're just so used to copying cargo culting these... like if you If every class is public, then that's an extra token that you have to add. right I know this is a small thing, but again, you think that you have to do that, and you just don't. So how do you do describe a class in TypeScript? You say class cat curly bracket, curly bracket.
00:11:05
Speaker
How do you do it in Java? Same thing, right? How do you describe a method that returns a string? You say string full parentheses, parentheses, curly bracket, curly bracket. how do you do it in TypeScript? Put the colon string as the return value. it's It's actually longer in TypeScript. There's a colon there, right? okay It's the same exact tokens, just rearranged.
00:11:20
Speaker
yeah and So when people say it's... it's Ceremonial, I just don't you know, I don't get it. We have ah we don't have inbuilt ah Like, for example, the array type is different from the collection type.
00:11:34
Speaker
Yeah. Right? And so in a lot lot lot of languages, that' there's no such distinction. The result is that if you use an array, which is a contiguous block of memory in Java, it's super, super efficient. Right?
00:11:44
Speaker
You can do a lot of things very efficiently because we're storing primitive types. Right? and so we're And so people look at that and go, okay, well, yeah, that's ceremonious because in Python or TypeScript whatever, I just have...
00:11:56
Speaker
bracket, bracket, and then some values in there in a literal, right? Yeah. And um yeah, I can see where that's different, but there's a huge distinction there. Our arrays, compared to other languages' lists, are a billion times faster. And they're just through the roof, right? Yeah, it's not ceremony, it's being specific. Yeah, and I agree that for the people who are just trying to store one, two, or three in a collection or a thing that aggregates them into one variable, you know that may seem ceremonial.
00:12:21
Speaker
um And then of course we get into, ah well, okay, let's say i want to support... but Let's say I want to have a list of one, two, three. what What should that do? right at the moment, that does the thing nobody thinks it does, which is it creates objects out of each number.
00:12:36
Speaker
it Yeah, so you get a list of integer, integer, integer, not int, int, int, the primitive values. right and those are And so that's like one of those examples of where they're striving to graft things retroactively onto this language. kind of It's a half measure and it hasn't really been a huge issue, but for all performance code, for all performance code in Java, one just drops down to int arrays.
00:12:59
Speaker
right yeah So in Java, you can have an array of int, you can have an array of float, you can have an array of Boolean. And in front of a collection, they can only be objects. you have to box the primitive types yeah into these objects. You have to wrap them these object wrappers, which means that every number now has an object header.
00:13:18
Speaker
Right? Yeah. Well, no wonder people don't do high performance video games in collection. They use ints, they use floats, they use arrays of things, you know? And so that, wouldn't it be nice if those things were unified?
00:13:30
Speaker
Yes. And so one of the things we're working on right now is Project Valhalla, right? Which means that basically you'll have the ability to have ah values as first class citizens. Like how do you add a new primitive type in Java?
00:13:44
Speaker
Do you? You can't. You don't. No. There's there's the whatever it's whatever the six or seven standard. Yeah. boan and float in And everything else is an object. Yeah. Well, wouldn what why can't I add a like a point, a value type called point, which is stored ah on the stack as just a float float, but behind the scenes, I can pass it around in terms of you know my point, an object that has an accessor for x and an accessor for Y. Yeah.
00:14:09
Speaker
Why can't I do that? So the project Valhalla will unify that so that when you you can write code in terms of that point, but behind the scenes, you're just having tightly packed float values. How is that going to look?
00:14:21
Speaker
Will I start writing in Java how I want something to be laid out in memory? You don't, eat you yes and no. You will say that this is a value class point. So literally the token will be value, space, class, voice, point.
00:14:32
Speaker
You'll have an int x int y or float x float y. Behind the scenes though, you're not dealing with an object header. You lose semantic identity. That point can't be compared to other points as memory references.
00:14:43
Speaker
Instead you compare them as values. Is float x and float equal to float x and float y? That's what's happening behind the scenes when you do equals equals. right yeah That's it. So you're getting the best of all worlds. You're getting... Because I don't really care. i don't want... It's not like I need to compare...
00:14:58
Speaker
like if I have two floats, two points of the same coordinates, I don't care if they have the same memory. I just need them to be the same point. right yeah they're They're small values. i need to I need to just know that they point to the same place on the map.
00:15:09
Speaker
right So that distinction is not useful to me. All I really want is the semantic identity, not the ah yeah the memory reference. always felt to me like um pointer-based equality in Java was kind of a hangover from how C did it. Yeah. And so so this gets this all you can create your own value classes, and those will just be... You can do equals equals.
00:15:29
Speaker
Not dot equals. On objects. And it'll do the right thing, right? um And you don't have to define the equals method yourself? I don't think you can. I don't even know. Yeah. good the vo it's This is still early days. it We're maybe a year or two off. But the idea is with that world, you'll have these...
00:15:43
Speaker
ah you'll have these values that you can now pass around. And because remember, the single biggest thing you can do to improve your performance for things like AI and video games and graphics and all that is cache locality, CPU cache locality.
00:15:57
Speaker
The more data you can fit in the same cache registers, the faster it is to find that data and work with it. Because you're constantly seeking and and all this stuff. Same with any like hard disk kind of arrangement. You don't want seek all over all of the disk. You want everything to be close together.
00:16:10
Speaker
So the same thing here. You want CPU cache registers to be near each other. You want them to be tightly packed. You don't want to waste space on object headers. Right, exactly. So that goes away now. right and then So you don't define how you want that all done. It's just done for you. right You've mentioned it two or three times now. Does this mean that Java is going after the games market? Are you implying that?
00:16:30
Speaker
No, I'm saying I think it's much more than it's going after the AI market. right But I can't speak to what the ambitions of the designers are. I can just say that were I designing a video game or a map or an AI TensorFlow kind of thing,
00:16:43
Speaker
Yeah, i or um way like in Python, they don't have these distinctions. So they can't do these things. The only way they do is by cheating by dropping down into C. So they have SciPy and NumPy and yeah all that stuff. That's not Python. There's no such thing in Python that does ah data frame. yeah So this stuff is all, they're using high performance primitives in C code.
00:17:02
Speaker
But there's that marshalling overhead. Why can't we have that high performance code in Java to begin with? We can do the same in Java. You could drop down to native code. It's long been a C API for Java, which is no fun to work with, as I recall. Even better, though. That's gotten better. So that you're talking about JNI, which is, a as you say, a rather hemorrhoid-inducing ah ah distraction.
00:17:22
Speaker
And it's the only thing I've ever seen where, in order to the whole point, most languages, where they want you to to to get purchase in that language. And so they they make it easy to interrupt with existing code bases, which one presumed 30 years ago would have been vast amounts of seed. Yeah.
00:17:36
Speaker
and Now, you know i I have plenty of code that it compiles down to the native C ABI, but it's not necessarily C. And um Java still isn't great up until recently. It hasn't been great at leveraging all that stuff.
00:17:50
Speaker
right And I think that's had two kind of interesting effects. First, remember, Java came out in the world of applets and the browser, embedded browser-based clients, right? Yeah. So at the time, the idea that I would have easy access to native APIs from my Java code was not something they were trying to

Concurrency Innovations with Virtual Threads

00:18:05
Speaker
encourage. you know You could do it in the rare instance you needed to, and it was in in definitely would have compromised the then-nascent and novel idea of write once, run anywhere. right yeah So they never really encouraged it. They made it like, i mean, it's the only language I know where in order to use c from Java, you have to write more C.
00:18:23
Speaker
The whole point is to repurpose existing see and get off of the language, right? yeah But ah no, you have to write more C to write this glue code. Yeah, Python has that as well there. Yeah, um and that's called JNI. So i don't I don't like that.
00:18:34
Speaker
ah Most languages have an easy foreign function interface. Basically, I can sort of like a reflection API. i can look up symbols in the native runtime. I can look up native symbols in the load path, right?
00:18:45
Speaker
and um And then get there you know ascertain the shape of those symbols and then call them. Well, now we have that in Java, since Java 22. It's called Project Panama. okay So you don't need the right C code to call something that's on there. If you're on... I mean, come on. it should I mean, this is a trivial example, but printf.
00:19:03
Speaker
and Why can't I just call printf, right? So Java now has this ability, since Java 22, you can create a memory arena. which is ah basically you're malloc-ing some RAM. ye And you could actually you can actually get the struct. You can get the layout of a struct in Java.
00:19:17
Speaker
And then say, OK, or you can describe this layout a struct. You can say, this struct has these fields. And um you know I want you to ah create a memory arena that is equal to the amount of memory that would be required for this struct.
00:19:29
Speaker
And then I want you to set this field to that value and set this field. So you can, in effect, reflectively interact with these types and then pass them back and forth natively. all from within Java. And it will lay it out in the way that C is expecting service works. but you have to do some hand-holding to tell it how to do.
00:19:42
Speaker
Are you writing that hand-holding in Java? Do I have to break out an XML file? You write it Java. Okay. But I don't want to even write it in Java, right? Because it is already written once, it's in C, and that seems like a perfectly reasonable way to go.
00:19:53
Speaker
So there's a tool called J-link, or is it J-extract? I forget, one forgets. It's jextract, I think, or jlink, one of the two. You point that at your your path and your header files.
00:20:05
Speaker
It'll dump out a Java peer. You add that peer to your class path. And so now for printf, I have a public static void printf function. I can import static.
00:20:16
Speaker
And it in turn calls the native Java of code, ah the native C code for me. And it just works? Well, no. there's I mean, it it works for the trivial stuff, yeah. But I wouldn't, like, um if you're doing you know Microsoft Calm, trying to get into Olay and whatever, yeah, you can expect to fiddle fiddle with that. And you might be better off just trying to do slow, low-level Project Panama stuff instead of using this high-level code generator thing.
00:20:38
Speaker
okay But yes, that's the point. Anything you can call in a C-A-B-I, you can now call from Java. That means Go, that means Rust, that anything that compiles to that C-A-B-I. And that's great.
00:20:50
Speaker
That's really good. like ah that's That's the kind of thing I wanted a long time ago. and ah but But to their credit, I imagine, like today, i with almost certainty, I can almost i can install...
00:21:02
Speaker
99.9999% of all the jars I see out there and run it on any operating system I run it on. yeah That's the worst job. You can't say that with any other language. You can't say that with Ruby, you can't say it with Python, you can't say it with PHP, you can't say it with Perl.
00:21:14
Speaker
They all have, nine you know half them, half of Python is native code or whatever. Some ridiculous proportion that makes everything risky. I've got 30 years of Python experience. it was I learned it when I learned Java. right I love Python, but don't tell me that it's pure. its it's It'll sit there and you' knowll you'll... I mean, again, we just talked about SciPy and NumPy.
00:21:32
Speaker
There was a time when that wasn't ah available on every operating system. And by the way, you know what's one of the operating systems that these kinds of things are not typically on ah and at the very beginning? Windows. Yeah. Because people are running this stuff in a Unix-y shell kind of environment. Yeah, yeah.
00:21:45
Speaker
They're not thinking about the Windows users, right? They made it work in Unix. That's all that matters. But it's not. Are you implying that like in modern versions of Java or forthcoming versions of Java, I can expect to write things like matrix multiplications of high efficiency on Windows and it will just work? ah Yeah. so going better there's a special case for that.
00:22:07
Speaker
um We have Project Valhalla. That's the thing about which I just spoke. That'll come in, don't know, nobody's promising anything. If it comes out in five years, I'll be grateful. If it comes out in two years, great. I don't know. No idea.
00:22:19
Speaker
Zero idea. um But, Brian Getz, Java language architect Brian Getz, assures us there's a working prototype and that they're just sort of polishing, i don't know, whatever.
00:22:29
Speaker
i give the Give the team time to cook. They do a great work when they cook, right? um But ah there's a contemporaneous with that. There's another effort called Project... um Project...
00:22:45
Speaker
Well, it's it's just the vector API. i forget what the project name was. It's the vector API. And the vector API is specialized support. It's not the old Java vector list type. you know it's it's Instead, it's it refers to matrices.
00:22:58
Speaker
So you can do fast Fourier transforms and matrix multiplication and and all the kind of stuff you'd need to do to build your own, say, TensorFlow, right like that kind of thing. ah there And that requires, i mean, that's GPUs, right? That's specialized computing hardware for that.
00:23:11
Speaker
yeah um And so again, with Project Panama, one could, were they so inclined, write native code to do that today. So you've already gotten out if that's really a thing you need to do and it's been there for a year at least.
00:23:22
Speaker
but But even better, there's a vector API. Project Panama is GA, but there's a vector API that's not GA, but it's been included and it's been fairly stable for years now. It's a preview feature. It's one of those things you just flag enable in the JVM you've currently got today.
00:23:36
Speaker
Enable preview, exactly. And it's there. And the reason it's not yet GA, despite it being so darn stable, I mean, the thing has been around, i think they started talking about it before the virus, before the COVID pandemic, right? It's been around in some incarnation or another for years, right?
00:23:50
Speaker
And um last I heard, and I could be speaking out of turn here, but the last I heard was that it's basically good to go, except that they might have to change everything. yeah what And what I mean by that is um the aforementioned Project Valhalla, well, the whole idea is there is that, I mean, imagine like big integer.
00:24:08
Speaker
right Big integer is a type in Java that gives you the ability to have a high fidelity integers ah you know that have like a thousand places or whatever. oh Yeah, sure. some Some huge number going beyond the limitations of...
00:24:20
Speaker
What's that standard that discovered IEEE or whatever? Yeah, yeah. What happens when you run out from 64-bit? Precision, yeah yeah. Exactly. All that stuff is specified in IEEE, but some people want to deal with like in finance context, financial context, 1,525, you know, like 20 numbers and then 0.275 has to still mean something. So there's, or at least without the point, right?
00:24:42
Speaker
If you're doing an integer, that still has to mean something, has to be preserved. So we have a thing a thing called big integer. But why couldn't that be preserved as a value type? right Why couldn't that be reified?
00:24:52
Speaker
right Same thing for the, i talked you about list of int, list of integers. Why couldn't it just be a list of ints? Why couldn't I have an array? Why couldn't it compile down to an array ints, even though i'm using a list as a wrapper?
00:25:05
Speaker
Why couldn't that be a value type? yeah um So there's all these things that'll look better and feel better once Valhalla lands. So they've released this vector thing. You can use it. And there's already been preliminary tests, notably in the 1BRC challenge.
00:25:22
Speaker
Oh yeah, Gunnar Mauling's process. How fast can you process a billllium roads one billion Billion Wallows of Weather Station Telemetry data, yeah. And the first and fastest entry there is ah Thomas Wurtinger's entry. He's the creator of GrowVM, and it's pretty good. But there's like one in the top 10, maybe it's like number eight or something.
00:25:42
Speaker
And that number eight is um using the Vector API. I forget the number, but it's one of those top 10 ones, and it's using the Vector API. yeah And um it's really fast, right?
00:25:53
Speaker
Qualify that. Well, it's... What do you We talking seconds? Minutes? Well, the top... It's it still... It's like one point... It's like two seconds, whatever whatever. Two seconds for billion rows. Yeah, billion. one With a B, right?
00:26:03
Speaker
The first fastest one is one and a half seconds. Isn't that right? one and a half seconds? I saw league table like the second day after that challenge came out. and Yeah, okay. I think the first one is 1.5 seconds, something like that.
00:26:15
Speaker
And then the rest of them all fight for staying under two seconds, right? It still kind of blows my mind that we can process a billion records in a couple of seconds Java. in jehovah yeah And that's not, that's without, so the first several, the first 20 odd, almost all them use exclusively the GrauVM Native Image Compiler, which will give you some benefits, particularly in their area of startup time, right? um But the Vector API allows you to optimize your runtime, right? You can deal with less RAM and deal with less data.
00:26:42
Speaker
But the problem is at the time of this competition, ran in January of 2024, so more than a year prior, ah there was no support for GrauVM Native Images and Vectors. so right So the preview feature is an OpenJDK preview feature, yeah but it wasn't unlocked for the native image capability of GraalVM, even though you could use it as part of the OpenJDK distribution
00:27:03
Speaker
that Graalvium ships with. right You just couldn't use that as a native image, an AOT t compiled native All these like preview features, but they don't necessarily all work with each other yet. but would you So now apparently they can.
00:27:15
Speaker
And so Thomas, I think he he told me that that were they to run the comparison again today, it would be faster. His entry, the fastest, right? i should We should get on then to talking about Graal.
00:27:27
Speaker
Yeah. because yeah we should We should outline what Graal is and why that's important. oh just wanted is Oh, yeah, sorry. Wrapping that thread up, you've got things like virtual threads, which are far, far more elegant and less ceremonious than async await, right?
00:27:42
Speaker
Oh, okay. Far less bureaucracy, far less ceremony, far less nonsense. It's just I change the executor type in one place in my program, and every thread that's spawned from that executor is now a virtual thread. I get the benefit of non-blocking I.O.
00:27:55
Speaker
without having to litter my code with async await. So this isn't just as good as TypeScript or Python or whatever. It's way, way better. Right? We have auto typing. We have var. Right? Again, i and i you can You can point to something like TypeScript and say, well, I don't need semicolons. This is the level where we're starting to qualify, well, Java ceremonious versus not.
00:28:16
Speaker
And it's a nonsense discussion to have. right People don't actually care about typing semicolons. It's just not a thing. If the compiler can tell you exactly where you screwed up, then there's no brain power required to get it right. So just do it. Who

Java's Approach to Asynchronous Programming

00:28:29
Speaker
cares?
00:28:29
Speaker
and And quite the contrary, you can make some all so you can make all sorts of weird mistakes without semicolons in JavaScript and TypeScript. I'm not excited about the semi-con argument at all. we can We can skip over that. i'm just my That's my point. Yeah, I mean... The level of pedantry we have to get into it to find real places where Java is actually markedly different than these other languages.
00:28:47
Speaker
Then you get into things like the collections. And I would say, yes, i we're 100% aligned, except there's a difference there, right? the the the story in something like a Python or a TypeScript is just not performing collections.
00:29:00
Speaker
It might be fun to use, but it's not performing, right? And so then you get into, like, well, i have to use a C extension. And I would say, okay, fine. But even there, you know, we're going to fix our value types before they fix their not performant collections.
00:29:14
Speaker
So then the question won't be which is more ceremonious. It's just they're they're both equally not ceremonious. And then which one's more performant? And I think the the answer already is Java. It'll be more so in the future. So I just think, again, ceremony is just not a thing as much as most people would like to ascribe it to.
00:29:30
Speaker
It's these corner cases. Like, ah want I want to have a lambda with 20 parameters. Oh, OK, well, can extract out an interface. But again, that might have been better designed as an interface anyway. It's clear there is there's got to be some rhyme or reason to it. you know I'm going to have to challenge you on this. I was going to avoid it, but um you gave a code demo earlier in your talk.
00:29:48
Speaker
Oh, yeah. And you still had the ceremony of... There was one class when you started, and it's seven directories deep. It's like source, main, Java, com, for example. yeah Yeah, you're right.
00:30:00
Speaker
So there are still ce ceremonious conventions if not enforced by the language in the Java world. They're definitely not enforced by the language. i think And that's where I agree. ah so there's no reason in Java I couldn't just have a main class and just compile it in the same directory.
00:30:14
Speaker
right In practice, that's not what most people do. And you know if you look at any ah node project or any Python project, they're going to have multiple directories for the source code, for the libs, for the vendor modules from Go.
00:30:26
Speaker
you know There's always going be folders. But yeah the way the way people work with ah Spring, usually, is they go to start.spring.io. or go to File, New, and there are IDEs, and that generates a project, and that's already done for you.
00:30:38
Speaker
And so, you know. And why break the conventions? I mean, it's just been there for 20 years. It's a Maven convention. It's not Java, right? Maven is a build tool, and that's just... Even the competing build tools honor that arrangement. It's just... It works. You have a folder for your source code.
00:30:51
Speaker
In that, you have your test and your main code. And by the way, we were... you know, that arrangement assumed that source wasn't the same as main. right This is not novel now, but back then you had a folder for source code, then you had your code.
00:31:06
Speaker
This is 2000. Did you have tests? Well, we're not that hip. We don't do tests. That's a new thing. That's what those weird kids are doing. you know yeah Those agile kids, aren they make no sense. you know like But now we just assume you're going to have tests. yeah I don't take it for granted. I just think it's a really nice. so It's set source main and then source test.
00:31:24
Speaker
Okay, okay. I'll buy that. I'll buy that. You raced through a point I find very interesting, the async await, you don't need it thing. Can you go through that in length for me? so in ah Okay, so... Was it C sharp?
00:31:40
Speaker
I think, or was it JavaScript? when I don't know. I forget. But one of those two languages um wanted to find an easier programming model to describe the composition of asynchronous things. yeah And so I think i let's take take JavaScript, for example. JavaScript was written with one thread mind, the browser thread, the render thread. And and and that limit that, i don't know it's a limitation, that design carried over for Node.
00:32:03
Speaker
right And so when Node came out in 2009 or 2008 or whatever it was, everything was callbacks. yeah And you get these deeply nested callback hierarchies right and people bemoan the situation.
00:32:14
Speaker
And people talked about callback hell as though yeah they lived there. Well, to their endless credit, the JavaScript team ah then stumbled upon the idea of a promise. right and Promises are basically the equivalent of what we have in the reactive community, in the Java community, called a publisher.
00:32:31
Speaker
So in this in this way, a promise, you can say, you know, the thing over here that does some processing returns a promise. which I can then call.then, and in the then I get a context object, which is the result of the previous operation.
00:32:44
Speaker
So instead of having deeply nested, I can just have.then,.then,.then, and just go straight down. yeah which is awesome And you can do filter, you can do map and flat map and all that kind of stuff. right So that's a lot nicer.
00:32:55
Speaker
But still, you're very much dealing with a chain of lazily evaluated things. right These are operations that haven't run yet. you know By the time you get to the end of that line, nothing is run yet. There's a terminal operation that then initiates it, kicks it off. yeah And so that asynchronous sort of component model, that raised that composition model, rather, is tedious. A improvement on callback. Sure. the end game.
00:33:18
Speaker
Not the end game. And in the Java community, we have reactive programming, which does... I would say it's better, but it's the same thing. and there's ah And there's more edges to it, certainly, than in the promises land. right so So then, I don't know, 15 years ago, it was it I think it was JavaScript or C Sharp. One of those two came first.
00:33:37
Speaker
I think it's C sharp, but I'm not sure. It's- I'd be surprised if they stole it from another language from the 70s that we forgot about. That's fair. Okay, so async await. And so here you have a function in the language, you have a function that returns a task as opposed to a promise in C n t sharp. pre You have a task.
00:33:54
Speaker
A task is a task of Boolean or a task of customer task of where T is your generic parameter. And the the language is written in such a way that now the thing that would have otherwise been a promise like a very so fancy future, that promise you can actually now all call await.
00:34:13
Speaker
So you can say auto my result equals await and then call this function that returns a task. yeah And then if you unpack, them if you look at the value that's stored in the my result variable, it's not task of T, it's just T.
00:34:27
Speaker
right Yeah. and that where This is the trick where you say promises are really useful, but they'd be even more useful if we put some syntactic sugar yeah over building and extracting from them Exactly. and um And so i you know i can I can see why that's useful, but in order for to have worked, yeah your function has to be marked with async.
00:34:45
Speaker
So async, and then you return, or it has to return a T, right? either you return Either you call another function which returns an async value, or you or you return a T directly, a task of T directly.
00:34:57
Speaker
um So you're you promulgating this task slash async All down. If you call an async function, you have to be async. Your parent has to be async and so all the way And it creates this chain.
00:35:10
Speaker
And you know what is what is this doing behind the scenes? Well, ah you know imagine i want to read from a network socket. In Java, you say i have an input stream. The input stream represents a yeah perhaps as yet resolved buffer of bytes.
00:35:24
Speaker
and I start reading from the bytes. Well, the network socket is not going to give me all the bytes and instantaneously. It'll give it to me as they become available. So maybe the server's not yet done loading the page, or maybe the network is a chat client, or they're still typing messages. haven't gotten everything they've said because they're still typing. There's realistic understanding what's happening here.
00:35:42
Speaker
But as I wait for those bytes to come back, I call inputstream.read in the JVM. um I'm waiting. I'm stuck. I'm sitting on a thread. yeah and And that thread is ah inaccessible to anybody else in the system. I'm bogarting it for my own use, even though I'm not doing anything besides waiting.
00:35:58
Speaker
The same situation exists in ah C Sharp. It existed in C Sharp. I'd make a call and I'd be sitting on a thread and threads are limited. They're precious resource. they don't They're not infinitely available. yeah So um like this is where you get the task stuff.
00:36:14
Speaker
right okay I'm gonna um'm going to ask for the bytes and as they become available, I'll get a call back. Yeah. Right? So now it's- And some internal scheduler can park that thread elsewhere. Right.
00:36:25
Speaker
and And then so tasks, even before async wait, you have this tasks notion. You're saying, I'm waiting for, call me when you're done. That's it. It's an asynchronous reactive thing as opposed to, a you know it's pushing the data to me as opposed to me pulling it.
00:36:40
Speaker
But the benefit is that whilst I'm waiting, I'm free to continue my thread of execution and move on to another thread or put the current thread back in in the thread pool and then you know while waiting for that thing, there's it'll get resolved asynchronously somewhere else.
00:36:53
Speaker
right And then when it's done, my logic will get run, put on a thread, and run to to handle the results. So that benefit is I'm not sitting on the thread. right But I still have to deal with this asynchronous style programming.
00:37:04
Speaker
right So then here comes async await. Now, I say auto my value equals await this function, they call this function. yeah And then behind the scenes, what's happening is it's rewriting the code so that if you actually put a breakpoint on the thread in which it's executing before you call that function and after you might see that thread name has changed.
00:37:27
Speaker
right So I said, call basically, ah the compiler wraps up the rest of the continuation. It wraps up the rest of the code in that pair in that method in a continuation, and it calls it after the bytes have come back.
00:37:39
Speaker
yeah And it might be running on a different thread by that Very much. Very possible, yeah. And that's nice, because that means that it wasn't stuck on the current thread while you're off waiting for bytes that may never come. If you're waiting for five minutes, last thing you want is for that thread to be unavailable for anybody else in the system, because there's only, again, a precious limited number of threads in the system.
00:37:57
Speaker
So um so that's async await. yeah And the async await hides, it spackles over. this async callback-centric programming model, or this.then-style programming model. yeah um And to be fair to C Sharp and ah Python and JavaScript and TypeScript and... Rust.
00:38:22
Speaker
Rust? Rust does async. Oh, good, finally. Okay. I thought everything was still using just Tokyo. Yeah, it's nice. um So, yeah, like, it finally, this this this approach is ah useful for anything that could take a little time.
00:38:37
Speaker
right yeah Like in theory, you're doing a Fibonacci series and you want to do that in another thread, then you can do a weight. You can weight that, right? yeah fibo Fibonacci series, of course, is just ah its CPU bound.
00:38:49
Speaker
You're not really doing anything. You're still working on a CPU. You just decided to do it in a separate thread, which seems pointless to me. I would just do it in the current thread since it's CPU bound anyway, right? Actually making that slower. But the real use case that most people struggle with is I'm waiting for bytes to come back.
00:39:03
Speaker
That's I.O. That's not CPU bound. That's just idle time. That's like doing thread dot sleep. And sometimes it's locked on a user on the other end. Yeah. Which is almost infinite waiting time. Sure. You've got no control over it. There's no reason to just be sat there stuck on a thread, especially if you're doing anything on the CPU.
00:39:18
Speaker
And if you are doing something on the CPU, you can just use the current thread. Yeah. Right? So Java took a much better approach. They said, OK, what we want to make sure doesn't cost people is io That's where we want that to be non-blocking.
00:39:29
Speaker
that Like, if it's CPU-bound work, then it should be blocking. Otherwise, you're just wasting time switching threads for no gain. You're still going to take time out of the CPU. It's just going to be on a different thread, which means copying the current stack over and moving things around ya pointlessly. pointlessly.
00:39:42
Speaker
So... ah point yeah point of three so um With I.O., if I'm just waiting, that means that thread could be freed up and somebody else could use it, and I've expanded the total availability of the CPU to code in the system, right? Yeah. um So with ja with Java, they said, okay, we have this new mechanism.
00:39:59
Speaker
it's You need to give the runtime a queue, just like with asingle wait, that it's okay to then create a continuation of out of everything that succeeds as blocking operation and then call it when the blocking operations operation is finished.
00:40:12
Speaker
The queue... In this case, the clue, the hint, is the fact that it's running in a virtual thread. It's just a thread. looks exactly like regular threads, java-lang thread. They're both java-lang threads. One's a virtual, one's not.
00:40:23
Speaker
If you're running in a virtual thread, it automatically does this for you. You call a blocking operation. If that blocking operation is thread.sleep or inputstream.read or outputstream.write, it just waits in a different... It it wraps up everything, puts it in a continuation, and calls it once the blocking thing is finished. Do you know how this is working under the hood, such that you don't need to write async await, even though, essentially, you're dealing with the same thing? There's only a few... I mean, again, there's only two or three places where these non-blocking operations... These things should... Anywhere there's I.O.
00:40:54
Speaker
The runtime can detect that you're doing that. It knows what I.O. looks like at the core of the platform. And it has hooks there saying, OK, as soon as these bytes come back, I've got a continuation needs to run. Call it.
00:41:05
Speaker
Is that happening at Java, the language level, or JVM, the virtual machine level? JVM level. There's this new thing called a continuation underneath the hood. Okay. You can actually get to it, I think, but it's but most people will never need to do that, right? and That's why they can detect in only a few places, because the virtual machine doesn't have that many operations. Right, but it's but the only i mean you say only a few places.
00:41:24
Speaker
There's two places, IO and Thread.sleep. and we There's no such thing as a non-blocking Fibonacci series or cryptography. That's CPU bound. It should be on the CPU. If we want to do that, you can put it in a separate thread and run it yourself. Surely the virtual machine has a few different I.O. calls.
00:41:40
Speaker
Sure, but they all go down to the same core. okay there's so there's only At some point, it's native code, so we just trap that hook, basically. So you can get all the... Because what we've always wanted as programmers is the ability to write asynchronous code, but have it look like regular code. yeah And you can get all of that without even function coloring for async away.
00:41:59
Speaker
Right. That's cool. So this is not just as good as those other languages. It's far better. Far better. And this is actually... you know The only other language where I've ever seen this is Go. ah Okay. Go does exactly the same thing, but to be fair to them, they did it 15 years earlier or 13 years earlier, and they didn't have to deal with the backwards compatibility of the existing solution. Yeah.
00:42:19
Speaker
From the get-go... amen You'll be the first person to ever do that joke. From the get-go, they had... ah you know, this this approach, that the the blocking I.O.
00:42:33
Speaker
code that you wrote was actually non-blocking behind the scenes. and So you write very simple imperative programming 101 style, you know, while inputstream.read does not equal negative one, keep reading, right? yeah Like that code is now non-blocking.
00:42:48
Speaker
It just is. you don't have it doesn't You're not dealing with async or not dealing with threads, no futures, no completable tasks, nothing. It just it just is non-blocking. And then Go does that for everything. There is no backwards compatibility to maintain.
00:42:59
Speaker
So Java somehow did it almost as concisely. I mean, you have to create one executor object or one thread pool or something like that. and Whatever factories the thread, you can actually just call a new thread if you want and then set it to be a virtual one.
00:43:12
Speaker
right okay You can say thread.ofvirtual Thread.capital thread.ofvirtual.unstarted and then pass in a runnable. And that'll be the same thing. But if you, most people in most contexts will have ah an executor.
00:43:27
Speaker
So you call executors.newvirtualtaskexecutor or whatever. And you get an executor and then you can submit your runnables to that. Well, it's exactly the same Java Util concurrent runnable you'd use 20 years ago.
00:43:38
Speaker
Yeah, yeah. And so nothing, you just change the definition of that one executor. and everything else that runs on top of that is now in virtual threads. And since most services are IO bound, that's free scale.
00:43:49
Speaker
Yeah, yeah. It's impressive they've managed to retrofit that. I mean, I'm sometimes impressed they've managed to put anything new in Java, but the scale of new jobs. They do it with diligence and care. So again, this Valhalla,
00:44:00
Speaker
is, I mean, why couldn't Java be on on par with SciPy or whatever, NumPy? ah That's the vector API. That's already here. You can try it out, and it's it's good. It's fast, and it's clean and nice.
00:44:11
Speaker
What about Valhalla? Why couldn't Valhalla be used for, you know, like, I mean, Valhalla is like, you don't even need specialized hardware in some cases. You know what I'm saying? Like some, some operations just become way, way cheaper.
00:44:24
Speaker
You know, they've already done tests on like, if you did N times X, X times M or M times n there you go N times M, Nancy times Miami. Miami, yeah, whatever. in Miami right now. Miami, yeah.
00:44:39
Speaker
N times M. I'm trying to pronounce it so you can hear. Why can't I do X times Y? There you go. Iterations. For each of these, then for each of those, do multiplication do some processing.
00:44:51
Speaker
Well, they did I saw Brian Getze talked about it, and he said it was like three or four times faster than than just doing on the JVM already.

Java 24: Virtual Threads and Project Valhalla

00:44:57
Speaker
That's just Valhalla. That's not the specialized vector API. That's not nothing. and think Nothing else. Just using regular Valhalla for free.
00:45:04
Speaker
code that did that before in regular Java just becomes faster. That kind of stuff. yeah And we haven't even gotten to the benefits of like, okay, well now I've got a list of int. right And by the way, another thing that falls out of um having nullability, having primitive types that are values that in non-primitive container types like lists,
00:45:23
Speaker
Another thing that comes out of that is you get... um ah Eventually, you have to answer the question of, well, okay, integers are nullable since they're objects, and all objects can be null. yeah So a list has to support nullability.
00:45:37
Speaker
But what if I have a list of ints? do you do an int that's null? Yeah, because the in primitive types aren't nullable. Right. So if you introduce primitive types, don't you need to account for what that means? What does nullable look like if you into if you have a value point? Is that nullable?
00:45:55
Speaker
Right? So then you get into, OK, well, Java needs nullability specification. right And that's coming as well as part of Project Valhalla. Specification of like how everything is nullable or a specification of, some look, some things aren't nullable and here are the rules.
00:46:09
Speaker
and So normally you say that this is nullable and that's the default. That's the exception. Nullability is exception and not null is the default. But since we're doing it retroactively, everything is nullable and you can annotate with an extra maybe a question mark, an exclamation mark or something like that.
00:46:24
Speaker
They'll have to answer that question of, okay, well, can I make this thing not nullable? So I will finally be able to have like value... Finally is the wrong word because that's a keyword, right? but But I'll at last be able to say this field can never be null. Yeah.
00:46:40
Speaker
I'd take just that. Just that. I mean, that's huge. I'd take in Java. but So that won't even be in the first tranche of support though, sadly. Valhalla will deliver value type first. Then they'll introduce nullability specifications. you know It's all in the sort of like... he's Brian gets to talk about it, right? But all these things are...
00:46:56
Speaker
Again, they all sort of go towards that, if I want to do this correctly, we do it incrementally, we introduce these features piece by piece. And that's what they've done with Java 17 to 21 was, I thought, kind of a masterclass on exactly how to do that. They introduced these little little tasty morsels of of syntax improvements that culminated in Java 21, supporting something called data-oriented programming.
00:47:17
Speaker
I mean, data-oriented programming is the second biggest thing they introduced in Java 21. The first one was virtual threads. Oh, even there, even there, the virtual threads. I'll come back to data-oriented programming. But virtual threads, they introduced virtual threads, and they said, okay, for not for for these blocking operations, you don't have to do reactive programming. You don't have to use Java NIO.
00:47:33
Speaker
You don't have to use Netty. Just use regular input stream and output stream. Things will work. Asterisk. And the asterisk is when you do... If you do inputstream.read outputstream.write or thread.sleep within a synchronized block.
00:47:48
Speaker
So you say in the language, hey, I've got a synchronized... mute I've got semaphore. I've got a lock... on there's no no thread can enter this block. Oh, I haven't thought about this in years. This is Java's feature where you can say this code block is... Exclusive. Exclusive, yeah. yeah And um so that monitor is held by the class... i' Sorry, it's held by the thread on which the code is running, right? right Well, that thread used to be a C construct behind the scenes. The JVM has a C type that holds the me meta for the monitor, and that was bound to the current operating system thread.
00:48:21
Speaker
right Now you've got two kinds of threads in Java, again, virtual threads, which are green threads or fibers. And by the way, those are not backed by anything in the operating system. So you can create millions of regular virtual threads, you know, millions and millions on the same, on a regular poultry JVM, no problem.
00:48:35
Speaker
right yeah And they will get mounted onto to carrier threads to get a chance to run. Those carrier threads correspond more or less to operating system threads that we saw before. And those are still there, they're just slower and less scalable.
00:48:46
Speaker
So now you've got these virtual threads, and they are not mapped till to the C code for the thread, and they don't have their own monitor. So how do you get the exclusive log? Well, so for Java 21, they couldn't do it correctly in time.
00:49:01
Speaker
So they introduced something called thread pinning. Basically, if they detect that you're doing a synchronized lock around a blocking operation that would have otherwise been made non-blocking in a virtual thread, they'll just pin you to the current thread. So you get none of the benefits of virtual threads.
00:49:14
Speaker
Right. i Which is fine. That means that nothing breaks. Everything that has ever worked still works. Everyone gets to move forward and things don't get worse. They might get better. So they had to refactor the gnarly and very, very, you know, messing with semaphores and memory and C code is not my idea of a good time.
00:49:30
Speaker
So they reworked that. That's fixed now in Java 24. So you can do, and by the way, think about what that means, by the way. I said you can't do synchronized around a blocking operation.
00:49:42
Speaker
When would you do synchronized, like, when would you want to monitor so that you can then read memory from another web server?
00:49:49
Speaker
ah It makes no sense, right? like You wouldn't do that anyway. But if you did, that would have broken. Yeah. you wouldn't like syn Synchronization on the current thread and the current JVM um doesn't mean the state over there somehow exclusive. That's nonsense. you'd I'd do the IO somewhere first. And then when i read in a hot path in my current JVM, when I got had to ensure that I'm mutating one little thing and it had to be within a synchronized block, I'd do that there. I wouldn't do input stream.read.
00:50:13
Speaker
right Yeah, that makes more sense. So it wasn't a it was a bug, but they made it so that it didn't affect people, it didn't hurt them, it just degraded the behavior to what we had before. yeah And then it was a weird one. you wouldn't hit it If you were writing your code with any sensible approach, you would have hidden it in the first place because most people don't do IO inside of a synchronized block. and That makes no sense. yeah And then even if you did do that nons and that nonsensical synical thing, it's fixed now in Java 24, which is GA and already out for months.
00:50:39
Speaker
How did they fix it? They just rewrote the code so that the c code now has a monitor that's moved up ah level to the ah virtual thread or to the um operating system thread. okay OK. That's all. It was just gnarly C code. They knew how to do it. They just didn't want to like take big swings of that, making sure they did yeah proceeded very, very carefully because memory models across c run times or not run times, languages, platforms are different, you know.
00:51:02
Speaker
So that's fixed. So there's one more asterisk. But again, between those two things, I i reckon like 99.99% of all people that are ever going to use threads will get benefits now out of virtual threads for free. You just upgrade and set that.
00:51:15
Speaker
By the way, I mentioned using executors. so But and if you're using Spring, you just set the property, spring.threads.virtual.enabled equals true, when you're done. And then we'll set the executor up for you. So again, we're talking one property, and you get really good scale.
00:51:28
Speaker
Okay, so the third and final case where you might have some issues is ah in class, if you do native code. So if I call into JNI, like we talked about earlier, yeah I have a Java code, and I'm in ah i'm going to call native code, and but I'm doing so on a virtual thread.
00:51:46
Speaker
Well, that native code causes thread pinning, right? yeah Even though it's a blocking operation, even though it's taking time on the CPU, or taking time but not using the CPU, right? um And so they still pin on that.
00:51:59
Speaker
So unless you're, like, that's not going to affect most people, but it will affect some, and the reason I say that class.forename. The thing used to reflectively create an instance of a class that requires some native code, and ah apparently that's still affected.
00:52:12
Speaker
okay But again, most people aren't doing that kind of goofy low-level metaprogramming, certainly not in the context of a you know You would do that once, one assumes not every time you process a request coming in. you know yeah kind of so This makes me wonder, unless you're about to go somewhere else. Somewhere else, so finish with thought, yeah. I'm just wondering how much of the innovation you think is happening in the Java world is at the language level and how much is at the virtual machine level? That's what saying.
00:52:41
Speaker
The language level is great and I live for that, but... The real crown jewel, the reason that there's been 30 years of innovation and I reckon, i don't know, nobody's ever showed me anything, but just do the math, right? We've got Sun and then Oracle. And by the Oracle has been this shepherd and steward and the care feeder for Java for a lot longer than Sun has at this point. Yeah. right and they've done a fantastic job.
00:53:01
Speaker
I mean, there's how many different companies, how many thousands and thousands of full-time people thinking about this stuff all year from all around the planet, Alibaba, from IBM, from Oracle, from ah even people on at Broadcom, we we help send ideas and we interface with the ah Java team. I mean, all around the world.
00:53:20
Speaker
ah How many billions of dollars do you think that human power is worth. I don't know that there's anything else that has anything close to that. And it's at such a professional level too. I mean, Linux is the only thing I can think of where that many people from so many different contingencies have come to bear on one particular problem for so long.
00:53:38
Speaker
Yeah, yeah. I wouldn't be surprised if by sheer numbers, Java's larger too. then There are more Java programmers than there are people who've ever contributed to Linux. Oh, well, sure. Yeah. yeah If only because they bear to entry so much lower, you know?
00:53:50
Speaker
Yeah. And that's not just a... That's not just a slighted line as Torvald. The technical barrier to entry of writing C code fit for the kernel versus writing code that can be used in a Java context is different.

Java in Large Organizations and AI Integration

00:54:04
Speaker
so All that I'm trying to say is that that's an amazing, amazing piece of kit. You can make fun of the Java, the works of the Java syntax all you want, but never, ever, ever doubt that there are that the reason people who have choices, right, the largest organizations on the world in the world have choices, and most of them use Java at scale.
00:54:22
Speaker
There's a reason for that, right? Every single one of them, except for even Facebook, their data processing pipeline. They did their worst thing. they ah They made the mistake of using PHP. Then, rather than admitting their mistake, they doubled down and decided to turn PHP into their own bespoke, you know, have you know bug-ridden, half-implemented version of Java called Hack, aptly named.
00:54:42
Speaker
right um But everybody else just said, no, I'm using the JVM. This is bulletproof rocket-sauce software. I'll use that. It'll get me to production. And it did. You know, there's a reason. Yeah. And ah you've you've thrown me off thinking about PHP now. Data-oriented programming.
00:54:57
Speaker
Yes, yes, of course. We're going to talk about That was a Java 17 to Java 21. They introduced a bunch of small things. What does data-oriented programming mean to a Java programmer? I wonder. I'm actually keen on knowing what it means to everybody else too, because for what the way it's been explained to me as a JVM developer was sort of ah the Java, the language, the they the arena of a server-side application today has changed.
00:55:21
Speaker
Increasingly, the messages that we send into and re and send from services are the way we express changes in the system rather than introducing new deeply-seated hierarchies of abstract types.
00:55:32
Speaker
right So if i want to change something, if want to communicate from one part of the system to another that something should change, I don't create a new implementation of something. I i send a message. via via REST, via RabbitMQ, Kafka, GRPC, Rsocket, whatever, GraphQL, they're all messages, right? Data has become the language of communication yeah rather than invocation. Exactly.
00:55:51
Speaker
and And so the language has to be more adroit there. It has to be more elegant, more concise. And so there's a number of things that make that experience just better, right? ah Pattern matching.
00:56:03
Speaker
yeah Smart switch expression so you can do, like, ah like in you can match on types in a deep... Structural way. you You only used to be able to switch on numbers and strings or something. you can We finally moved away from that. Yeah, you can well's you can switch on... Yeah, I think you can, yeah.
00:56:21
Speaker
But you can also... Yes, you can, because you also you can also do pattern matching there. So I can actually say not just that in case this is a ah a shopping cart, but i I can actually say this is a shopping cart with a customer inside of it.
00:56:35
Speaker
I match the pattern of the thing and I can extract out that result yeah yeah in the block. so So there's that smart switch expressions, pattern matching, um
00:56:46
Speaker
sealed hierarchies, which allow... Sealed hierarchies. Yeah, it's ah it's a way of... It's a new, more granular visibility, not visible, protective modifier. So I can say this type, you know, imagine I'm working in a highly regulate stated regulated financial services context.
00:57:01
Speaker
Yep. You don't want Sam Bank-Ben Fried coming along creating a new loan in implementation that has no-op, that does no validation for where the transfer is going, right? Yeah. but You want... There's going to be secured loan, unsecured loan. Those are the only two implementations in this whole code base, and the compiler should bark if that is ever not true.
00:57:17
Speaker
Okay. Right? That allows me... that loves First of all, that allows the compiler and the runtime to not have to worry about... undetermined as yet unknown polymorphic subtypes that it has to worry about dispatching to.
00:57:32
Speaker
But second of all, um you know I can be sure that if something somebody violates that premise, then the compiler will bark. What are we saying? That you can mark classes as closed for extension? Yeah.
00:57:45
Speaker
I can say this type, I can say this is the interface, and I only permit the following subtypes. So the interface will define who's allowed to use it? Well, it's not the interface, the actual but abstract class, but yes.
00:57:55
Speaker
Okay. Or the supertype, yeah, the the parent type is the thing that de delineates, it it it ah it permits the subtypes. That's an interesting thought. I don't think I've encountered that in another language. It's interesting. i reckon you can get yeah you know Other languages have the ability to seal them see all the types. We get the same sort of effect.
00:58:13
Speaker
It's roundabout way of doing it. and i And the benefit is that it it's it's a one of those rare instances like virtual threads ah where the result is better for your runtime efficiency and less code.
00:58:26
Speaker
just you It's so nice. when That's the benefit of using a runtime language like Java. You just... You upgrade to new Java, you get better performance. That's rare. You know you don't normally can't upgrade to a new thing and and just get free performance gains that you can tell management about.
00:58:41
Speaker
Look what I did. Yeah, yeah. I saved 10% off of our RAM budget, or I saved 15% off of our scalability budget, or whatever. made it faster. Occasionally, but usually it goes, like if we make things fast, they look worse and they're hard to maintain.
00:58:53
Speaker
Very rare. And we got we get we're getting a lot of those right now in Java. So Valhalla will be one of those things where I just paint my code with a value keyword. I'm like, and measurably large gains there.
00:59:05
Speaker
Virtual threads. Again, I showed LLM stuff in my... Yes, yes. Let's talk about, ah because Java's making a move on the a one i AI world. Yeah. I think it's ours to take. I think i think there's a Look, I mean, 90% of organizations out there have software and Java. you know ah it's And I'll bet a lot of these organizations, especially who are... and We're at a Modern's Code Remix conference here.
00:59:30
Speaker
These are all large... You've talked to some of these people, right? Large organizations, financial services, governments, insurance companies, media, startups too. But my point is everybody. They're all using Java at scale. And the the reason is because it works and it's a steady hand.
00:59:45
Speaker
But... That's where your business logic is. That's where so many people have their... The business logic, it's where so many people have their data. you know It's not in the code proper, but it's being guarded by services it written in the code. And that's where you want that's where ah one imagines it would be most most useful to hang off these AI integrations, right?
01:00:02
Speaker
To expose as agents these services, right? Or to expose as MCP services these services. But does... I mean... Yes, I totally agree that if you've got lots of Java already and everyone's jumping into AI, of course, you're going to want some kind of support.
01:00:16
Speaker
But are there Java or JVM specific things? Or are you saying there's a lot of libraries being built? What do you mean? so Are we saying that somehow the language Java is changing to adopt AI, or are we saying the tool, like things like Spring, are you saying that Spring is investing heavily on those utilities that will The answer is both And that's, I mean, the first half hour this conversation is all about those changes that will serve us better.
01:00:43
Speaker
So for the moment, Java's strength is in integrating existing LLMs, which since most LLMs just have a REST API, isn't hard. yeah And is Java's got, I mean, say well what you will about Java, but we can do integration like nobody else. right That's the bread and butter of every Java program ever written is the glue code.
01:01:04
Speaker
Pulling together all these different siloed data sources and syncs and and all that stuff. So this is just more of that. this is where we This is why ah the largest microservice systems are all in Java. right If you want to build REST APIs and services and all that, they're Java.
01:01:17
Speaker
So OK, fine. Now we got more of that. but I would also argue that the language proper, again, Valhalla and the vector API, these things will make Java more suitable ah for the other side, which is i want to train a model.
01:01:29
Speaker
You think we'll actually be training models in not C or Python, but Java? Why not? what It would be more performant to do so in Java. There's already even LLM, what is it, LLM3 or something like that? There's actually an LLM you can use to completely run in Java and it compiles to a Gravium native image. It's a single source code file.
01:01:45
Speaker
right We have to talk about Graal to import Vita. Yeah. And that that native image is, you can run a model faster than you would with the like a llama. It's already there. That's not a question. That's today. and by the way By the way, that's using the preview feature for Vector APIs.
01:01:59
Speaker
Okay. And GraalVM, right? Now. So now, fast forward a few years, here comes Valhalla. We're talking about really interesting opportunities here. I don't know why it wouldn't be that way.
01:02:09
Speaker
And it's not hard to, you know, the nice thing about the AI is that you can dump in the source code from Python and have it generate the Java.
01:02:17
Speaker
and they the tools get the The AI gave us it gave us the tools to translate our own way out of it. you know it's like it That sounds like is betraying its roots. Yeah, well, a little bit. That's okay. yeah so Or we can extend from it because, again, we have a easy integration with these native libraries as well with Project Panama.
01:02:34
Speaker
Either way, this world is is something in which we can all part to partake in. I think Java is really well situated. Okay. almost twice scalability way so efficiency-wise, integration-wise.
01:02:44
Speaker
Okay, I buy that. then Then tell me something, because your day job is working for Spring. I love Spring, yeah. Tell me something about the way Spring is evolving too, um starting with AI, but... Oh, okay.
01:02:55
Speaker
um ah Your check is in the mail. Thank you for that. ah No, so ah twenty May 2025, we'll have Spring AI 1.0. Spring AI is this engineing this this umbrella project that we built.
01:03:07
Speaker
And we set about in 2023. I don't know. It's been a long time running and coming. And that's because ah you might have noticed the the AI people won't sit still. Just tell them to shut up and sit still for a week and we'll be okay.
01:03:20
Speaker
But it's finally going GA after so many years of um iterations. right ah We're all very excited. It's been used already. it's and People are using it out there. But it's just not GA. It's not 1.0 yet.
01:03:32
Speaker
It's always been our you know milestones and snapshots and whatever. and like For example, we were last November, ah the Most of us on the planet were just sitting there enjoying our November.
01:03:44
Speaker
Some of us were enjoying Turkey, right? Not Anthropic. Anthropic, one one assumes they had their Turkey too.

MCP Protocol and Java SDK for Enhanced Integrations

01:03:51
Speaker
I don't know, whatever. But the point is, Anthropic also released this new protocol called MCP, Model Context Protocol. Yes.
01:03:57
Speaker
Model context protocol, you might have noticed, is ah just everywhere. There's all sorts of MCP implementations. It's a protocol that you can that models can use to reach out and talk to tools. And when I say tools, I mean utilities.
01:04:08
Speaker
Is it fair to say this, you were saying like calling an LLM is probably just REST. Is it fair to say that MCP is like a proper formal REST spec? but for mo it's um but But it's less of a spec.
01:04:20
Speaker
The magic here is that the model, the LLM itself is the thing that invokes the MCP service. And so you don't need a schema for that. You don't need the WSTL. You don't need ah j you know j ah JSON API. You don't need... Soap.
01:04:35
Speaker
Soap. Yeah, that's WSTL, right? don't need any of this nonsense. The model knows what the shape of a thing looks like if you just tell it, right? And you export the signature. so So we were really intrigued by this specification. And it's become, again, there's thousands, tens of thousands of MCP services.
01:04:51
Speaker
There's MCP services you can use to, like, run Blender. 3D and render scenes and do music synthesis and other apps and there's there's integrations for every platform out there. are All the hyperscalers, all your ah platforms and services, all your... i mean, even GitHub and Microsoft separately and Office 365, they all have MCP services, right?
01:05:09
Speaker
There's MCP services for everything that's not already here. That's already here. It's already out there, right? yeah And so the idea is you point your... AI model, and it's not just Anthropic. Though they innovated and created the spec, it's become a thing that all these different vendors have announced support for, including OpenAI just a month or two ago. They said ChatGPT will support these as well.
01:05:28
Speaker
um And so now you can you can make you can give your model the chat box, whatever model it is, be it ChatGPT or Cloud Desktop or Gemini or whatever. One imagines all these things will eventually support MCP services. You can say, hey, you i want you to have access to this MCP service, this one, and this one, and this one.
01:05:46
Speaker
Now you go to your chat model and say, hey, look, ah how's my we have an MCB service for Spring Batch, for example. but You can say, okay, how far along are my Spring Batch jobs? Great. Okay. And you can say, oh well, it looks like it's not going fast enough.
01:05:58
Speaker
Deploy a new instance on my my cloud platform. this so Star Trek. So in one sense, this is like um integrating retrieval augmented generation.
01:06:09
Speaker
into the model in that the model isn't just baked once and that's it. You can now add in connectivity to other things. RAG does that. RAG extends the data set, but this is tools. This is verbs, not data, not nouns. This the ability to say, and go and do something. yeah Yeah. And you have executive command, right?
01:06:26
Speaker
And obviously, it'll be up to you to add these tools to the model of your choosing. right you know We're not going to give it root level access to your hard disk if you don't want it, right? um but But the point is, you have this capability now.
01:06:38
Speaker
And you can bake it into applications. and so from So we were so intrigued by the specification that we went out and built a Java SDK. which was so early and so good that it it became the first it became the official Java SDK for MCP.
01:06:50
Speaker
So you go to modelcontextprotocol.io, which is the website for the project from Anthropic and the you know the group around that. yeah Ours is the official Java SDK. so So the spring one. Yeah, well, it's it doesn't, so we refactored the code, so it doesn't say anything about Spring. It's just a generic Java only SDK. Right.
01:07:06
Speaker
Then in Spring AI, we re we provided integrations rebasing on top of this new, now extracted Java SDK. Right. So you can use it. directly if you like, but I don't know why you would. You can use... But in theory, the if you're using um ah the MCP support from any other technology, it'll be using our core SDK support, right? um We're not forcing people to use Spring AI, but why wouldn't you?
01:07:30
Speaker
right This is tricky in a podcast because you don't get any slides. That's okay. I don't do it. Just... see slides? No. But just give me give me a sense of what that looks like to me writing Java.
01:07:40
Speaker
How I... What is it that I have to do to say, and connecting this model and ah write this MCP server together in my web app that I'm writing? or So, okay, on the server side, i want to export tools. What are tools? They're methods.
01:07:56
Speaker
They're functions, right? That's the only... name It's like RPC. So I have to export some tools, and you just to annotate those methods with at tool, provide a human language description. It's literally description equals, and then this function does A, B, and C so that I can do it x y Z, whatever. right And you annotate the parameters to that function with tool param.
01:08:14
Speaker
okay ah You'll define one bean, assuming, by the way, you've got the Spring AI starter for MCP server on there on the class path, and you've got the web server there. So I do the DOMS of JAWS.
01:08:25
Speaker
Well, you just go to start.spring.io, choose two checkboxes, hit Enter, and you're done. like Then you're in the Java code. i've got these I've got a class with some methods I've annotated with addTool and addToolParam.
01:08:36
Speaker
I need to create one object of type methodToolCallbackProvider. And all that does is you give it a pointer to the objects that you want to export. Because you might have 10 tools, but you only want to export three for now or whatever. So it's up to you to decide which of those things you've described should be exported.
01:08:51
Speaker
Start the program, you're done. Now, you're in the client, you're in another service, you're in an AI chat box. and Well, actually, at this point, you might already be done, actually. That might be it. You might... thought there If you're talking to a... um like an IDE, like Cursor C-Line and all these things, lot of them have MCP support, right?
01:09:10
Speaker
So you can just point them to these services and say, hey, these are tools you can use when you're helping people do editing code or whatever, right? Right, yeah, yeah. Okay. um But if you want to integrate that tool into your AI system,
01:09:22
Speaker
code that you've written that's using a chat client, right? You can do that as well. So now imagine you're the client. you're not It's not a cloud desktop or a chat GPT desktop or a cursor or a CLine whatever.
01:09:34
Speaker
It's some other thing. You're building your own client, which is maybe just another backend service on your system and your in your website, right? um And that's Spring AI powered. It's Spring Boot and it's got some Spring AI starters. okay There, you've got the Spring AI chat client, which is your fluid DSL thing that allows you to talk to the back-end ah you know model that you've auto-configured.
01:09:55
Speaker
right You can then tell that chat client when you make a call that because it'll call the model for you and you can tell that model, hey, for your consideration, I've got the following tools available to me.
01:10:09
Speaker
So you point it when you make that call to an MCP client, yeah which has been in turn configured to point to the host and port on which you were running that MCP server. So that in practice, that's just one extra line from your regular Spring AI chat client use case.
01:10:25
Speaker
right And you might write the bean definition for the MCP sync client. That could be three lines of code. And to be clear, is it the fact that I've written sensible, useful English prose on my and on my function API yeah that means that the LLM will know this is worth calling now?
01:10:42
Speaker
It has some sense of the shape of the method. It knows about the parameters and the and all that. But yeah, that human language text is how it reasons as to whether it should call this in this particular context. That's actually really cool. Very cool. And we have multi-lined strings in Java, so there's no reason you couldn't put whole paragraphs in there. you know The luxury.
01:10:58
Speaker
Yeah, yeah. Or you could actually point it to a resource file, which is just just a file. Yeah. right So, i mean, you have options. you know That sounds like a lot of fun to play with. It is. i mean, it is... I'm drunk with power now because but I'm 41 and I started, you know ah and don't want to even think about it, but when I started working, we all talked about SOA.
01:11:18
Speaker
right And we all talked about SOA. We talked about service-oriented architecture. I'm going to build services with SOAP and going to have this WSTL schema and I'm going to make directories using UDDI to discover this schema. and it just became this harassed. I'm doing document literal versus RPC SOAP or whatever. i mean just on and on and your life building up the protocols and never getting the benefit. Yeah, you just spent more time doing the glue than actually leveraging the the thing that was glued, you know? and um And so people very quickly became sick of it. And then eventually, five, 10 years later, here comes microservices.
01:11:52
Speaker
And now microservices was driven mercifully, not by tech. It was not driven by this need to do not repeat yourself, right? So it was all about, hey, wouldn't be nice if I could reuse a thing over the network?
01:12:05
Speaker
Right? There was no political statement there. was just, I don't want to have to write the same code twice, and that that code happens to live on another computer. yeah That's it. It's a technical discussion. Here comes microservices, and microservices are very much... It's like REST will do, because it's not about... you know It didn't actually do, as we found out. they People ended up building ah hypermedia.
01:12:26
Speaker
And... ah you know ah open API and specs like that to plug in the considerable gaps in just plain rest. but um But it was all about organizations ah and all that.
01:12:39
Speaker
But I still remember the halcyon days where we all dreamt that, okay, we're going to have all these web services and we can just start pulling them in, like like like importing modules in ah in in a JDK, yeah right?
01:12:50
Speaker
I could just import this actual computer service and I'd start using it and I'd be able to add... And it would just be this tapestry of services that are available and I could just start pulling them in, right? Yeah. And that was the whole... but You know, that was the...
01:13:03
Speaker
Kool-Aid that they were selling with distributed comm and Windows and EJV in the Java case is use use space use case, right? And use and user space. um And none of it really panned out because the integration became so painful.
01:13:14
Speaker
right The whole thing was it was meant to be like, oh, well, we can trust the computer to be reliable and available. And and of course, that's never true. yeah um And so even if you got past the fundamental friction associated with just associated associated with distributed computing, you still have to deal with how do I glue?
01:13:31
Speaker
you know And now, I don't need to do all that much. The model can reason for me. I can point it at a thing and say, here's a function, here's a description. If that looks like it can do what it needs to do for you, it'll figure out what parameters for my context and my query need to be passed into the parameter list.
01:13:47
Speaker
There's no mapping required for me here. And i so I have to ask, you said we've been sold this dream before. Do you actually see it panning out in reality? Yeah, ah because it's already there, right? I mean, been using that.
01:13:59
Speaker
Yeah. know Well, not just me, though. That's the thing. Like, um there's almost every experience, including open AI. every experience I can think of has now added support for tools, right? MCP is the most common standard, and I think the only one that wasn't using it was OpenAI, and they announced it like a month or two ago. right right So yes, I think that's going to be, and I think it's going to change, like five years ago, if you'd asked me what the MVP for any given service launched would have been, I'd say you got to have a web browser experience.
01:14:29
Speaker
one that works in a desktop and phone, mobile. You've got to have an Android app and an iPhone app, but right? yeah yeah In a pinch, I would have said just the iPhone app. Now I think, realistically, you should have a chat experience. you know like i And I'm not saying we're all done yet.
01:14:44
Speaker
There's still, unfortunately, um some gaps. So the trick will be to preserve the simplicity of the current state of things with MCP whilst plugging those holes, whilst also...
01:15:00
Speaker
evading or avoiding the complexity pitfalls that we saw with ws star from 25 years ago. Yeah. When was that? Yeah. So, and I like, for example, security, what's that look like?
01:15:14
Speaker
So a simple answer is just use an OAuth. Well, the the people behind the spec released a draft a couple of months ago that sent the internet into a tizzy because the spec proposed that everything use OAuth.
01:15:27
Speaker
um That is to say, every MCP service be an OAuth server. So remember, ol when I say OAuth servers, I mean ah thing that produces tokens that if you have that token, identifies you as acting on behalf of yeah Josh or Jane or whoever, right? yeah So that token is lightweight. You carry the token.
01:15:47
Speaker
It's a short-term credential. right You can throw that credential away you can even leak it and you can just it can be revoked centrally. yeah And with the token, you never usually have the ability to like lock somebody out of their own account.
01:15:59
Speaker
right yeah So you want something to identify the user by letting them log in and something to provide those tokens. And then something that when it sees a token can validate that that token is actually ah valid when it belongs to Josh and he or she or whoever said that it's valid and it was good as of five minutes ago and bla blah, blah, blah.
01:16:15
Speaker
On the surface of it, it seems quite sensible to build that into MCP. Well, I think OAuth is a good fit, but to understand why ah what I'm talking about doesn't fit, OAuth is the identity provider.
01:16:27
Speaker
It's the thing that it does all the hard work. It validates that a user is who they say they are. It issues tokens and it validates tokens that it sees. what are What are some examples of an OAuth identity provider in the wild?
01:16:41
Speaker
Okta, Keycloak, AltZero, Facebook, Google, GitHub. all of You can sign in with Google. You click on the button, it redirects you to Google.com. They are your identity provider.
01:16:52
Speaker
Yes. So what you're saying is we don't want to have to set up brand new identities. No, for every single entity service. No, that's insane. So instead, finally, after... you know and they're They're responsive to feedback and now that's why I love things like that. They're scrappy, they're willing to change, they they are changing very quickly and it's getting better by the day and you can see it. One other thing was... um And by the way, we have the Spring Auth server in the Spring team.
01:17:16
Speaker
The Spring Auth server is you go to start.spring.io, choose Auth server, hit Enter, and now you have an embedded authorization server. Arguably, the only group, I don't know any other community that has a full OAuth IDP that you can add to your build by just adding a library, right?
01:17:30
Speaker
So arguably, the only group that could have actually done that horrible spec was us. And we still push back very, very mightily against it, right? We didn't want that at all, right? But um so that's been fixed. that that Now they're saying, okay, no, no, no, each MCP server should be a resource server.
01:17:43
Speaker
right That's more a more natural fit, like a REST API that's protected by these tokens. Yeah, that makes sense. With a filter. And then what was the other thing? You mentioned something a second ago. Oh, i mentioned they added another another feature.
01:17:57
Speaker
In the original draft of the spec, it's a stateful, long-lived server-side streaming connection, service and event stream connection. Okay. Well, what happens if the person goes through a tunnel and the Wi-Fi cuts out or the signal cuts out?
01:18:09
Speaker
Do you have to... where you can do you start from the beginning? Well, yeah. Yeah, right? There's no resumption. So they just added to the spec a token for session resumption. So can pick off, like, pick up from where you left off.
01:18:23
Speaker
I'm slightly surprised that wasn't in there from the beginning. But but again, simplicity is prevalent here, right? Yeah. and Which I appreciate. I'd rather ah deal in terms of flawed but simple ideas that we can then refine.
01:18:36
Speaker
you know And if it's flawed and simple, least we can figure it out quickly. We can see it. yeah As opposed to just trying to build for everything and every use case. And in fact, the original draft of the spec, the first implementation of it wasn't even HTTP.
01:18:49
Speaker
It was just standard in, standard out on the same host. Oh, really? Yeah. So Cloud Desktop, until recently, I don't think they even supported HTTP. a The idea was that had have other things running ah in process on a process on your same machine.
01:19:01
Speaker
The idea was that you'd wield these things from Cloud Desktop.

Spring AI and Future Java Releases

01:19:04
Speaker
Right, yeah. You'd point them to, you'd have a JSON config file that ran, that that you, in the JSON config file, you would point it to a binary that if Cloud Desktop ran the binary, would speak the standard in, standard out protocol.
01:19:16
Speaker
to cloud desktop. that's why I mentioned the music synthesizer and the 3D, Blender 3D. Those are running on the same machine when it's homes. Yeah. Not over HTTP. That's... I can see the assumption, but actually just going over the network gives you far more options. Well, for for enterprise, certainly. Yeah. Like for services, right? So now both are supported. You can use Spring AI to build both in either and it's very natural, you know?
01:19:37
Speaker
Okay. Yeah. I'm fan. Bright future. I know you have to go and grab a plane. do. So i'm going to ask you one more question, um just specifically for the future. what What else that we haven't talked about is coming in the pipeline, perhaps in the distant future that you're excited about?
01:19:54
Speaker
Oh boy. I mean, how distant? Can I talk about November? You can go all the way into November. November we're going to be talking about, we'll have Spring Framework 7 and Spring Boot 4, which are new baselines, new upgrades, lots of nice and new features. Tell me quickly, what's new to say in the world of Spring?
01:20:14
Speaker
ah Well, again, Spring AIGI, Spring AI1.0 GA coming out in 20 May, 2025. So if you're listening to this in the far flung future with our flying cars, tell me how we get there.
01:20:24
Speaker
ah And yeah, by that point, hopefully Spring Framework 7. and Spring Boot 4 will long be in the rearview mirror. But it's coming up. It's not here yet. It'll be here later this year.
01:20:36
Speaker
We're going to have... um There's lots of like nice projects that are going to become ga and become ah that'll be built against that and that I think will be sort of better for their their existence. So Spring AI will, of course, support these new baselines.
01:20:49
Speaker
ah Spring GRPC is a new project. we've We've had so many great community-run GRPC projects that the Spring team proper never felt the need to build one. But those have kind of stagnated. and they never none of them Because of the way the ProTalks GRPC compiler works, you end up doing code generation. And it's always felt like it's just not very idiomatic spring. People write Java code.
01:21:08
Speaker
They write plain old Java objects, POJOs. right These are just objects with methods. yeah And the the assumption is that you can map those methods to invocations of HTTP endpoint or socket or a GraphQL or whatever.
01:21:22
Speaker
So for GRPC, it's sort of... you know and very much against the grain there. you're You're forced to deal with the generated code. yeah And so that's gotten a lot easier. We're working on a component model that's sort of early days yet, that you can already use it for everything that the existing projects in the community did.
01:21:38
Speaker
And it's been updated, and it's got a good security support and observability, and it works with GraalVM Native Images and all that. So it's already a better fit than a lot of the existing community options. but What you're saying is you think Java's going to take the crown from certain other fields that we're excited about now and keep the interop integration crown that it's had for a while?
01:21:58
Speaker
ah Yeah. I think it's already taken a lot of that. you know i don't think it's a matter like I don't think there's all that much to go. I think what people have been complaining about was the ceremony. Your lament is not...
01:22:12
Speaker
you're not your lament is not ah Unheard of, right? We've heard this before. No, no, I'm not. ah So a lot of that has been reduced. And you'll you know people who are patient will realize that the ah occasional ort, the occasional bump in the road far out, are far outstripped by ah the immeasurable benefits of the platform, the community, the technologies, the richness of the ecosystem, and the and performance, security, and observability benefits you get there, right? Okay. It's just ah it's a really interesting time to be a Java and Spring developer, I think.
01:22:44
Speaker
I'm down in the Rust mines the moment. When I come out, I promise I will update myself. Rust is one of the few places where I don't know that they're... I think they're going to swim in parallel paths. And, you know, again, I don't think you'd ever use Spring to build a kernel extension, but you could definitely use Rust, right? Yeah. I like Rust. Good stuff.
01:23:00
Speaker
Yeah. Cool. Josh, thank you very much. but Appreciate you. Fascinating. Cheers. Bye, everybody. Thank you, Josh. And I'm now officially looking for an excuse to write something new in Java.
01:23:12
Speaker
That's not a sentence I was ever expecting myself to utter. But that's good. I take this as a good sign. The whole point of this podcast is to learn new and unexpected things.
01:23:23
Speaker
So, Josh, you did it. Thank you. As ever, you'll find links in the show notes if you want to follow up on any of those threads, virtual or otherwise. And this seems like the right moment for me to take a brief pause and say thank you to Modern and Open Rewrite for being our hosts for that conversation and some of the other conversations coming in the next few months, and for their long-time support on Patreon.
01:23:46
Speaker
I really appreciate it. It helps keep the podcast going. So thank you. All the best companies support Developer Voices on Patreon, or will soon, I'm sure.
01:23:57
Speaker
If you want to support us, Patreon's a great way to do it. Telling your boss to support us on Patreon is another great way to do it. Link in the show notes. But just clicking like if you've liked this episode, or share if you want to tell a friend. That's enough.
01:24:12
Speaker
For now, I've been your host, Chris Jenkins. This has been Developer Voices with Josh Long. Thanks for listening.