←back to thread

Four Years of Jai (2024)

(smarimccarthy.is)
166 points xixixao | 1 comments | | HN request time: 0.245s | source
Show context
pcwalton ◴[] No.43726315[source]
> I’d be much more excited about that promise [memory safety in Rust] if the compiler provided that safety, rather than asking the programmer to do an extraordinary amount of extra work to conform to syntactically enforced safety rules. Put the complexity in the compiler, dudes.

That exists; it's called garbage collection.

If you don't want the performance characteristics of garbage collection, something has to give. Either you sacrifice memory safety or you accept a more restrictive paradigm than GC'd languages give you. For some reason, programming language enthusiasts think that if you think really hard, every issue has some solution out there without any drawbacks at all just waiting to be found. But in fact, creating a system that has zero runtime overhead and unlimited aliasing with a mutable heap is as impossible as finding two even numbers whose sum is odd.

replies(4): >>43726355 #>>43726431 #>>43727184 #>>43731326 #
sph ◴[] No.43726355[source]
The faster computers get, the more the GC problem is way overblown apart from super-low-latency niches. Even AAA games these days happily run on GC languages.

There is a prominent contributor to HN whose profile says they dream of a world where all languages offer automatic memory management and I think about that a lot, as a low-level backend engineer. Unless I find myself writing an HFT bot or a kernel, I have zero need to care about memory allocation, cycles, and who owns what.

Productivity >> worrying about memory.

replies(4): >>43726479 #>>43726679 #>>43729279 #>>43729921 #
lifthrasiir ◴[] No.43726479[source]
GC doesn't exactly solve your memory problem; it typically means that your memory problem gets deferred quite far until you can't ignore that. Of course it is also quite likely that your program will never grow to that point, which is why GC works in general, but also why there exists a desire to avoid it when makes sense.
replies(3): >>43726569 #>>43726586 #>>43730602 #
mjburgess ◴[] No.43726586[source]
Not sure why you're down-voted, this is correct.

In games you have 16ms to draw billion+ triangles (etc.).

In web, you have 100ms to round-trip a request under abitarily high load (etc.)

Cases where you cannot "stop the world" at random and just "clean up garbage" are quite common in programming. And when they happen in GC'd languages, you're much worse off.

replies(2): >>43726627 #>>43730012 #
immibis ◴[] No.43726627[source]
Java's ZGC claims O(1) pause time of 0.05ms.

(As with any low-pause collector, the rest of your code is uniformly slower by some percentage because it has to make sure not to step on the toes of the concurrently-running collector.)

replies(2): >>43727026 #>>43729288 #
riku_iki ◴[] No.43729288[source]
With Java, the issue is that each allocated object carries significant memory footprint, as result total memory consumption is much higher compared to C++: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
replies(1): >>43737053 #
igouy ◴[] No.43737053[source]
The benchmarks game shows memory use with default GC settings (as a way to uncover space-time tradeoffs), mostly for tiny tiny programs that hardly use memory.

Less difference — mandelbrot, k-nucleotide, reverse-complement, regex-redux — when the task requires memory to be used.

Less with GraalVM native-image:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

replies(1): >>43737112 #
1. riku_iki ◴[] No.43737112[source]
> Less difference — mandelbrot, k-nucleotide, reverse-complement, regex-redux — when the task requires memory to be used.

yes, I referred to benchmarks with large memory consumption, where Java still uses from 2 to 10(as in binary tree task) more memory, which is large overhead.