Thoughts on replacement languages
tedunangst.com
tedunangst.com
My question is: Who offered memory safety on its own, historically? I think the reason that memory safety has been a tough sell historically is that it always came with performance overhead and lack of low-level control, and people kept using C and C++ for low-level programming as a result. By contrast, Rust tries to go farther than any other industry language in truly providing memory safety on its own—without any of the baggage of JITs, or garbage collection/pervasive reference counting. If you had to sum up the raison d'être for Rust in one sentence, that'd be it.
I think that historically, memory safety "on its own" hasn't been tried, at least to the degree that Rust strives for.
Ironically, channels are a great example of this. Rust used to have a channel keyword, and the language used to reason about them directly, but nowadays, the type system is strong enough that they (and in fact, all of I/O) is just a library, yet just as safe.
Rust also has strong enough guarantees that channels aren't always as necessary as they might be in other languages. For example, we can catch data races _at compile time_, which means shared memory just isn't as dangerous. The type system makes it impossible to mess up your usage of things like atomics and mutexes.
Anyway, if people don't know what Rust is about, it's ultimately a failure of our marketing. We'll get there. :)
You can still cause deadlocks and livelocks in well-typed code, which I put into the category of "messing up your usage of mutexes". It would take a more powerful type system to prevent these errors. It is also unclear whether the behavior of mutexes in the face of task failure is correct for all use cases.
* Minimal overhead (e.g. runtime), great for systems with very constrained resources
* More advanced language features than C (better macros, better type system, pattern matching, etc)
* Compile-time verification of safe usage of memory
* The ability to drop down into manual/unsafe mode for doing stuff like DMA or writing to configuration registers
c.f. this topic from a year and a half ago: https://news.ycombinator.com/item?id=6268291
I did a bit of embedded development (MSP430, Cortex M3, PIC18) some time ago, and I can say that having a language like Rust at my disposal would have drastically improved my productivity.
"Zinc is an experimental attempt to write an ARM stack that would be similar to CMSIS or mbed in capabilities but would show rust’s best safety features applied to embedded development."
Rust only needs to compete against c, c++, Ada, etc. In that class of languages, safety is a major feature.
The Go runtime provides GC, its own scheduler, time abstractions -- basically everything a JVM is required to do (plus the scheduler)[1]. It's an AOT-compiled Java. Because of its high-abstraction runtime, interoperation with native libraries is hard to nearly impossible (depending on the direction). It is to be used to write server-side applications. It's Java without the JVM, for better or worse (native binary, short startup, but no dynamic code swapping, no multiple languages support, no instrumentation, no JIT, and no deep monitoring)
Rust, on the other hand, is a modern C/C++ replacement. It is meant to be used anywhere C or C++ are used. It can be used to write applications, device drivers, operating systems, or fully native libraries (that can be called from Java, Go, Python or Fortran).
Neither approach is better than the other, but the two are so different that they can't even be compared directly. One is Java minus the JVM, and the other is a C/C++ replacement.
[1]: GC (or rather the illusion of infinite memory), abstracting OS time plus some other OS abstractions -- all provided by Go but but not Rust), are the only things required from a JVM. Runtime bytecode interpretation or JIT -- what most people usually associate with JVMs -- are actually not required; some JVMs, particularly those for hard realtime and safety critical code, perform AOT compilation.
For Go, 'systems' as in the sense of software running on servers providing services to user applications.
For Rust, 'systems' as in the sense of (http://en.wikipedia.org/wiki/System_programming_language) - software such as OSes, device drivers, etc.
Just for fun, Swift is advertised as a systems language as well. In its defense, it does have facilities for bypassing the preferred way of managing memory (ARC) and working with memory directly.
I guess I think the sentence you wrote above is just a lot more clear than calling it a systems language and hoping people know what you mean.
Actually, rust does provide very similar concurrency primatives. T̶h̶i̶s̶ ̶i̶s̶ ̶a̶ ̶s̶h̶o̶r̶t̶ ̶i̶n̶t̶r̶o̶d̶u̶c̶t̶i̶o̶n̶,̶ ̶a̶l̶t̶h̶o̶u̶g̶h̶ ̶I̶ ̶d̶o̶n̶'̶t̶ ̶t̶h̶i̶n̶k̶ ̶i̶t̶ ̶w̶i̶l̶l̶ ̶c̶o̶m̶p̶i̶l̶e̶ ̶o̶n̶ ̶t̶h̶e̶ ̶a̶l̶p̶h̶a̶ ̶d̶u̶e̶ ̶t̶o̶ ̶t̶h̶e̶ ̶u̶s̶e̶ ̶o̶f̶ ̶p̶r̶o̶c̶:̶ ̶h̶t̶t̶p̶:̶/̶/̶w̶w̶w̶.̶r̶u̶s̶t̶f̶o̶r̶r̶u̶b̶y̶i̶s̶t̶s̶.̶c̶o̶m̶/̶b̶o̶o̶k̶/̶c̶h̶a̶p̶t̶e̶r̶-̶0̶6̶.̶h̶t̶m̶l̶. See Steve's awesome documentation posted below!
Currently you need to type a bit more, but the compiler is able to make some channel usage errors uncompilable. I can see myself doing napkin prototyping in Go (as I already do) and writing the real version in Rust for better performance and safety in many cases.
Namely, Rust's notion of memory safety prevents data races in concurrent programs. This is because Rust's region typing / lifetime system rejects racy programs as invalid.
Go provides something more like a built-in concurrency framework than truly baking this sort of safety into the language. It's just as possible to write racy concurrent programs in Go as it in in Java, C++, or C.
Go provides idioms that can help you avoid writing racy programs, but they're just that: ideas about how to structure your program, not guarantees that will keep you from shooting yourself in the foot.
Go provides a data race detector so if you do write racy programs, you can retroactively detect the problem. Unfortunately data races have this nasty tendency to pop up under unusual circumstances like high load or unusual combinations of events.
That the author of this post chose concurrency as the thing to harp on about Go's superiority shows how little experience that person has with Rust, IMO. Rust shares the same basic concurrency concepts as Go (communicating sequential processes), but features a compiler whose type system prevents you from writing racy concurrent programs.
AFAIK, rust also doesn't allow selecting between a send and receive on channels. It only allows selecting over a set of receivers and even there it doesn't offer something like the default clause of Go's select statement.
Rust does have interesting features to prevent data races but it's concurrency model is very different from CSP and Go. Since the author praises Go's concurrency in the context of writing servers, it is entirely reasonable to prefer goroutines over OS threads as the unit concurrency.
Rust supports both approaches.
However, even if that exists, rust's concurrency doesn't follow CSP as much as go's. Like I mentioned in my previous comment, it doesn't have a way to do everything the select statement in go does. This is not necessarily a bad thing, but rust definitely doesn't share the same concurrency concepts as go. It offers everything that Java/C++ does along with data race protection.
Speaking of data race protection, the current type system rejects a lot of very common "non-racy" code too. There is work in progress to address some of them and may be most of them will be addressed eventually.
Because it supports asynchronous messaging too? As if CSP were some concept that emerged fully formed from Tony Hoare's head like Athena from Zeus?
I'm sorry you see dichotomies where others see dualities.
The tone of your previous comment made me feel that this thread is going in an unproductive direction, so I'll stop here.
Perhaps you should try to be more informed about Rust before you try to have an argument about it in the future!
AFAIK, rust also doesn't allow selecting between a send and receive on channels. It only allows selecting over a set of receivers and even there it doesn't offer something like the default clause of Go's select statement.
Perhaps you should try to read my comments in their entirety before making accusations.
Yes I missed sync_channel, but if that is all CSP was, Java does CSP too. It has Threads and SynchronousQueue exactly like rust 1.0 will.
This is where I again point out that neither Java nor Go ensure that state sent over channels is actually isolated, and both allow data races.
With Rust that is not the case. You have true isolation (unless you explicitly opt not to)
Though I don't think GUIs need to be a primary focus, there are some useful projects already. The rgtk library [1] is the best so far. It is the first Rust project I contributed to. It is currently broken due to the changes in the language, but that should be fixed relatively soon. GTK is more natural to interface with than Qt or WxWidgets because it is written in C.
My IDE called Nightcode (see nightcode.info) has a template for that. You just click "New Project", give it a name, and then choose the "Web" template. It will generate a project that builds a single jar file like I described. Sorry for being off-topic but I figured it might be what you want.
Hm, I think this is a bit distant from reality. People who use Perl/Python/Ruby eventually experience problems with performance and memory usage and start looking for alternatives. And since Go is a small language, familiar to everyone and offers an easy way to replace existing services (static binaries) - people choose it.
He says "succeeded", isn't that the same thing you are arguing against?
As for the languages themselves, I was very happy when Go came out and I've been using it for the last two years. I generally loud the conservative approach to language features that Go took, but I fear they've overdone it.
One feature missing from Go which is mentioned at every such occasion (and with a good reason) is generics. Their value to the programmer would be even higher in Go than in other languages, since a lot of existing concurrent code could be written in a generic way and reused regardless of what needs to be put in the channels.
There are also a few minor annoyances like lots of boiler plate (e.g. overly verbose for loops), nil pointer, no algebraic data types, select statement vs reflect.Select(), range keyword (off-limits to your own data structures).
I've got high hopes for Rust.
The majority of software can be written in python, Go, Ruby, Haskell etc. but the software that need to be native is extremely important. Improving browser parser by 10% improves millions of apps. Having better and more productive language is better for faster innovation.
My only problem with Rust is that the first version has a lot of features. The should have shipped 80% of them and add the rest in 2.0.
It's not like 1.0 represents all the features they want though, there are many language and library features that are planned for the future.
As an example, the IO subsystem had lots of generality designed for when lightweight tasks were still a feature. By ripping them out, the library is both easier to use, and simpler for future expansion. It was also changed to support the general error-handling facilities that Rust now has (which are partly similar to the old IO-specific error handling features, but wouldn't work well with other libraries).
Others like the collection-api cleanup were badly needed, because of inconsistency and a lack of direction over time. Now the collection-api is much cleaner, and consistent between different types of collections. This allows them to add things like collection-api traits in the future, and newer collections that can follow the same api conventions
IMHO, for GC'ed languages, Go is just more of the same. I can think of a bunch of languages that offer much more already.
If you run a Java application outside a web browser, e.g. a server-side application, it won't run untrusted code and it isn't sandboxed by the JVM (like any other language), so those CVEs are irrelevant in that case.