10 ms·
Mozilla releases version 0.1 of the Rust programming language
- markerdmann 15y agoIn case you're wondering why we need another programming language, this short audio clip from Brendan Eich is great: http://www.aminutewithbrendan.com/pages/20101206 http://www.aminutewithbrendan.com/pages/20101206 "With Rust, what Graydon has been trying to do is focus on safety and also on you could say concurrency -- the actor model which I've spoken about recently - and the two are related in subtle ways."
- pfraze 15y agoWhat's the target platform? Looks like it compiles to system-executable, but Mozilla was involved, which makes me wonder if there's browser execution.
- azakai 15y agoSystem native executables: Win32, OS X, Linux, etc. This is a language for (among other things) prototyping browsers themselves, not running stuff inside browsers.
- pavlov 15y agoIt's basically a planned replacement for C++ as the language used to program the Mozilla apps themselves (and native add-ons). It wouldn't make sense as a scripting language that runs on Mozilla.
- marshray 15y agoOn the audio it sounded like he went out of his way to deny that Mozilla has any plans to rewrite existing C++. It may be that Rust is being designed as if that were a goal, but let's not start any rumors here.
- pjscott 15y agoThe stated goal is to use Rust for prototypes of new browser architectures.
- Hemospectrum 15y agoIt would be wise of any developers to give their new language a shakedown on smaller, less important projects before staking their whole business on it. Of course, if it turns out to work amazingly well and they can port all their old code (or interface with it) with relative ease, there's no reason not to jump ship from the hellfires of C++ compilation. They've had major issues with that lately, after all.
- kibwen 15y agoIf anyone decides to give Rust a spin and is compelled to help out by providing feedback, the devs love to hear comments and criticism from users of the language: https://mail.mozilla.org/listinfo/rust-dev https://mail.mozilla.org/listinfo/rust-dev
- Chirono 15y agoDo you know if there is any explanation of 'unique pointers' and 'unique closures' anywhere? I'm quite interested to see some of the decisions, especially wrt the type-system.
- zokier 15y agoI do not know about unique closures, but afaik unique pointers in Rust are similar to std::unique_pointer in C++ (with some syntax sugar).
- starwed 15y agoOne of the devs keeps a blog, and he has a post about implementing unique closures. (There are several posts on the topic actually, since I guess the idea evolved a bit with time. Just check out the Rust category for more...) http://smallcultfollowing.com/babysteps/blog/2011/12/16/implementing-unique-closures/ http://smallcultfollowing.com/babysteps/blog/2011/12/16/impl...
- richdougherty 15y agoUnique types are used to guarantee that only a single reference is ever held to a value. Sort of like the value has a single "owner". This restriction, while a maybe bit of a pain to program with, gives the compiler permission to do clever things. In particular: 1. The compiler can detect when a value is no longer "owned" (referenced) by anything and free it automatically -- without garbage collection. That's really handy for things like closures where the compiler automatically allocated the memory for you in the first place. 2. If an immutable value is modified then a copy usually needs to be made. But if the immutable value is uniquely-referenced then the compiler can reuse the old bit of memory, thereby saving a copy operation. It can do this because it can prove the old memory can no longer be accessed. 3. I think Rust might also use uniqueness when sending values between its tasks. Since it can prove the value will no longer be referenced by the old task the compiler can avoid copying the values while still preserving isolation. http://en.wikipedia.org/wiki/Uniqueness_type http://en.wikipedia.org/wiki/Uniqueness_type
- protomyth 15y agoIs there a reference manual anywhere?
- samth 15y agoReference here: http://doc.rust-lang.org/doc/rust.html http://doc.rust-lang.org/doc/rust.html Tutorial (probably better at the moment): http://doc.rust-lang.org/doc/tutorial.html http://doc.rust-lang.org/doc/tutorial.html
- capnrefsmmat 15y agoThere's a language reference and a tutorial: http://doc.rust-lang.org/doc/rust.html http://doc.rust-lang.org/doc/rust.html http://doc.rust-lang.org/doc/tutorial.html http://doc.rust-lang.org/doc/tutorial.html
- kibwen 15y agoThe technical reference manual: http://doc.rust-lang.org/doc/rust.html http://doc.rust-lang.org/doc/rust.html The friendlier language tutorial: http://doc.rust-lang.org/doc/tutorial.html http://doc.rust-lang.org/doc/tutorial.html
- kristianp 15y agoOriginal HN thread here: http://news.ycombinator.com/item?id=3491557 http://news.ycombinator.com/item?id=3491557 https and http links should be treated the same for de-duplication purposes, although this thread has a few more links, and points.
- swah 15y agoImplementation partially in OCaml! (But why don't we use Ocaml again?)
- driax 15y agoAs I understand the first (development) versions was in OCaml, but now the compiler is completely self-hosting.
- jamii 15y ago> But why don't we use Ocaml again? Rust offers better control over memory layout, more predictable resource usage and a fuller concurrency model. If it works out it will be a good replacement for ocaml, especially for systems development.
- InclinedPlane 15y agoMaybe I'm crazy but it seems like a lot of these recent new languages are missing the mark. If you're designing a language from the ground up why wouldn't you build unit testing as a first class citizen, for example? As well as profilling and instrumentation. How about a modular compiler that can round-trip back and forth between raw source and commented parse trees so you can do much smarter merging in source control? So many languages seem to be aiming at targets that are pretty far away from the major pain points for the normal developer.
- pcwalton 15y agoUnit testing is a first-class citizen in Rust. You can annotate functions with #[test] and they become unit tests. You can then run tests with the built-in test harness on a module-by-module basis. Profiling and instrumentation are possible using the standard tools (xperf, Instruments/DTrace, perf/oprofile). Rust works just fine with those. Not sure what you mean by "round-trip back and forth between compiled code and commented parse trees", but Rust contains a pretty-printer which preserves comments.
- nwmcsween 15y agoCan you clarify a few things, these are bikeshed issues but they bother me none the less. * Why was fn foo(bar: int) -> int chosen and not fn foo(bar:int): int? * Why annotations within comments? Annotations aren't comments it smells of C bolt-on. Why not keyword annotations?
- haberman 15y agoAs a die-hard C guy, Rust is the first "new systems programming language" since Cyclone and D that I didn't immediately dislike. A lot of really interesting ideas in here. I'd love to know what Mozilla uses this for internally. That said, it's hard to imagine anything displacing C for me. Almost any systems code I write these days is something I'll eventually want to be able to expose to a high-level language (Lua, Python, Ruby, etc). To do that you need code that can integrate into another language's runtime, no matter what memory management or concurrency model it uses. When you're trying to do that, having lots of rich concepts and semantics in your systems language (closures, concurrency primitives, garbage collection) just gets in the way, because you have to find out how to map between the two. C's lack of features is actually a strength in this regard. I do really like Rust's expressiveness though. The pattern matching is particularly nice, and that is an example of a features that wouldn't "get in the way" if you're trying to bind to higher-level languages.
- arctangent 15y agoI've only recently started to look at D as a number-crunching language, but it certainly sounds like you know a bit more than me here. Let me ask you a question or two: is there anything at all that makes it possible to interface D with Python? I'm aware of PyD [1] but it looks like it only worked with D1. If I wanted to stick with D and Python, would it be the case that I'd have to (re-)write something like PyD from scratch, or is there a simpler approach? [1] http://pyd.dsource.org/ http://pyd.dsource.org/
- TylerE 15y agoIf you don't mind writing a little C, that could serve as a bridge, since both runtimes can speak C.
- alexatkeplar 15y agoCan you elaborate on what (if anything) you immediately disliked about Go?
- haberman 15y ago
- jon6 15y agoThe language looks ok. If they are going for world domination a more likely path seems to be evolving C very slowly. That is they should start from C and then every few years add a few new features and take out some old crummy features until they finally reach Rust. Lots of people probably don't like rewriting code bases wholesale and new languages take a while to become trusted.
- aaronblohowiak 15y ago> and take out some old crummy features Backwards-compatibility is held extremely dear to the C community, with those few breaking changes being simple (usually) to work around. If you want to break compatibility, you have a better chance calling it a new language.
- jon6 15y agoThats true, but new modes can be added with switches similar to how gcc has -std=c89, -std=c99 and whatnot. Newer modes could disable old features and people could upgrade at will.
- rcfox 15y agoExcept that there's no business case for rewriting old code that still works and is still supported by the compiler. And then suddenly, the compiler team has to support multiple, very different versions in the same release.
- roel_v 15y agoWith 10 years between each such 'mode', and the differences still being relatively minute, it would take centuries to morph C into something else. Which is a good thing, don't get me wrong. It just shows that the proposed approach isn't feasible.
- enneff 15y agoHow can you build trust in a language that changes all the time?
- dain 15y agoIf anyone from Mozilla reads this, - http://github.com/mozilla/rust/issues http://github.com/mozilla/rust/issues. Is an invalid URL. You put the period inside the last </a>. You should toss that out :)
- markwong 15y agoAnd we have Ada.
- mulander 15y agoHonestly, I am observing closely the way some new system languages evolve - D, Go, Rust and I see a large intersection of features with Ada. I am always amazed that no valid discussion/comparison of those languages and Ada erupt in these threads :( Ada is not as bad as it's painted to be.
- markwong 15y agoi find Ada is a good and consistent programming language.
- Hemospectrum 15y agoAda has a reputation for being dramatically overengineered, especially among programmers with exposure to Ruby or Haskell (or Lisp, naturally). I've never seen a demonstration of how well it works for rapidly prototyping code and "filling in the blanks" iteratively. Would you mind providing examples?
- supersillyus 15y agoDoes anyone have a link to some examples of non-trivial Rust programs? It looks like a pretty neat language (despite making a few more distinctions than I tend to care about), but I'd like to see how it reads in practice.
- gnuvince 15y agoI guess the Rust compiler is the most non-trivial Rust program at the moment. You can start there. I've been reading the lexer and parser code (cause I've got to write those for a class) and it's very easy to follow.
- mbrubeck 15y agoHere's a discussion of a ray tracer written in Rust: https://mail.mozilla.org/pipermail/rust-dev/2011-December/001070.html https://mail.mozilla.org/pipermail/rust-dev/2011-December/00... and here's the source code on GitHub: https://github.com/brson/rustray https://github.com/brson/rustray
- marshray 15y agoI liked the part about 'immutable by default'. I would love to have that in a language (as long as the 'mutable' keyword was something shorter :-).
- masklinn 15y ago> as long as the 'mutable' keyword was something shorter :- That's one thing I really like, actually: use of mutable structures should be avoided, making mutable structures harder to use (because they require a pretty long extra keyword) is a good way to drive developers towards immutable equivalents. See it as shifting incentives.
- marshray 15y agoOK, but the goal isn't to be Haskell here, or even ML. Those languages have all kinds of support for making immutable-everywhere a feasible goal (and the vast majority of developers still don't use them). If you want the language to be actually liked by people who develop large systems, it must be designed with its users in mind. 'Nanny' languages tend not to be very popular. In C++ "reinterpret_cast" is a good example of something that is long and ugly for a reason. But it's also be very rare, probably an order of magnitude or two more rare than mutable in Rust (just a guess).
- rmoriz 15y agoIf you reinvent the wheel you should at least have one plausible use case that shows the benefit of your square/wheel over existing solutions. Bonus points for real world examples.
- samth 15y agoImagine Firefox, but without segfaults, and using multiple cores. That's the use case. Rust is intended as a safe language for building a research browser that works in parallel.
- mapleoin 15y agoI find it really interesting that Rust itself requires all these languages to compile: g++ 4.4 or clang++ 3.x python 2.6 or later perl 5.0 or later Does anyone know why that is?
- gizzlon 15y agoLooks like mostly building scripts (documentation, tests ..) Guess they expect all platforms to have Perl and Python these days..
- fzzzy 15y agoThe perl dependency is from LLVM. Rust uses Python for utility scripts, "Just Because." Also, you left rustc off the list of languages required to compile rust. :-) It's self-hosted.
- nixarn 15y agoThey need to learn from Google how to present a new language. Although maybe they will once it reaches 1.0. When Google showed off Go they had some really great examples and a clean web page for it. Got me excited, this hasn't. Edit: Apparently there is http://www.rust-lang.org/ http://www.rust-lang.org/
- stewbrew 15y ago"They need to learn from Google how to present a new language" You mean like choosing a name that is easy to search on the internet?