r/java • u/rieckpil • Aug 02 '22
Bright future to Java devs ahead 🚀
https://www.youtube.com/watch?v=2nOj8MKHvmw7
13
6
u/Adyel Aug 02 '22
Somewhat offtopic. I tried to post this a few hours ago, but I could not post it for some reason. The video was auto-blocked. Did anyone face a similar issue?
8
u/BlueGoliath Aug 02 '22
Reddit seems to be shadowbanning people from posting links. You can do a text post though.
3
Aug 04 '22
Shadowbanning is really annoying. Seems as if Reddit lost the courage to tell people they are banned directly.
6
3
u/PartOfTheBotnet Aug 03 '22
If you create your own sub and post with an alt you can see how the different tiers of "automatic spam detection" work.
I have it on the lowest setting on /r/javafx. And it blocks things like linkedin, most blog-spammy wordpress sites, service ads, etc. But it also blocks youtube and github links from time to time (Even if made in a text post).
On other subs if I ever reply with a link in my post I view the comments incognito to ensure it doesn't get hidden. Its really annoying.
12
u/Iryanus Aug 02 '22
Looking forward to it, but currently we are using Akka, which also allows a huge load of actors working at the same time with only a few real threads underneath it - and Akka offers a cleaner programming model than threads, to be honest.
18
Aug 02 '22 edited Aug 02 '22
Completely agree, a ton of scenarios feel much more natural with actors than with threads. Besides, Akka and Loom have always sounded perfectly compatible to me, if I had to guess the biggest impact of Loom would be the introduction of a virtual thread dispatcher for blocking calls to replace the fixed thread pool one.
Not to mention all the Akka libraries that make developing distributed systems easier that have nothing to do with Loom.
Edit: The amount of downvotes is ridiculous :shockedpikachu:
2
u/Iryanus Aug 03 '22
Yeah, it will probably take a while until we have a version of Akka that uses virtual threads under the hood, but I'm also looking forward to that, combining the Akka programming model with the low-level virtual threads for even better performance sounds really promising. (Also the votes seem to have evened out, no clue what some people were reading there.)
6
u/t_j_l_ Aug 03 '22
I totally agree, I regularly use both Akka and standard Java threading depending on the service, and I find the Akka model is much simpler to conceptualize, and is biased towards safety of shared state.
No idea why you're getting downvoted, that seems very reactive to me ;)
-13
u/kkjk00 Aug 02 '22
please stop spreading non-sense, the whole reactive model can't die soon enough, to me feels like scrum, pump-up up but course sellers and consultants, the performance benefits in real world are small and development experience is a nightmare, I may as well do callback hell in javascript.
20
u/Iryanus Aug 02 '22 edited Aug 02 '22
You might be slightly confused here. Akka Actors is an actor framework, not a reactive one. Reactive programming can be used with actors, true, but most often, it isn't. And actors are much, much older than reactive programming. In our case, it's not anything reactive, just actor based programming, which is a very nice model that increases encapsulation and enforces it much more than standard OOP.
(Of course, you can use parts of Akka Streams in a reactive way, but that's only one option for one specific side library of Akka.)
8
Aug 02 '22 edited Aug 02 '22
Well, depends on what you mean by reactive framework; if it's any framework that makes creating a reactive system easier then Akka is certainly a reactive framework - after all, its creators are also the co-authors of the Reactive Manifesto and if you've taken any Lightbend Academy courses then you know they like to point out Akka's reactive roots. However, if by reactive framework you only mean reactive streams framework then yeah, that's just the Akka streams.
1
u/seinecle Aug 14 '22
Can't wait to see how it will impact data science apps, especially with the new Vector API
1
u/Firm_Month1861 Dec 04 '22
Virtual threads are very hard to debug in case of trouble due to lack of diagnosis information in thread dumps. As a much anticipated enhancement, it's dead on arrival.
-3
u/BlueGoliath Aug 02 '22
You could have just posted a comment instead of making the thread title some editorialized nonsense.
-6
Aug 03 '22
I have been writing a bit more c# than java because of work, so I might be misremembering things, but,
At the end of the day internally, cpu has limited threads for all programs, and OS can interrupt one program or one process or one thread to resume another one
in java you could always set a fixed number of threads based on the number of cpu threads you want to use
in java you could always set a thread pool, and reuse the same threads instead of ending one thread and starting a new one
the cpu and OS will not run more threads than it’s designed to run, and will suspend processes or threads as it sees fit to distribute the cpu usage
I don’t have all the details of the implementation of green threads, but the general idea, in a specific narrow scope of listening to probably network communication like http, the person developing the web server or web framework doesn’t have to set a thread pool, and can use green threads.
Internally the virtual threads are managed, hopefully in a decent way so it doesn’t interrupt itself too much and takes into account the hardware underneath, the program can say I want a thread to handle this, it will be allowed or temporarily blocked and queued in, then allowed to run, your web api or web application can handle more requests per second or it can handle the same amount of requests per second but can keep more connections open, so throughput might be the same but less connections are dropped if the program can get to them before client timeout or keep alive kick in.
Outside of that one popular thing, is this new scope fork join that different to a developer using the thread class? Pretty sure thread and task in c# has start and join, maybe slight syntax change, maybe it runs faster because creating a thread is a time consuming task.
Personally, I don’t like visual studio compared to IntelliJ idea, but I do like that in c# I can just do await when I need a client to wait for something.
I don’t make web application frameworks, I make client applications and rest apis, and to me I don’t feel the need of having more threads than cpu threads or more threads than 1k, because I would definitely queue things in, if you make too many http or i/o requests they can fail each other or just slow each other out, so there is no real benefit there to me at least.
Now if syntax start changing, it might be good or bad, could be good, if the try block with structured scope task thing blocks the calling thread, and you call getData() without the need to write in every function above it async, that’s good.
Is it better in speed than creating a new virtual thread sure, do client applications care, no, you are about to make a network call with unknown latency and execution time.
Is the scope object good at handling 100 or 1000 requests? If yes then maybe it can be useful but would I wouldn’t want to ddos the api I am calling so I would probably queue things in, so it’s only using 4 or 10 connections.
3
u/plumarr Aug 03 '22
I don’t make web application frameworks, I make client applications and rest apis, and to me I don’t feel the need of having more threads than cpu threads or more threads than 1k, because I would definitely queue things in, if you make too many http or i/o requests they can fail each other or just slow each other out, so there is no real benefit there to me at least.
That's the hole point of virtual thread. You don't have to queue anything. You have an I/O bound operation to make ? Just spawn a thread.
-4
Aug 03 '22
That’s fine when I need to do a couple of things, but I don’t want to thrash I/o, DB, or someone else’s API.
3
u/kiteboarderni Aug 04 '22
I think you need to read the jep for this. You are misunderstanding the concept entirely.
0
Aug 04 '22
Dude, the cheeple here, in the the Jeb it will mention the rate limit and ddos and thrashing you will cause to the services you are interacting with?
When you use another entities API, you are going to do thousands of requests per second, and possibly bring their system down or ban your account?
Toxic community has to downvote anything questioning anything. Good job guys, I am logging off of Reddit, enjoy the blind doctrine
9
u/cantstopthemoonlight Aug 02 '22
Can someone explain how virtual threads fit in with something like a Swing/JavaFx app? You still off load any long running work to a fork join pool and invoke back when you are done?
What about messaging libraries that have threads that call into your code? It has to be virtual threads all the way though right?