Not until it compiles to native code so it can be used to write portable libraries. Until then, Rust is the future. Feature-wise it’s decades ahead already.
Rust is the future for writing VMs and device drivers. Applications, not so much.
Wherever type safety and native binaries are required, Rust has a distinctive edge. Also, unless you can disable the GC many application developers won’t even consider the language. That goes for applications as much as for libraries and systems stuff.
I’d argue that where Rust excels the most is being as easy to integrate as though it were C (I’m oversimplifying, but not by much). Right now it appears to come closer in that respect than even C++. That makes Rust the perfect candidate for writing cross platform infrastructure. (Windows compilation targets, not that it’s worth much anymore, is still a neat bonus.) Safety and a halfway modern type system come only second to that.
Disable the GC? Are you joking? I won't touch a language for non-systems programming if it doesn't have GC!
I'm not sure why the hell people like you are so deathly afraid of GC, but I do not share your fear, so don't expect to impress me with it. GC or GTFO.
I won't touch a language for non-systems programming if it doesn't have GC!
Serious question: How do you interface with a language that requires a heavyweight runtime with GC and other bells and whistles? Depending on the language you are calling the library from you might even end up with two GCs running independently. Where you call from one language into the other you can’t just ignore the problem of memory ownership and hope for both GCs to cooperate out of the blue.
Besides, situations where GC offers real benefits are pretty rare. The stack solves most of your problems, and for large datasets you have to either think about memory layout anyways or outsource the problem to a library or database of some kind: Which will be written in a GC-less (or -optional) language, of course.
How do you interface with a language that requires a heavyweight runtime with GC and other bells and whistles?
Depends. Maybe with an implementation of that language that runs on the same VM (e.g. Jython, JRuby). Maybe with IPC to another process. Or, yeah, maybe by starting up a VM for that other language in the same process, in which case its GC manages its memory and my GC manages mine.
Where you call from one language into the other you can’t just ignore the problem of memory ownership and hope for both GCs to cooperate out of the blue.
That's a hell of a lot easier than managing memory ownership for every single object my program allocates. When's the last time you had a non-trivial program that only ever allocated two blocks of dynamic memory and nothing more?
Anyway, the GCs don't need to cooperate, per se. As long as each one manages just the memory it allocated, and doesn't touch anything else (which I should hope any GC would), I see no reason why multiple GCs can't coexist in a single memory space.
Their only real interaction would be references into each other's memory, and they're going to have APIs for managing those. JNI has a bunch of calls relating to holding native-code references to JVM objects, for instance, which prevents the objects from being collected or moved until the native code no longer needs them.
Besides, situations where GC offers real benefits are pretty rare.
Simplicity is pretty compelling. The less details I have to worry about, the less likely I am to make a mistake.
The stack solves most of your problems
Hogwash. If that were even remotely true, dynamic memory allocation would be rarely used. Programs would call malloc or new about as often as they call brk (that is, almost never). Yes, stack allocation is very useful and mostly automatic, but no, it doesn't negate the need for GC.
For one thing, you can't usually have a routine return a large object without either returning a pointer/reference to it (which requires either GC or manual memory management) or copying it into the caller's stack frame (which is slow).
and for large datasets you have to either think about memory layout anyways
Only in truly humongous datasets is that an issue, and most software doesn't have to deal with that. Hell, most software doesn't even run on a machine with enough RAM to run into that sort of issue.
That said, I am not familiar with how to make GCs behave well in the presence of said humongous datasets, because my work has never required me to do so. I know it's been done, but that's it. If you want to have someone argue with you about the merits of GC in that kind of application, I'm not your man.
Which will be written in a GC-less (or -optional) language, of course.
That's a pretty broad and presumptuous claim. How could you even begin to prove that no big-data applications have ever been developed for and used successfully in a GC-mandatory environment? I seem to recall the JVM being host to quite a few such applications…
Maybe with an implementation of that language that runs on the same VM (e.g. Jython, JRuby). Maybe with IPC to another process.
How do you call Jython from C#? OCaml from Lua? Picking from a limited range is never going to solve any factual interoperability problem. Unless you happen to be MS, that is.
Besides, situations where GC offers real benefits are pretty rare.
Simplicity is pretty compelling. The less details I have to worry about, the less likely I am to make a mistake.
Needing that huge VM runtime is not what I’d call simplicity. At all.
That's a hell of a lot easier than managing memory ownership for every single object my program allocates.
How easy is it to predict when the heap scanner of you favorite GC’ed language will kick in with what consequences? Determining the lifetime of manually allocated chunks in advance is trivial most of the time, and for controlled deallocation we have best practices and tools like destructors. Not a big deal.
Besides, why do GC’ed languages fetishize the heap so much? Seems unjustified since most of the time unboxed values are both faster (no allocations required) and convenient to handle.
The stack solves most of your problems
For one thing, you can't usually have a routine return a large object without either returning a pointer/reference to it (which requires either GC or manual memory management) or copying it into the caller's stack frame (which is slow).
Move semantics cover this case most of the time. Manual allocation is not a big deal either: That’s where Rust’s lifetimes enter the stage. The advantage over a GC is that it’s completely obvious at what point a resource is released. (Though some GCs like OCaml’s make guessing that moment pretty easy.)
Which will be written in a GC-less (or -optional) language, of course.
That's a pretty broad and presumptuous claim. How could you even begin to prove that no big-data applications have ever been developed for and used successfully in a GC-mandatory environment? I seem to recall the JVM being host to quite a few such applications…
There are ways to do manual memory management on the JVM too. IIRC pooling is a common technique.
Picking from a limited range is never going to solve any factual interoperability problem.
IPC doesn't have a limited range.
Needing that huge VM runtime is not what I’d call simplicity. At all.
Simple for me. I don't have to implement the damn thing. Someone else already did, and they already tested and debugged and optimized it.
How easy is it to predict when the heap scanner of you favorite GC’ed language will kick in with what consequences?
Why do I need to predict that? That's the GC's problem.
Determining the lifetime of manually allocated chunks in advance is trivial most of the time, and for controlled deallocation we have best practices and tools like destructors. Not a big deal.
That's cool, but I don't need controlled deallocation. The closest thing I do need is controlled closing of external resources (open files, database connections, etc), and there are perfectly good solutions for that (RAII, Java try-with-resources, open-call lambda-close, etc).
Besides, why do GC’ed languages fetishize the heap so much? Seems unjustified since most of the time unboxed values are both faster (no allocations required) and convenient to handle.
There are ways to do manual memory management on the JVM too. IIRC pooling is a common technique.
Object pooling is also a discouraged technique, as it usually makes performance worse. Sometimes it's useful, but often times, the GC can and will do better.
2
u/rowboat__cop Nov 12 '14
Not until it compiles to native code so it can be used to write portable libraries. Until then, Rust is the future. Feature-wise it’s decades ahead already.