7 ms·
Rust 0.4 released
- kibwen 14y agoThe note regarding "preliminary JIT support" buried at the end is one of my favorite new features (and it's a tough call, since there's so damn many new features), since it makes stuff like this possible: https://github.com/bleibig/rust-repl https://github.com/bleibig/rust-repl I hear that LLVM's JIT support is rather untested, I'd be interested to learn if there are any other major projects besides Rust making use of it. In general, if you haven't checked out Rust yet I'd still recommend waiting until the implementation of traits is finished off (scheduled as a high priority[1] for 0.5, which is tentatively scheduled for sometime around year's end). [1] https://github.com/mozilla/rust/wiki/Note-0.5-priorities https://github.com/mozilla/rust/wiki/Note-0.5-priorities EDIT: Oh, and here's a direct link to the detailed release notes rather than the summary presented in the OP: https://github.com/mozilla/rust/wiki/Doc-detailed-release-notes https://github.com/mozilla/rust/wiki/Doc-detailed-release-no...
- dchest 14y ago> I hear that LLVM's JIT support is rather untested, I'd be interested to learn if there are any other major projects besides Rust making use of it. Sure, OS X since 10.4. http://llvm.org/Users.html http://llvm.org/Users.html
- onetwothreefour 14y agoOS X does not use LLVM JIT.
- capnrefsmmat 14y agoFrom the link: > Mac OS X 10.4: Uses the LLVM JIT for optimizing many parts of the OpenGL pipeline, including emulating vertex/pixel shaders when hardware support is missing, performing texture format conversion before uploading to the GPU, efficiently packing GPU buffers for vertex submission, and many others. > Mac OS X 10.6: The OpenCL GPGPU implementation is built on Clang and LLVM compiler technology. This requires parsing an extended dialect of C at runtime and JIT compiling it to run on the CPU, GPU, or both at the same time. http://llvm.org/Users.html http://llvm.org/Users.html
- potkor 14y agoAlso, Mesa / Gallium3D.
- doublec 14y agoI believe Pure uses LLVM JIT https://code.google.com/p/pure-lang/ https://code.google.com/p/pure-lang/
- cliffbean 14y agoLLVM's JIT isn't a monolithic entity. There are a bunch of different components and feature options. Some paths are mature and well tested, and others are not. As a result, some projects are using it quite successfully, and some projects with different needs have different experiences.
- Tobu 14y agoIndeed: http://qinsb.blogspot.com/2011/03/unladen-swallow-retrospective.html http://qinsb.blogspot.com/2011/03/unladen-swallow-retrospect...
- cpeterso 14y agoWhat is the use case for a Rust JIT? A REPL or runtime eval()? I though the static compilation of Rust code was one of it selling points.
- dmorgan 14y agoProminently, on the parent comment: it makes stuff like this possible: https://github.com/bleibig/rust-repl* https://github.com/bleibig/rust-repl*
- duaneb 14y agoI think Rust's attractiveness is due to its type system, which does not necessarily need to be statically compiled.
- masklinn 14y agoConversedly, you can have compilation and a REPL, Clojure has a repl yet is always compiled (repl instructions are compiled to JVM bytecode using the usual compilation toolset, then that bytecode is loaded and executed). According to http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-compiled.html http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci..., GHCi's name doesn't lie and it's actually an interpreter.
- Tobu 14y agoA REPL is extremely useful for learning, debugging (instead of using print statements, embed an interpreter to see exactly what is going wrong — IPython's one-line embed() for example), sketching (embed into an incomplete part of your program, try out a few things, when it works paste it to your source), and documentation (IPython's ? and ?? — completion is also part of that).
- kibwen 14y agoNotice that the first link I posted there is to a working Rust REPL (though it's rather rough at the moment, there's a lot that could be done to improve it).
- leeoniya 14y agowonder why ret -> return was decided on. the former is sufficiently clear me thinks, shorter too.
- erickt 14y agoWe like brevity in our keywords, but we felt that "ret" was taking things a little too far. "return" met our 5-characters-max criteria, so we switched. edit: Ho ho ho, I can't count. And we don't really have a 5-character-max criteria, but we do prefer shorter keywords.
- lmkg 14y ago> "return" met our 5-characters-max criteria I'm curious as to how this conclusion was reached.
- freditup 14y agoWell, the actual keyword is retum. It turns out that most humans can't tell the difference between an r and an n next to each other, or the letter m, so they just decided to go with the quicker to type 'm' instead or 'rn' You've just been reading it wrong. :D Honestly, I think either ret or return is fine, but I'd match other keywords. So if you're using pub and priv instead of public and private, I'd use ret instead of return as well.
- squires 14y agoThe 'r' is the zeroth character of course.
- erickt 14y agoOh boy I can't count. That criteria is a little tongue-in-cheek. Basically the core developers decided saving those extra three characters wasn't worth it. We implicitly return the last expression, so "return" is typically only used for an early exit. Therefore it's more approachable to new users, and pretty rare so it doesn't add much clutter.
- zobzu 14y ago
- Jare 14y agoMy impression is that their push to remove keywords is hurting the readability of Rust code. They also seem undecided about the keyword length issue. In any case, it's really interesting to witness the evolution of the language.
- pcwalton 14y agoWhich keywords did you like that were removed?
- Jare 14y agoRemoving 'again' to overload the meaning of 'loop' for example.
- pcwalton 14y ago"continue" is very long (out of place with the rest of the keywords), "again" was quite unpopular ("next" is out in a systems language due to linked lists), and the construct isn't used very often anyway (just a handful of places). A lot of people like languages with small sets of keywords (for example, Python, Lua, or Go). It helps you keep the whole language in your head. We wanted to replicate that.
- Jare 14y agoI understand, and I can only imagine all the debates about naming, which programmers seem to love. My point is just that by multiplexing a keyword, you shift the cost from one-time in-head knowledge of two keywords, to having to look at the context every time the keyword appears. My personal preference is to reduce the cost of reading code above everything else (which is what turned me off the otherwise wonderful to write CoffeeScript, for example).
- hamstergene 14y agofor-while-break-continue is such a standard, I still don't see what justifies breaking it. (Do you really have less-than-N-characters rule? :) ) That fact that `continue` doesn't appear often is exactly why it has never been annoying to type. What if there are three nested loops, two of which contain if-cond-then-continue, wouldn't the new syntax be too ambiguous?
- felixmar 14y agoNow that the language syntax is mostly stabilized, i am hoping that more focus will go to the standard library. Currently it seems rather ad hoc and not always consistent (which is understandable because of all the language changes).
- kibwen 14y agoAbsolutely, the standard libraries are sorely desperate for some TLC. If anyone fancies themselves a connoisseur of batteries-included libraries in the vein of Python and Go, even just stubbing out a nice API without any code would go a long way towards directing the community development effort.
- nickik 14y agoSounds intressting. Data Structure libs are one of the best cases to show of how cool and polymorthy your language can be. I dont know if that exists allready but I think I am going to implment a persisten vector (like clojure vector) in rust and see if it interacts nice with other libs. I have done with other languages, would give a lot of inside into rust.
- erickt 14y agoThat sounds great. We do have a basic package management system (https://github.com/mozilla/cargo-central https://github.com/mozilla/cargo-central), so it'll be easy to get anything you write into the community.
- ww520 14y agoOne thing I don't understand is the rational behind the decision that the returning expression in a block has to have the semicolon omitted. Why can't we just say the last statement of a block is the returning expression of the block, regardless of semicolon?
- masklinn 14y agoBecause — as in Erlang — the semicolon is a separator, and the expression's value does not go through it? So the type of `a` is A, but the type of `a;` is Unit.
- Tobu 14y agoSure, but I think readability and ease of editing should trump purity here (and I'm an OCaml user).
- deleted 14y ago[deleted]
- deleted 14y ago[deleted]
- ww520 14y agoYou meant semicolon is used as a binary operator, joining the statements into one long expression. Since it's an operator, its behavior can be defined to however make sense. Why not just say in the absence of the right operand, return the result of the left operand? Just like || (or) can return the result of left or right operand. So type of 'a' is A. Type of 'a;b' is B. Type of 'a;' is A.
- masklinn 14y ago> You meant semicolon is used as a binary operator Not necessarily no, I don't know how it works precisely in Rust but in Erlang it is not an operator, it's exactly what I wrote: a separator.
- mej10 14y agoSo what needs to be done in Rust? It seems like a pretty interesting language, and I have some free time coming up. What kinds of things would people like to see?
- kibwen 14y agoHelp would definitely be appreciated, there's a whole lot to do. See the issue tracker on Github[1] for a starting point. Filter by the "E-easy" tag if you just want to dip your toes. The "A-an-interesting-project" tag is where it gets, er, interesting; those issues represent projects that don't necessarily have a high-enough priority to block 1.0, but that everyone would love to see and that a single motivated, skilled contributor could conceivably produce. And if you ever need any help, check out the mailing list[2] or #rust on irc.mozilla.org (most active during Californian working hours). [1] https://github.com/mozilla/rust/issues https://github.com/mozilla/rust/issues [2] https://mail.mozilla.org/listinfo/rust-dev https://mail.mozilla.org/listinfo/rust-dev
- gbaygon 14y agoI cannot seem to grasp the scope of this language, so please if any of you fellow gentlemen could enlighten me, i would like to know: What plans does mozilla have for Rust? What are the projected applications? What personal project could be an ideal use case for it? Thanks!
- wmf 14y agoIt's basically a replacement for C/C++, but safer, with more functional flavor, and better support for parallel programming. If used properly, Rust should be faster than Java or Go because it can create non-garbage-collected objects. Mozilla is writing a parallel browser called Servo in Rust.
- zura 14y agoWhen a company declares some language X as a replacement for C/C++, X actually becomes replacement, or to be more precise, attracts engineers from some other language L, but C/C++ stays in place :)
- sbmassey 14y agoFrequently, yeah, but the Rust developers seem to actually have some idea what makes C/C++ successful, so I think it stands a better chance than Java/C#/Go.
- wladimir 14y agoIf they can make a safer, more secure and less verbose C/C++, without giving up on what makes C/C++ a good choice for some projects (low-level control and performance), I'm sure some people will switch (I know I will). It's just that no one succeeded in this before. It's just too easy to shoot yourself in the foot with the current C/C++. Combined with developers overestimating themselves and a lack of static checking by compilers, this results in all kinds of hard-to-debug and hard-to-find issues. A language that guarantees no dangling NULL pointers, no buffer overflows and safe concurrency/parallelism is a great promise, at least. Hopefully it gains enough critical mass. We'll see where this goes...
- dochtman 14y agoIIRC, typestate was one of the big things in the initial releases/presentations of Rust. Is there an overview/discussion/ideas on why it ended up being removed?
- doublec 14y agoOne such discussion in the mailing list: https://mail.mozilla.org/pipermail/rust-dev/2012-July/002094.html https://mail.mozilla.org/pipermail/rust-dev/2012-July/002094... An example github issue discussing problems encountered: https://github.com/mozilla/rust/issues/1105 https://github.com/mozilla/rust/issues/1105
- kibwen 14y agoI asked Graydon about this near the release of 0.3. Here's the exchange: 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.
- ternaryoperator 14y agoI'd like to know how Rust is better/different than Vala. Not the usual feature comparisons, I can look them up myself and have done. But rather if anyone's done programming in both and can compare the experience.