Remix.run Logo
garbthetill 5 days ago

doesnt rust still have the advantage of having no gc? I dont like writing rust, but the selling point of being able to write performative code with memory safety guarantees has always stuck with me

noelwelsh 5 days ago | parent | next [-]

I think "no gc but memory safe" is what originally got people excited about Rust. It's a genuinely new capability in production ready languages. However, I think Rust is used in many contexts where a GC is just fine and working with lifetimes makes many programs more painful to write. I think for many programs the approach taken by Oxidized OCaml[1] or Scala[2] gives 80% of the benefit while being a lot more ergonomic to work with.

When I see Rust topping the "most loved language" on Stack Overflow etc. what I think is really happening is that people are using a "modern" language for the first time. I consistently see people gushing about, e.g., pattern matching in Rust. I agree pattern matching is awesome, but it is also not at all novel if you are a PL nerd. It's just that most commercial languages are crap from a PL nerd point of view.

So I think "no gc but memory safe" is what got people to look at Rust, but it's 1990s ML (ADTs, pattern matching, etc.) that keeps them there.

[1]: https://github.com/oxcaml/oxcaml

[2]: https://docs.scala-lang.org/scala3/reference/experimental/cc...

voidhorse 4 days ago | parent | next [-]

Spot on. It's also fascinating to watch people have their minds blown in 2020+ by basic features that have been around since the nineties. It's kind of sad, actually. The industry would be in such a better place than it is today if so many programmers weren't allergic to all things academic and "theoretical" and were more curious and technical than they were conceited. It's baffling that computing, literally a subject area in which the theory quite literally is the practice, is so full of people who refuse to engage with theoretical work and research.

pjmlp 4 days ago | parent [-]

And eventually nothing of it will matter because our AI overlords will eventually translate natural language, maybe with some added help from formalisms, into any kind of application.

josephg 4 days ago | parent | prev | next [-]

> So I think "no gc but memory safe" is what got people to look at Rust, but it's 1990s ML (ADTs, pattern matching, etc.) that keeps them there.

Yeah; this is my experience. I've been working in C professionally lately after writing rust fulltime for a few years. I don't really miss the borrow checker. But I really miss ADTs (eg Result<>, Option, etc), generic containers (Vec<T>), tuples, match expressions and the tooling (Cargo).

You can work around a lot of these problems in C with grit and frustration, but rust just gives you good answers out of the box.

GeekyBear 5 days ago | parent | prev [-]

> I think "no gc but memory safe" is what originally got people excited about Rust.

I think it was more about "the performance of C, but with memory safety and data race safety".

inkyoto 4 days ago | parent | prev | next [-]

OCaml was[0] very popular in the high-frequency trade programming, especially because of its high performance and predictable latency despite having a garbage collector, plus, of course, because of the correctness of the code written in it.

OCaml's GC design is a pretty simple one: two heaps, one for short-lived objects and another one for the long-lived objects, and it is a generational and mostly non-moving design. Another thing that helps tremendously is the fact that OCaml is a functional programming language[1], which means that, since values are never mutated, most GC objects are short or very short-lived and never hit the other heap reserved for the long-lived objects, and the short-lived objects perish often and do so quickly.

So, to recap, OCaml’s GC is tuned for simplicity, predictable short pauses, and easy interoperability, whereas Java’s GC is tuned for maximum throughput and large-scale heap management with sophisticated concurrency and compaction.

[0] Maybe it still is – I am not sure.

[1] It is actually a multiparadigm design, although most code written in OCaml is functional in its style.

gf000 4 days ago | parent [-]

At the same time, OCaml has a very simplistic memory layout where even integers are boxed - Java at least has primitive types.

That surely has a performance cost.

dmpk2k 4 days ago | parent [-]

Are you sure about boxed integers? Perhaps you mean floats? As far as I know Ocaml uses the typical integer/pointer divide.

orthoxerox 4 days ago | parent [-]

IIRC it has 31-bit integers, which means you can't natively work with 32-bit data without widening.

zorobo 4 days ago | parent [-]

or 63 bits on 64 bit architectures.

vips7L 5 days ago | parent | prev | next [-]

You can write safe and performative code with a garbage collector. They're not mutually exclusive. It just depends on your latency and throughput requirements.

sieabahlpark 5 days ago | parent [-]

[dead]

0cf8612b2e1e 5 days ago | parent | prev [-]

Considering how many applications are running in JS/Python execution speed or GC is a low concern for many programs. Ergonomics (community, compiler guarantees, distribution, memory pressure, talent availability, whatever) seem more meaningful.

gf000 4 days ago | parent [-]

I get your point, but JS is an order of magnitude faster than Python, they are not in the same league.

A lot of effort went into making it efficient thanks to the web, while python sorta has its hands tied back due to exposing internals that can be readily used from C.

pjmlp 4 days ago | parent [-]

PyPy could get some community love, but I guess it will never happen, and on the GPU side, Python is basically a compiler DSL.