4 ms·
Green threads are awkward to express with the JVM threading/memory/io model. The runtime is massive (contrasting to the go model of statically linking deploymen
by duaneb 11y ago
Green threads are awkward to express with the JVM threading/memory/io model. The runtime is massive (contrasting to the go model of statically linking deployment binaries). Some semantics (such as unsigned 64-bit integers) are difficult to express. Java's JNI is a PITA. I don't believe go's c bindings are much better, but the JVM definitely has its sore points.
Finally, the object-oriented nature of the JVM is sometimes a pain. This can be worked around, but there is something to be said for preferring the typing of Go.
- alblue 11y agoFWIW there have been methods added to the Math class that perform math operations on unsigned integers, allowing a Java int to be treated as an unsigned int (cf long). In addition there have been other libraries such as JFFR and JNA that make it more sane to inter operate with C libraries in a much less painful way. There's even a future enhancement request to add this info a future release of Java.
- duaneb 11y agoYea, I wouldn't read my above list as a list of roadblocks. The JVM is a serious work horse and every year the list of complaints I have shrinks. Go certainly has its own problems as well, and the performance profiles that pain java are probably not going to fare much better under Go. The major win is probably goroutines.
- kasey_junk 11y agoIt's not even goroutines. Its the scheduler. I am continuously impressed by the amount of quasi-generic performance they can get out of something so simple. You can understand the entirety of the golang scheduler in minutes, and it works out of the box for most of my golang use cases. That said, the JVM scheduling is pluggable, so I have options for a much bigger variety of use cases. With go if the default scheduler doesn't do what I want, I'm stuck.
- Manishearth 11y agoFWIW: https://github.com/kilim/kilim https://github.com/kilim/kilim
- merb 11y agoActually JNA is actually way better than Go or JNI. And if you are looking at Kotlin / Scala you won't find yourself inside the object-oriented pain. The JVM is actually not that bad.
- fithisux 11y agoI agree with you. But this code, does not compile List<Integer>[] j=new List<Integer>[10]; and this is a a serious problem. If generics are correctly implemented, then it should compile.
- Nutomic 11y agoThat's because List is an interface, not a class. FYI this works in Scala: val j = List(1, 2, 3)
- duaneb 11y agoIt doesn't work for all scala interfaces, and when it is like that, it's often frustrating to find the underlying implementation. But that's beside the point—OP was pointing out that you can't have generic allocation.
- merb 11y agoHowever there are mostly alternatives for Java8 something like that: Collections.singletonList(1, 2, 3) which actually gives a List<Int> by the end it all comes down to syntactic sugar.