5 ms·
I only partially agree with you. The examples you gave are solid, but there's a big elephant in the room: async programming. In Go async is transparent, in Rust
by Zababa 5y ago
I only partially agree with you. The examples you gave are solid, but there's a big elephant in the room: async programming. In Go async is transparent, in Rust async tends to be a huge pain. Preemptive multitasking really makes everything easier, and I would take it over Rust's type system and abstractions.
I'm personally patiently waiting for OCaml multicore, which should have the best from both worlds, except the large communities.
- johnnycerberus 5y agoI think the JVM would also be a good choice once Loom lands. I've seen that right now the Java architects are trying to unify the ALGOL flavored Java with ML in the sense of algebraic data structures, pattern matching, local type inference. As you said, OCaml does not have a big community, library ecosystem. It also does not have the 100B$ garbage collectors of the JVM, which are a deal breaker, at least for me.
- Zababa 5y agoThat's a good option too, though in that case the tradeoff is that compiling to a single binary is a bit harder than in the other languages. Someone mentionned Scala too, which is even "higher level" than OCaml, but I think Scala has the issue of future/async (monadic) concurrency, and is even harder to compile to native. There are lots of options in that space, which is great! > It also does not have the 100B$ garbage collectors of the JVM, which are a deal breaker, at least for me. Can you expand a bit on that? I was under the impression that even with all that investment, Java code tends to be slower and more memory hungry than equivalent Go code.
- astrange 5y agoNo amount of $ spent on JITs and garbage collection can solve the problem that Java was designed with no respect for memory use. It just doesn’t have the features (such as but not limited to value types) that let you save memory. They’re adding value types of course, but I haven’t looked at how exactly they’ll work.
- erik_seaberg 5y agoGo is better at keeping values on the stack. Java has better throughput when collecting objects that escaped to the heap. Java also tries to optimize out method dispatch, so we can use it freely where Go might tend to avoid it.
- astrange 5y agoThere's more than just the stack/heap - in a compiled language your constant data is file backed and doesn't need to contribute to memory footprint at all. Java doesn't have that because jar files are missing it (being zipped, syntax that looks like it creates them emit heap allocation bytecode, etc.) and it doesn't have multidimensional arrays or things that might help you use it even if you wrote it in C. There's some other tricks like tagged pointers, purgeable data it doesn't reliably have either.
- zozbot234 5y agoZIP does support uncompressed data, so this could easily be added in a backward-compatible way if deemed worthwhile.
- astrange 5y agoEh you can still have compression, what’s important is the OS pager knows how to read the page from disk as opposed to eagerly loading and swapping it.
- erik_seaberg 5y agoJava NIO can mmap a file of bytes or ints or whatever without using the heap’s private pages, and there are some JVMs that persist and reuse jitted machine code. I’ve read that games and simulators schedule realtime asset loading pretty carefully; what other problems are solved using large constant data?
- pjmlp 5y agoUntil Valhalla arrives, Unsafe package and JNI are options as well. Or is it ok to use cgo to work around Go's shortcomings, but not JNI for Java's?
- kaba0 5y ago> Can you expand a bit on that? I was under the impression that even with all that investment, Java code tends to be slower and more memory hungry than equivalent Go code. Go doesn’t need a good GC as much because it can rely on value types sometimes. But for general enough workloads a superior GC can triumph. Also, Java is memory hungry only in that doing GC when it is not absolutely needed is useless work. The JVM is actually quite power efficient due to trading off memory for better throughput — so especially in server environments with huge (up to multi-TB) memory which the JVM is free to use, it can be ridiculously fast. So no, java is not slower than equivalent Go program though correctly comparing languages is nigh impossible.
- nextaccountic 5y agoDoes Java have sum types yet?
- Zababa 5y agoIt does, through sealed classes.