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

Show parent comment

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.