Remix.run Logo
▲ assumed_throwaw 3 hours ago

Tangential, but the complexity and over-head of the malloc abstraction is precisely what made me very intrigued by "stack-only" languages, such a recently published Goose. There is something very elegant and exciting about the idea of (almost) completely getting rid of it. Just as modern programming languages have developed good ergonomics that replaces a garbage collector, the same could hopefully be done to replace heap-allocated memory.

▲smashspectacle 2 hours ago | parent | next [-]

This is actually what first drew me to zig. Most people talk about error handling, but the explicit allocator handling and making choosing an allocator a deliberate consideration has pushed me to better coding habits in general. I don't think it is possible or practical to completely abandon heap-allocated memory, but explicitly choosing between allocation types and styles that most precisely fit a job has great potential for meeting that spirit.

▲EPWN3D 30 minutes ago | parent | next [-]

I don't think we can get rid of heap memory, but I do think we can get rid of a shared heap.

▲lawandjustice an hour ago | parent | prev [-]

[flagged]

▲connicpu an hour ago | parent | prev | next [-]

Avoiding the heap entirely isn't required and will prevent you from working with substantial amounts of data. The real key is to allocate all the memory you need up front and use that large block for a long duration.

▲eschneider an hour ago | parent | prev | next [-]

Embedded programming has taught me that almost anything can be a stack-only language if you want it to be, even C++. :)

▲jacquesm 2 hours ago | parent | prev | next [-]

Most stack oriented languages also have a heap.

▲nialv7 3 hours ago | parent | prev [-]

the stack is just a bump allocator. the unique thing about stack-only languages is lifetime management, not really how they allocate.

▲saagarjha 2 hours ago | parent [-]

A stack only language that called into malloc to service allocations would not be very interesting.