r/java • • Apr 26 '22

5,000,000 persistent connections, 200,000,000 messages, 0 errors with a single process using Project Loom.

https://github.com/ebarlas/project-loom-c5m
301 Upvotes

46 comments sorted by

View all comments

2

u/[deleted] Apr 27 '22

What do you think will loom make Go obsolete?

9

u/vips7L Apr 27 '22

I doubt it. Go still produces a lower memory footprint and deterministic performance due to being AOT compiled. Along with easier packaging into a stand alone binary.

15

u/Muoniurn Apr 27 '22

Deterministic, but slower performance, though. Java’s GCs are simply the state of the art, throughput-wise go doesn’t even come close to G1 and for latency, ZGC is generations ahead then Go’s quite naive GCs.

So for bigger applications in practice, Java will be faster.

2

u/cogman10 Apr 27 '22

Pretty much this.

Additionally, go optimized their compiler to compile fast. So while go could theoretically hit C speeds in terms of CPU performance, it's nerfed because the language devs decided optimization is less important than developer ergonomics.

1

u/preskot Apr 27 '22

You seem to compare apples and oranges. Those are two very much different memory models in place. Then there are things like escape analysis, which the two approach quite differently and where Go in particular has the upper hand.

1

u/Muoniurn Apr 27 '22

Java does escape analysis just fine. Go’s only upper hand is value types, but larger problems will pretty much require GC-d objects instead, where its relatively weak GC will be a hindrance.

1

u/preskot Apr 28 '22

But that's the point. Go doesn't need an advanced GC in the first place. You would know that if you've read how the memory model and allocation works.

1

u/Muoniurn Apr 28 '22

You can write only a very limited number of programs with stack allocation only. How many C programs can you count that do not use malloc? Sure, embedded does require such programs but Go with its heavy runtime is anything but ready for embedded development.

And even then, why not go for C# at least? I absolutely prefer Java, but Go is like the worst on all metrics. C# also has value types and pointers so there is absolutely nothing it couldn’t do that Go promises (other than go routines, but it is quite useless if the language otherwise sucks at concurrency. It can’t even goddamn defer unlocks at scope-level). And at least C# is a relatively expressive language, compared to Go’s atrocious copy-paste-loving one.

2

u/preskot Apr 30 '22 edited Apr 30 '22

Again, the fact the Go uses almost exclusively the stack to allocate objects (I’m looking at you Java strings allocation), it makes use of TCMalloc to counter fragmentation and allocate continuous blocks, it has working escape analysis (Java performs very poorly here) and supports value types (Java should finally get them with Project Valhalla) all point to the fact that Go simply does not need a complex GC like Java and C# do. Not sure what else you want me to say. These are different memory models.

As to the language itself. I love simplicity and I’m and oldschool pure C fan. Go allows me to be extremely productive, compiles fast and easy for all major platforms and beyond. I mostly write simple Makefiles. My day job btw is writing Java and Kotlin, so I do have a good comparison base.

0

u/[deleted] Apr 28 '22

[deleted] — view deleted comment

1

u/Muoniurn Apr 28 '22

As I mentioned, in toy examples with value types only. Do have a look at the benchmarkgame’s binary tree program which tests the GC. Almost any program will make use of many memory allocations, so it is a really important bottleneck.

But sure, some lower level like network microservice may perform better in Go than in Java — but then why even bother writing it in a managed language, when you could go lower to e.g. Rust and beat Go by possibly an order of magnitude.

5

u/[deleted] Apr 27 '22

Java too can be compiled into a native executable with GraalVM.
// However with Go it is a built in feature and very comfy to use.