by twic · 3y ago · 0 comments
At the moment, my apps are using either the JDK HttpServer, which is easy to use, but of questionable robustness and lacking websocket support, or a Netty-based server, which works very well and supports websockets, but is often awkward to program against because it's asynchronous. Nima should combine a nice simple synchronous API with a fairly luxurious feature set and good scalability.
Of course, it will turn out there are things terribly wrong with it, because this is real life. But for now i'm optimistic!
[1] https://intellij-support.jetbrains.com/hc/en-us/community/po...
The other problems I have is that as soon as you need to do anything blocking (e.g talking to SQLite or RocksDB over JNI), the whole thing falls apart in terms of threading. Doing a HTTP request somewhere in a reactive chain that does some blocking operations - well shit now you're blocking the reactor-http-netty-* threads, which are fixed so you're worse off than with thread-per-request at that point. Or even just using Caffeine cache, or any caching library really, but Caffeine is one of few that prevents async stampede - well shit now you're running on ForkJoin pool during cache misses, but "reactive" threads on cache hits. You can see how this quickly becomes a tangled mess of thread-hopping and avoiding blocking event loops, and it's extremely complicated to get this right with how subscribeOn/publishOn works and how the profiler can't tell you which threads runs what code because the stack traces are filled with garbage.
You also opt out of a lot of what Java offers in terms of synchronization. Using the synchronization keyword is a big no-no, the JVM can park the thread while waiting for the lock. Now that thread cannot schedule other tasks just because that one task ran into lock contention, and it's highly likely a fixed pool of threads. You're basically left with CAS, AtomicLong/AtomicBoolean/etc, and that's it. I've even seen BlockHound, project reactor's tool to help you find if you are blocking somewhere, trigger "Blocking call to LockSupport.park()!" during a ConcurrentHashMap lookup. Add to this that most caching libraries are implemented on top of ConcurrentHashMap. Getting async right in reactive code has a huge mental overhead and you need intricate knowledge of the libraries you depend on, the platform you run on and what it is that actually enables async in the kernel, and where it is unavailable. Good example of this; that UUID library you use uses a CSPRNG. Have you set the JVM flag to read it from the non-blocking /dev/urandom rather than the default /dev/random on Linux?
I think reactive programming in Java is decent as long as all you're really doing is accepting/performing HTTP requests and talking to a database that has a reactive client connector. In essence, anything that strictly deals with networking, since that's all that can really be made truly async currently, thanks to epoll/kqueue/iocp on linux/mac/windows respectively. Hopefully io_uring will broaden that to file IO as well eventually, but unfortunately that's linux-only for now.
Contrast this with Go's scheduler that just takes care of this for you - no need to think about it. Or Rust + Tokio, where it is explicit with tokio::spawn_blocking and offering async counterparts to std Mutex, RWLock, Channels, etc that doesn't block the current thread on lock contention.
[1]: https://github.com/ben-manes/caffeine/blob/master/examples/c...
Pretty sure this works with Java 20 with the loom previewed enabled.
Everyone is free to use Java in vi with make, if they feel happy doing so.
In fact, there were hardly any Java IDEs when the language was released in 1996, which were quickly provided by Smalltalk, Delphi and C++ vendors.
I became an XEmacs user in 1995, because everything else in UNIX just sucked in comparison with PC, Mac OS and Amiga IDEs of the time.
All my co-workers use VS Code for TypeScript, but I feel crippled when I can't use WebStorm. Not because I can't program without it, but because I'm missing a powerful force multiplier.
It is not mere IDE Dependency. It is IDE Supremacy. Java is the leader of the IDE master race - the other PL IDE's need to squint to see how far ahead Java IDE's are.
I've seen many frameworks shared in hackernews. But rarely do I see anyone commenting on their IDE's capability to be able to use that framework for go-lang, rust, c, c++, etc.
For example, Rust tokio 1.0:
https://news.ycombinator.com/item?id=25520353
I don't see anyone mentioning an IDE there.
In what concerns C++, have a look at VCL, Firemonkey, Qt, Unreal, Godot, DirectX, Metal,...
All Apple frameworks for Objective-C and Swift.
Just like how our current civilization is dependent on industrialized agriculture and distribution systems.
We cannot imagine how it would be possible to live without those functions. In a way, yes, it is "supremacy", but only if you have access.
I find the whole notion of software engineers rejecting software applications being useful as a concept while it being the primary focus of their own profession quite fascinating.
Personally I use various IDEs, light weight IDE/Editors and even vi/vim depending on the language & situation.
Think of it this way:
If I asked my team to develop a project/POC with this framework and they came back to me saying that they have to wait for (or prefer to wait for, or whatever) jet brains to add java 21 support to do this, I would not be very happy.
But writing any language is much more productive with a good IDE. For me, the added value in using Java 21 now rather than in a few months is not enough to outweigh giving up the use of an IDE.
Time to add a format check to pre-merge CI.
Being a bit entitled regarding support of preview features.
If said developer is savy enough to use a preview SDK, they should be able to cope with the downsides of lacking all the nice support.