Rust 0.3 released
github.com
github.com
Finally a programming language with decent syntax that does RAII, and understands the need to restrict garbage collection!
Thanks!
D, at the end of the day, is C++ with cleaner syntax. Yes, you've gotten rid of headers and some of the syntactic ambiguities, but things that were mutable are still mutable, templates are still templates, hard-to-solve threading problems are just as hard to solve, etc. Indeed, I'd argue this is one of the reasons why C++ coders generally like D: it's the same damn thing with the most painful dumbth removed.
Rust, on the other hand, focuses on having different semantics from C++, in order to make certain problems much easier to solve. The big one is immutability, which makes code easier to reason about, and vastly simplifies multithreaded code compared to its D or C++ counterparts. But there are other major semantic differences, such as region pointers, the lack of nulls, and more, that really solve the semantic issues that crop up in C++ programs.
I know people who like D, and are highly productive in it, but Rust is solving a very different problem in a very different way.
`string` is immutable. You can use immutable everywhere if you like. C++ doesn't even have transitive const.
> templates are still templates
With constraints, unlike C++.
> hard-to-solve threading problems are just as hard to solve
Have you looked at D 2.0? Globals are thread-local by default, unlike C++. Implicit sharing is disallowed, unless immutable.
> region pointers
It's early days (perhaps I don't fully get region/borrowed pointers yet) but D's `scope` parameter keyword seems very similar. It prevents an argument escaping the function call.
> lack of nulls
This is the big one. Unfortunately D doesn't seem to have an answer on this. I understand Rust uses option/sum types for this, which seems like a great idea.
Rust's per task GC seems like it should allow more flexibility, and I'm hoping it would be usable in the High Frequency Trading arena, for example.
That makes it sound like you can't use GC and manual memory management together; you can - std.container uses manual memory management internally for max efficiency.
https://github.com/mozilla/rust/wiki/Doc-detailed-release-no...
Download tarballs/docs/etc:
https://github.com/mozilla/rust/wiki/Note-development-roadma...
Will it ever be intended to replace application languages like Vala, Mono (used to write Tomboy, Banshee, etc.) or will it be restricted to system level stuff.
If yes, will there ever be scripting support (like Ocaml https://ocaml.janestreet.com/?q=node/80)
edit: Rust has a nice decentralized package manager as well called Cargo https://github.com/mozilla/rust/wiki/Doc-using-cargo-to-mana... ) Pretty nice.
Scripting support would be cool. To me, Rust isn't necessarily the best language to write small one-off scripts in; I personally prefer dynamically typed languages (or whole-program type-inferred languages) for that. But if you want to write scripts in Rust, I'd certainly review any pull requests to make it easier :)
I'm interested in this from a vision point of view. What are going to be your first "written-using-Rust" apps ? Firefox is gargantuan, so it cant be your first. Ergo, the question about platform toolkit compatibility. If you build that one first, you will start spawning an ecosystem almost instantly... if you want.
Mono, Vala, etc. have nice apps that people love. I am wondering on how can you bridge the gap between javascript/Qtscript and Rust to make it easier to build apps in.
Rust compiler is written in rust, so that would be the first "written-using-Rust" app. Additionally afaik the work on rust-based web-browser (engine) has began, so that would be second (major) project for rust.
Also, I personally believe that camel case for type names would be a net loss; the underscore separates the words nicely, and I think it's pretty clear from the syntax what is and is not a type name (in my extremely limited experience).
Back in the day, I used ObjectPascal, where we used camelcase for everything: function names, variables, types. Borland set an early precedent by prefixing many class types with the letter T, thus to visually distinguish them from other things: So you had TWindow, TButton, etc. This system makes sense when you see it in practice:
function GetParent(Window: TWindow): TWindow;
begin
...
While a bit crude, I feel the same kind of visual differentiation is needed for a language like Rust.Ruby has some syntactic oddities I like precisely because they provide visual classification: "@" for instance variables and "@@" for class variables:
class User
@@max_name_length = 32
def initialize(name)
raise "Error" if name.length > @@max_name_length
@name = name
end
end
The current "old-style" Rust code quickly becomes a uniform sea of lowercase to me, as does Stroustrup-style C++. It gets worse due to a quirk of mine to name things verbosely. So instead of variables like "u" to represent a user, I spell out "user". With all lowercase it gets odd: fn save(user: user) {
...
}
While Rust have types and variables living in separate namespaces, all-lowercase names introduces the possibility of ambiguity and possibly makes some things impossible in the future, I think; consider: let foo = user.new();
It looks like a method call "new()" on an instance "user". But what if you could call methods on types? With the discussion about the "::" operator becoming ".", such a distinction would become impossible without introducing a new operator. With camelcase it becomes obvious what's what: let foo = User.new();I'm sure camel casing will be controversial, but it makes sense given that Rust's primary audience is Mozilla, where camel case is the enshrined naming convention for its C++, Java, and JavaScript code. Python's standard library is an ugly example of what happens when the language community can't settle on one convention.
Also, I wonder why 21st century languages still use "&&" and "||" operators. Python's "and" and "or" operators are easier to read (for English speakers) and type. They don't require shifting of distant keys. "and" has two home row characters. "or" has fewer keystrokes than "||". :)
https://mail.mozilla.org/pipermail/rust-dev/2012-July/002087...
I wonder if anyone can explain why they have not tried to incorporate some of lisp's syntax as it is more efficient for linked lists I think. And I thought part of the reason for Rust's development was for very fast/efficient concurrency that is properly garbage collected.
Please provide some examples that show Io speed similar to Lua.
We're trying to iron out all of these issues.
Typestate's still there for the time being, but it may not be for much longer. The problem is that it's not being used anywhere in the compiler, so it's not getting exercised nor is it providing any constructive design feedback. Last year there was an attempt to begin using typestate throughout the compiler and standard library, but it proved so clunky to use in practice that nobody had any patience to deal with it. So now there are two camps among the developers: those who consider the (quite large) subsystem to be a useless maintenance albatross, and those who would still like the idea of typestate but who acknowledge that it's not usable in its current form. Rust's BDFL appears to be slowly migrating from the latter camp to the former, so typestate may not be around for much longer.
Either way, making the whole thing work would require more effort than anyone has time for at the moment. Of course, this doesn't mean that it can't be removed now and then reintroduced in some future version of Rust.
Actually, wait, I remember asking Graydon (the Rust lead) about this. I was saving this for the 0.3 release discussion, so now's the perfect time:
me: so what were the reasons that nobody ever used typestate? was it just too cumbersome?
graydon: combination of incomplete and wound up not often able to benefit from much code-path-distance between site of check and site of constraint-enforcement.
graydon: I'm still unconvinced that could not be overcome
graydon: but the result is that using it has effectively caused all callers to do checks just before they call, which isn't much of a win
me: graydon: was typestate the whole reason you started rust in the first place? I'd be really interested to read a retrospective :)
graydon: no, I started rust because I was sick of hacking in C++ and wanted something with a saner compilation model, grammar, safety properties, concurrency properties ...
graydon: I'd used lots of other languages and kept not being able to use them in an industrial setting, because they failed to be similar-enough to C++ in important ways, usually.
graydon: typestate was just a property that hermes had that I liked because it looked like a way to statically optimize DBC, which I like in languages that have it
graydon: (sather, eiffel, some of the C# derivatives)
graydon: I tend to program over-defensively when left to my own devices. make copies of every datum to be local. make everything const. run a lot of internal consistency self-checks. etc. etc.
graydon: (the one habit I hadn't picked up yet, which I'm still trying to, is adequate unit testing and fuzzing ... sigh)
me: graydon: so are you confident yet that even if someone was forcing you to write rust, you would't be sick of it? :)
graydon: my experiences writing rust so far have been pretty positive. it has a number of the parts I like in other languages. the grammar is simpler, the compilation model is better, it's AOT and static, it has algebraic types, clear integer types, is eager and reasonably fast, doesn't force OO style...
graydon: and crucially: doesn't need to allocate / GC like crazy, so can close that residual gap on inner loops without having to hit the FFI
graydon: there are still odd bits we need to whittle down
graydon: oh also the safe references are lovely. and getting better.me: so what were the reasons that nobody ever used typestate? was it just too cumbersome?
graydon: combination of incomplete and wound up not often able to benefit from much code-path-distance between site of check and site of constraint-enforcement.
graydon: I'm still unconvinced that could not be overcome
graydon: but the result is that using it has effectively caused all callers to do checks just before they call, which isn't much of a win
me: graydon: was typestate the whole reason you started rust in the first place? I'd be really interested to read a retrospective :)
graydon: no, I started rust because I was sick of hacking in C++ and wanted something with a saner compilation model, grammar, safety properties, concurrency properties ...
graydon: I'd used lots of other languages and kept not being able to use them in an industrial setting, because they failed to be similar-enough to C++ in important ways, usually.
graydon: typestate was just a property that hermes had that I liked because it looked like a way to statically optimize DBC, which I like in languages that have it
graydon: (sather, eiffel, some of the C# derivatives)
graydon: I tend to program over-defensively when left to my own devices. make copies of every datum to be local. make everything const. run a lot of internal consistency self-checks. etc. etc.
graydon: (the one habit I hadn't picked up yet, which I'm still trying to, is adequate unit testing and fuzzing ... sigh)
me: graydon: so are you confident yet that even if someone was forcing you to write rust, you would't be sick of it? :)
graydon: my experiences writing rust so far have been pretty positive. it has a number of the parts I like in other languages. the grammar is simpler, the compilation model is better, it's AOT and static, it has algebraic types, clear integer types, is eager and reasonably fast, doesn't force OO style...
graydon: and crucially: doesn't need to allocate / GC like crazy, so can close that residual gap on inner loops without having to hit the FFI
graydon: there are still odd bits we need to whittle down
graydon: oh also the safe references are lovely. and getting better.
Or make use of F# for Windows scripting, using as excuse to the boss that it is part of Visual Studio.
And, I think the answer is no, Mozilla doesn't do any production-ready work with Rust.
[1]: https://github.com/mozilla/rust/wiki/Doc-project-FAQ [2]: https://github.com/mozilla/rust/wiki/Doc-language-FAQ
Vs OCaml it has a threading model. Vs D memory safety, less kitchen sink. Vs C++ cleaner, better type system, memory safety. Vs Objective C memory safety, cleaner. Vs vala I don't know anything about vala. Vs go Here is their list of problems with Go from their website: Shared mutable state. Global GC. Null pointers. No RAII or destructors. No type-parametric user code.