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

This is something I've been thinking about for a while. What if we create a language where all object references are explicitly specified to be either request-scoped or application-scoped. Don't allow application-scoped objects reference request-scoped objects. Allow to manually upgrade a reference from request-scoped to application-scoped if needed.

That would allow us to have ephemeral per-request heaps which are torn down after every request at once. In-request garbage collections are super-fast. Application-scoped objects are never collected (i.e. no major collections).

Wouldn't this simple model solve most problems? Basically, a very simple equivalent to Rust's lifetimes tailored to web services without all the complexity, and much less GC overhead than in traditional GC systems.



You could call them "arenas" to be consistent with the prior art. Yes, if you can partition the heaps into ones with distinct lifetimes, good plan.


"What if we create a language where all object references are explicitly specified to be either request-scoped or application-scoped."

I've done this in both C and C++.

The downside of automatic memory management is you have to accept the decisions the memory manager makes.

Still, generational GC like in Ruby and Python essentially attempts to discern the lifetime of allocations, and it gets it right most of the time.


Given that Rust seems to be the generalized solution to this problem, would a viable prototype just be a Rust HTTP server with a Ruby interpreter embedded in it? Write the code in some kind of Ruby DSL which then feeds back into Rust?

I ask because I have embedded Ruby in applications before, and I'm looking for an excuse to do it in Rust.




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

Search: