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

Very interesting, I've read your readme and your core principles really resonate with me. How is memory managed?


Great question - we keep memory management intentionally simple.

1. There’s no manual memory management exposed at the language level (no pointers, no allocation APIs). I intend to keep it this way as long as possible.

2. Containers (list[T], dictionary[K,V]) compile directly to C++ STL types (std::vector, std::unordered_map).

3. Values follow a strict rule: primitives pass by value, containers pass by read-only reference. This prevents accidental aliasing/mutation across scopes and keeps ownership implicit but predictable.

Anything created in a scope is destroyed when that scope ends (standard C++ RAII). So in practice, memory management in Rox is C++ lifetime semantics underneath, but with a stricter surface language to reduce accidental complexity.


That sounds like it's basically impossible to implement your own non-trivial data structures. You can only use the ones that are already in the standard library.

For instance, how would you represent a binary tree? What would the type of a node be? How would I write an "insert node" function, which requires that the newly-created node continues to exist after the function returns?

I'm not necessarily saying that this makes your language bad, but it seems to me that the scope of things that can be implemented is much much smaller than C++.




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

Search: