5 ms·
> Rust is the first language to bring non-GC automatic memory management to the mainstream To nitpick, the first language to bring non-GC automatic memory mana
by arghwhat 2y ago
> Rust is the first language to bring non-GC automatic memory management to the mainstream
To nitpick, the first language to bring non-GC automatic memory management to the mainstream would be either Forth or C through stack memory.
For heaps, we have reference counting, often handled automatically through the stack (e.g., C++ smart pointers).
The thing Rust brought to mainstream is not automatic memory management - they're a dime a dozen with and without GC. It's an ownership model that is strict about whether you have read or write access within the type system. At the same time, this is also where most developer friction stems from, as it's quite unique, and you're often faced with a trade-off between explaining exactly what you want at compile-time at higher design cost, or bailing out more to runtime checks with e.g. RefCell while getting fewer guarantees about code correctness from the compiler.
- pjmlp 2y agoNot at all, considering the decade of high level systems programming languages that predated the very thought of C coming into life. All with stack allocation.
- arghwhat 2y agoKeyword is mainstream, so it’s not when the idea was invented - I think Forth popularized it? I can’t really comment on what counted as mainstream before C though. Not old enough for that.
- pjmlp 2y agoMainstream is whatever people could use between 1958 and 1969, as high level programming language, in whatever computers, universities and companies could afford. Goggle, Bing, DuckDuckGo, ChatGPT,... will gladly provide a list.
- arghwhat 2y agoWhat people could use is not at all what mainstream is. You can use D, OCaml, F# and brainfuck, but they are not mainstream. To define what was mainstream we'd need to talk to people coding at the time and ask them about popularity, adoption, tooling availability, etc. and what languages people were likely to use rather than what was available. And no, I have no need for researching that as I have no use of the information - the point is to say that automatic memory management in mainstream languages predate rust by decades and is present in most languages, not "this specific language should get credit".
- pjmlp 2y agoThen you should not have mentioned Forth or C at all, only to show not having a clue about programming languages history. Besides, any Assembly programmer is well aware of what stack memory is all about, bring us even further back than 1958.
- arghwhat 2y ago> Then you should not have mentioned Forth or C at all, only to show not having a clue about programming languages history. The whole point was that these well-known mainstream languages provided the feature claimed to first have arrived in Rust, to make it clear that it was not just theoretical or some obscure language. It's not my fault that you misunderstood the topic or the idea of what makes something mainstream, and instead read this as an elaborate history class stating the absolute first discovery of the idea. > Besides, any Assembly programmer is well aware of what stack memory is all about, bring us even further back than 1958. The instructions you refer to were designed to support stack-based languages, not the other way around.
- shakow 2y ago> C through stack memory. Stack memory is decades older than C.
- deleted 2y ago[deleted]
- Ygg2 2y ago> non-GC *automatic memory* management to the mainstream would be either Forth or C Emphasis mine. It's not C. You do manual memory management there. You have to call malloc/free. Didn't use Forth, so I can't say anything about it.
- xolox 2y agomalloc/free are for heap based allocations. The grand parent explicitly mentioned he was referring to stack based allocations, which are kind of automatic (implicit).
- Ygg2 2y agoSure, however you still have to do them manually. That's what manual in manual memory management stands for. Stack based allocation are essentially registers, right?
- arghwhat 2y agoThe stack is fully automatic arbitrary memory and has nothing to do with registers. You can allocate as much as you want (including e.g. bytearrays), until you run into the allocated stack limit. That limit can be arbitrary, and some languages even dynamically scale the stack. That you also have access to manual memory on the heap doesn’t matter. You can also do manual memory management in Rust if you want, as one has to do at times.
- Ygg2 2y agoOk. Then manual memory applies to just heap memory management. It's not rocket science. If you are calling malloc/free to maintain your memory you're doing manual memory management. > You can also do manual memory management in Rust You can do Garbage Collection in C, it doesn't make it Garbage Collected language. You're confusing default memory management with what's possible. By your logic, Arena allocators can be used in many different languages, including GC ones like Java. So that means GC languages like Java are manually memory managed. Which is defeats the definition of it.