Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Memory safe and easy implies a garbage collector to me. Unfortunately, garbage collection and C libraries easy to use is at odds.

In other words: Memory safe, easy to learn, easy C-FFI? Pick two.



They also wanted "without loss of performance" (compared to C, I think, based on the context), which also has tension with the other requirements. I don't think it's possible to make a memory-safe language that has easy C FFI with no overhead and doesn't require you to think about C stuff. The esoterica of C have to be addressed somewhere.


You can have fairly cheap (but not entirely free) runtime memory safety at interface boundaries in any language that supports arrays via "tagged index handles" (basically weak references which protect against dangling access). To be efficient this requires a specific module design philosophy though (you basically want to avoid converting between a handle and a pointer for each memory access, only at the interface boundary, and interfaces should be designed so that they avoid "high frequency functions" with handle parameters).

Interestingly this approach is also somewhat popular in Rust to workaround borrow checker restrictions.

For instance see:

https://floooh.github.io/2018/06/17/handles-vs-pointers.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: