Mozilla Is Designing a New Programming Language Language Called Rust
readwriteweb.com
readwriteweb.com
There was no need for assembly -- writing straight machine code worked. There was no need for C -- writing straight assembly worked. Etc, etc.
There has never been a need for a new programming language, but new programming languages can make life easier, can save you time, can make new optimizations possible, etc. So he's right in that we flat out don't need any more programming languages, but that doesn't mean creating new programming languages is a bad idea, or something we shouldn't do.
For me the ideal language would : - Support OO, imperative and functional paradigms - Compile to fully optimized machine code with efficiency comparable to that of C - Provide language support for numerical multidimensional arrays and linear algebra with a syntax comparable to Matlab - Support list comprehensions - Provide map,list and set types similar to those of Python - Support dynamic typing - Support optional static typing, and contracts - Provide standard libraries with breadth of functionality comparable to those of Java but simpler API's (more like Python) - Provide a mechanism for efficient compile-time parametrization of algorithms, like C++ templates - Support free-form (ie. whitespace independent) syntax - Provide a high quality cross-platform GUI toolkit with support for OpenGL - Provide an interactive graphical environment for experimentation and data analysis - Provide a dataset abstraction similar to R data frames - Be supported by a high-quality IDE and debugger
Of course that's a lot to ask for, but it would be nice to be able to do everything with a single unified syntax and environment.
> Support OO, imperative and functional paradigms
Yep. Objects aren't used all that often but they are fully supported and can do some things that are difficult in Java or C++ eg http://caml.inria.fr/pub/docs/manual-ocaml/manual007.html#to...
> Compile to fully optimized machine code with efficiency comparable to that of C
Not quite, but ocamlopt generates pretty damn fast code and, more importantly, has very predictable performance. Ocaml makes a pretty good systems language as demonstrated by the recent Mirage paper: http://anil.recoil.org/papers/2010-hotcloud-lamp.pdf
> Provide language support for numerical multidimensional arrays and linear algebra with a syntax comparable to Matlab
No, but this would make a good Jane Street summer project. Ocaml has extensible syntax via camlp4 and bindings to R, GSL and Matlab (no octave bindings for some reason).
> Support list comprehensions
Yes, as a syntax extension. http://batteries.forge.ocamlcore.org/doc.preview:batteries-b...
> Provide map,list and set types similar to those of Python
The syntax is not as nice but apart from that:
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Map.Make.h...
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Hashtbl.ht...
http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Set.S.html
> Support dynamic typing
Nope. You can circumvent the type system using Obj but its generally not advisable.
> Support optional static typing, and contracts
Static typing - yes. Contracts - see eg
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.157...
http://perso.eleves.bretagne.ens-cachan.fr/~dagand/opis/opis...
> Provide standard libraries with breadth of functionality comparable to those of Java but simpler API's (more like Python)
No. Ocaml Batteries is a start but nowhere near as broad as Python or Java.
> Provide a mechanism for efficient compile-time parametrization of algorithms, like C++ templates
Not just compile time specialization but multi-stage compilation via MetaOcaml. See eg http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.73....
> Support free-form (ie. whitespace independent) syntax
Yep, although there are some issues with the syntax eg dangling-else-like problems with nested matches.
> Provide a high quality cross-platform GUI toolkit with support for OpenGL
Well tested bingdings to Tk, Gtk and OpenGL.
> Provide an interactive graphical environment for experimentation and data analysis
None that I know of. I tend to use matplotlib and opengl interactively from the repl but its not up to the standards of mathematica etc.
> Provide a dataset abstraction similar to R data frames
I dont think so. I haven't used R much so I don't know exactly what features are missing.
> Be supported by a high-quality IDE and debugger
There are a couple of IDEs but none of them seem to be very well polished. Ocaml-mode and emacs is generally the way to go.
The time-travelling ocaml debugger is pretty amazing. You can also compile with support for gdb for low level debugging.
*Have you seen this Google language, Go? How does Rust compare?*
Yes.
Rust development was several years underway before Go
launched, no direct inspiration.
Though Pike’s previous languages in the Go family
(Newsqueak, Alef, Limbo) were influential.
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.
There are a number of other fine coroutine / actor
languages in development presently. It’s an area of
focus across the PL community.The other points seem pretty dead-on.. Rust seems to prioritize safety over simplicity, which is probably a good thing.
* Rust does not have NULL!!
* Rust has parametric polymorphism.
* Rust has more predictable memory/cpu usage thanks to forgoing global GC for a novel memory management model based on stack allocation/RAII, immutability, isolated processes and reference counting.
* Rust has a very Erlang-like model of handling failures.
* Rust has typestate, which is an easy to use way of proving properties about your program statically, or check them dynamically via assertion.
* Rust has no shared mutable state.
Those are facts. My personal, more subjective, opinion is that Rust is a lot better thought out than either D or Go. If this niche is too crowded, I'd rather see them go and Rust win. :) But given that Rust lacks shared global GC, I guess you could say it's closer to C++
Actually, anybody have a link to some non-trivial Rust code?
That hardly strikes me as a feature. Null pointers simplify a lot of error-checking. Don't know if what you got back was valid? As easy as checking to see if it's zero!
Rather than, "oh crap! every single variable could potentially be null at any time!", the few functions that can be null make you check for None / Some 'a, and that's it, no tedious null checks ever again. "Null pointers simplify a lot of error-checking.", my ass.
Contrary to ML, it doesn't require variables to be initialized when declared. The typestate system checks (statically) that they are not referenced before initialized.
What's the point, then?
Look deeper, there is a rich world of Programming Language history and research linked from Rust's FAQ. Don't cling to your Java or C/C++ null pointers.
Deleted comment
The boundary between a file format and a programming language is fairly fuzzy too.
I recently created a custom "little language" as a replacement for some rather fragile configuration routines. It won't need a lot of users to be a win.
(and no, it wouldn't have been faster/easier to use Lua/Ruby/Python etc).
We absolutely don't need any more languages. Languages aren't a problem that needs fixing.
But they're fun to create, which is why people keep creating them. Also it's very much a 'social' and fashion driven thing. Some people can't bear to be using 'last years' language.
Keeping Multicore machines busy is a problem that needs fixing and it's also an example of a problem amenable to a solution in the form of a new language.
http://gigaom.com/2008/06/19/multicores-not-so-secret-proble...
edit: Thanks for the downmod to 0. It really does speak volumes.
http://news.ycombinator.com/item?id=1498528 http://news.ycombinator.com/item?id=1498233
Rust's design decisions make much more sense than Go. Rather than designing C+++, they've ditched shared mutable state, a global GC and null pointers, and the stupid parts of the C syntax.
As Moore's Law for processor speeds hits a wall, programmers are going to have an incentive to take advantage of the parallel/multi-core CPUs that are appearing in lieu of actually faster CPUs.
Parallel programming is inherently less general-purpose than single threaded programming - there are a narrower range of things that you can do really quickly. I'd suspect that even doing that narrower range well will be more dependent on the memory/communications/threading model you use.
If this is true, it seems logical that we'll see a wider variety of languages in the future rather than having things consolidate. One language might better for simulation, another for 3D manipulation, etc. I'd also imagine chip-makers would start to look at the languages which can target
The standard Von Neumann architecture has allowed the general purpose computer to be relatively dominant product (even purpose built-machines often just leverage general-purpose chips). Parallel architecture would tend to allow the reappearance of purpose-built machines so-designed from the ground-up with all the differentiation that this world previously had.
Also, I've always felt queasy about using -> or => as arrows. And the word 'let' instead of 'def' or 'var' gives me a strange flashback to middle school which I can't quite pin down.
I agree about the 'let' part. Why isn't "int i = 0;" sufficient?
If the keyword really bothers you that much, couldn't you fork the project and perform a global find/replace? (yes I realize that _maintaining_ a fork like that could be nightmarish, but the point still stands)
Where "modern" means "any non-utterly-stupid compiler built in the last 40 years or so".
Literals can map to multiple types, and there hasn't yet been discovered a satisfactory way--apart from guessing in cases of ambiguity--to support type inference for literals.
(It's a reasonable opinion, albeit not mine.)
*Have you seen this Google language, Go? How does Rust compare?*
Yes.
Rust development was several years underway before Go
launched, no direct inspiration.
Though Pike’s previous languages in the Go family
(Newsqueak, Alef, Limbo) were influential.
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.
There are a number of other fine coroutine / actor
languages in development presently. It’s an area of
focus across the PL community.
tl;dr, Rust seems to not ignore the last 20 or 30 years of computer science.I never understand people who complain that free project X exists, when those people could be working on Y which is obviously more important. As if production and enthusiasm were both zero-sum and fungible.
Also, as someone who works with systems languages every day, I can tell you that there's a need for this work. I'm not saying Rust is it, but the systems language space is pretty dead, which is scary in a world where processors are threatening to become parallel on scales we don't know how to deal with with traditional tools.
But if you ask me "Do you agree?", well do you want my answer, or do you want me to simply say, "If that's where your passion is".
My honest answer, no I don't agree. I don't think we need a systems language of this sort. And I think there's a bigger gap that I'd like to see Mozilla work on, although maybe this blog post author isn't the right person to work on it.
It's unfortunate that the most popular platform in the world will continue to look like it was cobbled together by CS 101 studwents who weren't particularly great students, and were drunk.
People thought Windows 2.0 was bad as a platform. It's like we have Windows 2.0 for the life of the web because there's too many vendors in conflict to actually make it decent.
Both the JVM and the CLR fail to run other than their premier languages, or nearby languages, very well (fast enough or with all features in the "port"). Continuations? Hah. Invokedynamic has taken way too long and the JS VMs have run laps around the JVM.
Yes, browser vendors will also not agree, and for these good reasons among other more "selfish" ones. Get over it.
This would be a long lead item, but one worth doing. I know the Mozilla folks got a kick out of the recent IE9 DCE issue, but I think most people who don't really care about your rivalry, agreed with your assessment, but thought that it continued to show how broken that JS is as an IL.
The point of doing this is to really get a bytecode that will allow language designers to build performant languages that still are first class citizens in browsers.
Unfortunately, the end result, as you say, is that we as developers need to simply get over the fact that we should expect more of our vendors.
It's ironic that people speak of everyone will build webapps with HTML5, yet when Apple and Palm pushed web-centric apps, no one showed up. When they moved to a "desktop"-model, the apps came. Its apparent why. The web doesn't care about devs -- and unsurprisingly the shallowness of most web apps is the result.
That IE9 Dead Code Elimination JS optimization that seemed strangely overtuned for one SunSpider test has nothing to do with JS source vs. bytecode. It does show how poor the industry-standard benchmarketing tests are (Apple is fixing to use the result of the loop, btw).
If you assume DCE happens upstream of transformation to bytecode, you assume more tooling than most web developers I've spoken to prefer to run. And anyway, web developers generally don't write useless yet computationally expensive loops!
But let me agree that it's possible a bytecode for JS could catch on, if only it could be standardized and implemented in all the top browsers.
Then we would have the versioning and future hostility problems I've mentioned, along with some other languages than JS being developed, which might or might not catch on.
So why don't we standardize some (or any, to read your comments) bytecode? I listed reasons including NIH and patents. Those are the "bad" ones but they're real. I don't think they afflict Mozilla, so kindly spare me your inflamed sense of grievance against "vendors".
Regarding web-based apps vs. native apps, see:
http://www.avc.com/a_vc/2010/11/html5-mobile-apps.html
and also
http://www.emarketer.com/Article.aspx?R=1008010
Opinions vary, but web-based apps if not "web apps" are trending up, not down.
But high-performance JavaScript VMs and rendering engines are not written in JavaScript; today they are mostly written in C++. Rust is designed by and targeted at the people implementing the VMs. It's the language they hope to use to implement future JavaScript compilers.