Mitch Pronschinske is the Lead Research Analyst at DZone. Researching and compiling content for DZone's research guides is his primary job. He likes to make his own ringtones, watches cartoons/anime, enjoys card and board games, and plays the accordion. Mitch is a DZone Zone Leader and has posted 2576 posts at DZone. You can read more from them at their website. View Full User Profile

Mozilla is Developing a Language Called "Rust"

11.28.2010
| 18696 views |
  • submit to reddit
Along with web language champions such as Dave Herman and Brendan Eich, Mozilla's Graydon Hoare is developing a new programming language with an interesting mix of features.  The language is called "Rust", and although it's still in preliminary stages, it has an exciting list of features such as control over memory layout, structural typing, massive concurrency, and the ability to define complex invariants that hold over data structures.

It's difficult to make too many pre-judgements about the language at this stage.  The developers "really really don't want to be spending time on syntax discussions presently."  However, to placate the masses, the developers have posted a small sample testing tuple-outputs on iterators

iter pairs() -> tup(int,int) {
let int i = 0;
let int j = 0;
while (i < 10) {
put tup(i, j);
i += 1;
j += i;
}
}
fn main() {
let int i = 10;
let int j = 0;
for each (tup(int,int) p in pairs()) {
log p._0;
log p._1;
check (p._0 + 10 == i);
i += 1;
j = p._1;
}
check(j == 45);
}

So here is a brief overview of the features:

Safety oriented:

  • Memory safe. No null pointers, wild pointers, etc. Automatic storage management.
  • Mutability control. Immutable by default. No shared mutable state across tasks.
  • Dynamic execution safety: task failure / unwinding, trapping, logging. RAII / dtors.
  • Typestate system: ability to define complex invariants that hold over data structures.

Concurrency and efficiency oriented:

  • Explicit memory control. Layout and allocation control. Interior / value types.
  • Very lightweight tasks (coroutines). Cheap to spawn thousands-to-millions.
  • Stack iterators (effectively lambda-blocks w/o heap allocation).
  • Static, native compilation. Emits ELF / PE / Mach-o files.
  • Direct and simple interface to C code (switch stacks and call, ~8 insns).

Practicality oriented:

  • Multi-paradigm. pure-functional, concurrent-actor, imperative-procedural, OO.
  • First class functions with bindings.
  • Structurally-typed objects (no nominal types or type hierarchy).
  • Multi-platform. Developed on Windows, Linux, OSX.
  • UTF8 strings, assortment of machine-level types.
  • Works with existing native toolchains. GDB / Valgrind / Shark / etc.
  • Practical rule-breaking: can break safety rules, if explicit about where and how.

The Mozilla developers have done a good job of answering many of the questions from interested developers and programming language researchers.  Here are a few of the many questions that the Mozilla developers answer in an FAQ:

  • How do you get away with “no null pointers”?
  • Why is failure unwinding non-recoverable within a task? Why not try to “catch exceptions”?
  • Why don’t local functions or objects capture their dynamic environment? What’s with bind?
  • Why aren’t modules and values type-parametric?
  • Why aren’t channels synchronous?
  • Can Rust code call C code?  Or vice versa?
  • How do Rust’s task stacks work?
  • Why can’t stateful objects have destructors? Why only immutable ones?

You can see the discussion on Rust over at Lambda the Ultimate, where Dave Herman and Brendan Eich answer some questions and debate with commenters.

Comments

Endre Varga replied on Mon, 2010/11/29 - 3:50am

This seems more interesting than Go. Maybe I have to change my next-language-to-learn?

Thai Dang Vu replied on Mon, 2010/11/29 - 9:54am

Is this language cross-platform? If yes, why not joining Scala? If everything is built from scratch, then Rust needs, maybe, at least 5 years to be as good as Java now. And who knows what Java will look like by then.

Mark Haniford replied on Mon, 2010/11/29 - 11:26am in response to: Thai Dang Vu

Thai, obviously since they're not targetting the JVM, there's no reason to "join Scala".

Mike P(Okidoky) replied on Mon, 2010/11/29 - 12:40pm

Aahhhh, yet another language...

I thought "Vala" is an interesting promising language. I don't know if this pair example works well in Vala, but perhaps the two could learn from each other, perhaps converging their efforts together. Too many parallel experiments that aren't solidifying....

Endre Varga replied on Mon, 2010/11/29 - 3:21pm in response to: Thai Dang Vu

Probably because the world needs programming languages for soft real-time tasks, like video processing? Or OS development? I love the JVM, Java and I am a daily user of Scala, still, I am on the look for a good systems programming language that is not C.

Mike P(Okidoky) replied on Mon, 2010/11/29 - 3:28pm in response to: Endre Varga

> a good systems programming language that is not C.

C++? Vala?

Endre Varga replied on Tue, 2010/11/30 - 5:45am in response to: Mike P(Okidoky)

C++? No. Vala? Maybe. There are many new languages cooking, it will take some time, but a few will emerge and will be used in practice. 

Philippe Lhoste replied on Wed, 2010/12/01 - 8:13am

Interesting. Looks readable, although a bit too much on the terse side ("tup" instead of "tuple"? little gain for increased obfuscation). Perhaps showing its C roots?

I appreciate the specs, looks interesting. Yes, that's yet another programming language, but somehow I find it more interesting (on paper, at a glance) than Go which never convinced me.

The native code generation (JVM is nice, but I also appreciate lightweight programs), the interface to C code and the ability to use existing toolchains is a plus, opening all the numerous high quality C libraries, making it a real world language instead of an academic one.

Something a language like Nimrod (to add one to the discussion above) understood too: generating native C code, leaving the task to generate binary to good existing tools like GCC, interfacing easily to C and providing a good set of language libraries. But this one doesn't have Google or Mozilla behind it, so it remains unknown...

Anyway, I think I will take a look at this Rust. We can expect fast development, because as we know, "Rust Never Sleeps" (someone had to make it...).

Carla Brian replied on Sun, 2012/07/01 - 5:55pm

This is the first time I heard about this program. I will read more tutorial on this and try to learn on this one. - Paul Perito

Jaffa Wify replied on Thu, 2012/07/05 - 6:20am

Educational requirements generally consist of a university degree in architecture. The experience requirement for degreed candidates is usually satisfied by a practicum or internship. Finally, a Registration Examination or a series of exams is required prior to licensure. Thanks a lot. Regards, editing a book

Jaffa Wify replied on Sat, 2012/07/21 - 1:46am

Many computer languages provide a mechanism to call functions provided by libraries such as in a .so. Provided the functions in a library follow the appropriate run time conventions, then these functions may be written in any other language. Thanks. Regards, circuit breaker

Jaffa Wify replied on Sat, 2012/11/17 - 12:35am in response to: Jaffa Wify

 

Apply for places to study translation. Translation is usually taught as an Master of Arts-level subject, and candidates require a degree in languages or a background that demonstrates considerable linguistic ability. You may also need to take a translation test. Thanks a lot.
english to russian translation

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.