Rust 0.2 released
mail.mozilla.org
mail.mozilla.org
> Are you going to use this to suddenly rewrite the browser and change everything? Is the Mozilla Corporation trying to force the community to use a new language?
> No. The Mozilla Corporation's involvement is at the labs level: the group concerned with doing experiments. The point is to explore ideas. There is currently no plan to incorporate any Rust-based technology into Firefox.
You're right that it would be idiotic to spend the money and time to develop this if they didn't intend to use it in their products, but they've gone out of their way to make people understand that the Rust they can see today is not going to be shoved down their throats. Whether some eventual successor Rust that may or may not resemble the one we have today is used for some kind of rewrite is probably a foregone conclusion, but they clearly don't want us deciding whether to support or object based on what exists today.
I sound like I'm making a big deal out of a minor distinction, but I don't like seeing what I saw on Slashdot, which was essentially, A) Rust devs announce Rust 0.1, B) someone submits story to Slashdot saying Mozilla is forcing everyone to abandon C++ and switch to Rust in the near future, C) everyone on Slashdot complains that Rust isn't going to perform and ought to have language features X, Y, Z. This cycle misinformation/non-information is going to persist as long as we emphasize the foregone conclusion that this might be used in some kind of far-distant rewrite ahead of the actual news, which is just that 0.2 of Rust, an experimental language, came out today.
The browser engine in question is called Servo, and initial discussions of its design have only just recently begun. See more here: http://smallcultfollowing.com/babysteps/blog/2012/03/28/serv...
Well, per the FAQ: (https://github.com/mozilla/rust/wiki/Doc-project-FAQ)
What is this project's goal, in one sentence?
To design and implement a safe, concurrent, practical, static systems language.One is the belief that it would be to good to write everything in assembly (from OSs to browsers to games) so that it would be faster. See they heard that assembly is faster and lower-level, so "the more the merrier, right"?
Another (that you don't get much nowadays, but there was a time in the early 90's that was very common) was this fascination with Ada. Mostly because of all the marketing and BS articles at the time. The reasoning here was "well, if they use that for missiles and F16s, it must be the best, right?"
They could even make use of Ada's real time capabilities. It was a pleasure when I ran QNX (2005) and everything responded to my actions on spot, even their browser (Voyager). Today I run FF and after a while and with several tabs open it takes (many) seconds until this beast shows some reaction.
BTW I don't use Ada but mostly Haskell since 2001.
None of this require buying into marketing hype.
It's bad because the language is large and some parts feel out of date, the memory management is more complicated than it ought to be, and compilers are thin on the ground and often expensive. Targeting C at a new machine is much easier than Ada, and this is probably the main reason why it lost.
What was meant half-joking (that they should use Ada for the browser) becomes better the more I think about it. When I look at Rust's design goals, I find that Ada 2012 fulfills them (at least superficially). Additionally: if users have to learn Rust as a new language, then they can use Ada anyway (which has a good track record, while there's no experience with Rust's possible quirks). And I guess if they ask AdaCore to include certain features as add-ons to their GNAT compiler, they'd do it or assist (because for fun and for the publicity that Firefox uses Ada).
edit: most complains seem to come from strong typing and static type checking.
DARPA funds lots of computer science research, so I doubt academic dislike of DOD is a big factor.
While I can't say that I completely understand the underlying concepts, I believe that this is the sort of thing that Rust's typestate mechanism is intended to achieve (the way I seem to understand it, it's sort of like design-by-contract, except invariants may be checked at dozens of places per line rather than just at function boundaries). You should look into it if Ada's safety guarantees excite you.
let port = comm::port::<int>();
let chan = comm::chan::<int>(port);
task::spawn {||
let result = some_expensive_computation();
comm::send(chan, result);
}
some_other_expensive_computation();
let result = comm::recv(port);
Why not let the task have a mailbox and send messages to it like in Erlang? Is it because of the desire to have typed channels? I like everything about Rust so far except this choice. I know Go does the same, but I consider Erlang's approach a lot more elegant and less verbose.One can be built on the other, and it being built by the platform rather than the coder would be a big plus. Lets hope mailbox abstraction turn up in the next release.
To emulate that with channels it is like saying you have one default channel created for each task. Instead of sending a message to the task, it is sent to a channel and instead of just a simple receive, the task has to has a reference to the same channel.
Another way of thinking about it, it is like having a graph of components and one model emphasizes the nodes (actors) and the other emphasizes the edge (channels) as the central abstraction.
Yeah I can see that I guess. It is a lower level language so it would be the same as asking for closures or garbage collection in assembler?
> Making a strong association between tasks and message boxes like erlang does makes too many assumptions.
It does, and often having good assumptions is nice. One can argue that at some point unless the system is not C then someone can say it is making "assumptions".
In their documentation they do mention how they are trying to emulate Erlang (they even have supervision trees for tasks) so my point was that they left a critical semantic feature out.
I think they are trying to learn from Erlang, not replicate it completely. The key point is that the missing feature can be pretty trivially made up for by libraries and convention. Which again, seems like an apt choice for a systems language.
Presumably you could still use a queue to provide the semantics you want, even now? Or have another actor that acts as the queue. But I think that use case doesn't warrant decomposing actors into channels and tasks.
Would the best route be to learn C then move onto the untread waters of Rust? I'm just looking for some guidance, this seems really cool to learn.
As to Rust, there are still a few essential constructs missing from the language, so if you're looking for a gentle introduction you'd probably be better off waiting for 0.3 (scheduled for release in "about a month") or 0.4 (probably due to be released in three months or so).
Fortunately, most of the changes in this version were internal rather than user-facing, and the few user-facing changes (classes, regions) are still somewhat half-baked. Not much new to learn at all. :)
Basically, Rust makes it easy to avoid the collector by clear ownership rules, but still provides a collector for the cases where that just won't do.
My personal thinking is that the standard libraries should avoid the GC and use regions, reference counting should be achievable through a "smart pointer" type in the standard library, and GC should be provided if the programmer wants it.
Go is a new Erlang; its the Erlang for people who don't like Erlang, perhaps?
It very much is not. Erlang's primary goal has always been reliability. Not concurrency. Concurrency arose from a subset of the mechanisms Erlang "needed" to implement reliability, but was not a primary focus of the language (just look how long Erlang lived without an SMP-able runtime).
Yet this concurrency is pretty much the only Erlang feature that was ported to Go, in a much less reliable manner.
> Erlang's primary goal has always been reliability. Not concurrency
Wrong. Concurrency is not some accidental bolt-on in Erlang: http://www.erlang.org/course/history.html
Now I picked out Erlang because it has ... garbage collection. I was replying to the parent saying that GC is utterly incompatible with a systems language.
Go and Rust are the new Erlangs in that they are the go-to language for system services above kernel level.
No.
> Wrong. Concurrency is not some accidental bolt-on in Erlang
You might want to read my comment correctly and avoid injecting things which are not in it. I did not say concurrency was "bolted on", I said it was not a primary goal of Erlang's design, it was merely one of the tool deployed to reach the over-arching goal of reliability.
> I was replying to the parent saying that GC is utterly incompatible with a systems language.
Can't say I've ever seen Erlang called a systems language. But in any case Erlang's design and VM structure does make it suitable for soft real-time (per-process shared-nothing[0] heaps independently GC'd with configurable initial heaps, allowing such things as never GC'ing a process at all). Go still's no Erlang.
[0] aside from reference counted big binaries
Whether GC is acceptable in systems work depends on what you construe as "systems work" (kernels and GC don't mix nicely; browsers and GC is OK if you're careful).
If you're willing to be unsafe, it should be possible to avoid most (any?) overhead from automatic memory management. Here's a quote from one of the Rust developers:
"So we basically use the runtime for three things: (a) the task system, which features lightweight threads like Go or Erlang; (b) stack checks and growth; (c) garbage collection. We used to use it for more, but lately more and more stuff has been moved out of the runtime to be written in Rust itself.
"I'd like to see a 'runtime-less Rust' myself, because it'd be great if we could implement the Rust runtime in Rust. This might be useful for other things too, such as drivers or libraries to be embedded into other software. (The latter is obviously of interest to us at Mozilla.) Rust programs compiled in this mode would disable the task system, would be vulnerable to stack overflow (although we might be able to mitigate that with guard pages), and would require extra work to avoid leaks, but would be able to run without a runtime.
"If anyone is interested in this project, I'd be happy to talk more about it -- we have a ton of stuff on our plate at the moment, so we aren't working on it right now, but I'd be thrilled if anyone was interested and could help."
Go adopted semantics (safety and memory model) that are quite unsatisfactory.
Shared mutable state.
Global GC.
Null pointers.
No RAII or destructors.
No type-parametric user code.Shorten 'mutable' to 'mut'
Seriously? Are we editing with TextEdit in this day and age?
I suppose your best bet may be to muck a bit with the key bindings of your particular text editor. IMO, I already swap some keys around to make () and {} more usable.
FWIW the Haskell crowd were super-defensive and claimed that Haskell is super-readable (by them).
Now in that article I talk about 'curly bracket' languages in general, meaning those that use symbols (words) to denote blocks rather than indent. And I don't like reading them because of that.
`-=[]\;',./
In ye old time Unix tradition, the Rust developers favor extreme brevity. :)
I'd personally have gone with "rustc".
I do seem to remember that the devs were passively soliciting ideas for a better name for this keyword. The great thing about a language at this stage is that if this really bothers you, then you can petition to have it changed!
I thought processes and sub processes are cheaper to spawn then threads? That's the reason why Chrome tabs are in per sub processes right? Instead of threads?
Also process is heavier entity for OS kernel in comparison to thread (address space, file descriptors are all per-process objects, not per-thread, thread is just a unit of processor time scheduling). Chrome tabs are processes for security reasons. Chrome trades speed for security in this context.
Both Go and Rust - being relatively low level - prefer passing pointers (references) rather than the data itself. This requires a shared GC heap.
No free lunch...
Secondly threads were originally created as a cheaper alternative because spawning processes was too expensive (on Windows). The original reason for Chrome using processes was that processes gives you memory protection. But I don't know how much it really helped them in the end, because they quickly noticed that using one process per tab doesn't scale. Thus Chrome (at least originally) limited the maximum number of processes to ten.