Re:Why I Don't Want to Learn Go
by pcwalton on Monday March 19, 2012 @12:13PM
(#3724551)
We're working on improvements to the language (namely, regions and dynamic arenas) to make it possible to not use the reference-counted pointer type at all if you don't want it, while retaining the type safety. Regions have their own set of costs, as we're finding out (mostly due to the annotation burden if you start doing complicated stuff), but I think we'll be in a nice sweet spot. Rust gives you three basic options:
(1) Regions, when you want safe, low-overhead allocation. The downside is a more complex type system. (Usually you don't see the complexity unless you're returning pointers that contain references to the stack, at which point you have to convince the typechecker that you aren't creating dangling pointers by doing so.)
(2) Safe, garbage collected heap allocation. This gives you maximum flexibility at the cost of runtime overhead.
(3) Unsafe pointers. This lets you manage your memory manually, like C++. Of course, this is unsafe.
Also, I suspect we're going to add fixed-length vectors; we've been discussing this quite a bit lately and I think there's general consensus that they should be present in the language in some form.
(1) Regions, when you want safe, low-overhead allocation. The downside is a more complex type system. (Usually you don't see the complexity unless you're returning pointers that contain references to the stack, at which point you have to convince the typechecker that you aren't creating dangling pointers by doing so.)
(2) Safe, garbage collected heap allocation. This gives you maximum flexibility at the cost of runtime overhead.
(3) Unsafe pointers. This lets you manage your memory manually, like C++. Of course, this is unsafe.
Also, I suspect we're going to add fixed-length vectors; we've been discussing this quite a bit lately and I think there's general consensus that they should be present in the language in some form.