12 ms·
Rust - a new programming language from Mozilla
- ses 15y agoThis is an interesting new language but I'd be interested to know - what is the motivation behind its creation?
- jurre 15y agoMarijn Haverbeke, a freelancer hired by Mozilla to work on it mentioned that they plan on using it for their browser development to replace C++: http://lisp-univ-etc.blogspot.com/2012/04/lisp-hackers-marijn-haverbeke.html http://lisp-univ-etc.blogspot.com/2012/04/lisp-hackers-marij... "Rust is a programming language that's supposed to fit the C++ niche, without the insanity of actual C++. If the project works out, and it's going swimmingly so far, Mozilla will try to apply it to writing a next-generation browser, without the constant danger of buffer overrun exploits and threading bugs that comes with C++. True to Mozilla's spirit, all development on Rust is happening in the open, on github."
- sanxiyn 15y agoMozilla is writing Servo, a parallel browser engine, with Rust. http://smallcultfollowing.com/babysteps/blog/2012/03/28/servo-design/ http://smallcultfollowing.com/babysteps/blog/2012/03/28/serv...
- _delirium 15y agoWriting a new programming language from scratch in order to enable the writing of a new HTML rendering engine from scratch is at least ambitious!
- bzbarsky 15y agoIs it more or less ambitious than trying to take an existing large C++ single-threaded codebase and try to multithread it without introducing bugs or running into Amdahl's Law early on? That's the key question here...
- agumonkey 15y agofeels like ADA
- Gertm 15y agoYou make it sound like a bad thing. :p
- wglb 15y agoWhatever its merits (and it does have a few), it hasn't exactly been a popular choice outside of building fighter airplanes.
- stcredzero 15y agoThose three words are neutral. The "sound" was supplied by you. :P
- nicholasreed 15y agoCan you please add some more relevant information to your comment? Expand upon why you feel it is similar to ADA, why ADA might be a better (or worse) alternative, if you have any experience working with ADA/Rust, etc. A three word comment does not add anything worthwhile to this thread. If you're on HN and commenting, please refrain from throwing whispers of thoughts down as they come to you, and instead take the opportunity to reply with something meaningful.
- jurre 15y agoDid anyone find an explanation for why they opted for brackets in favor of whitespace or a ruby-like syntax?
- viraptor 15y agoMeta-comment: It's interesting how the default way changes with time... around 10 years ago it would be "why does ruby use the weird syntax instead of just brackets like c/java/js/...?"
- silon4 15y agoI'm waiting for python to fix "from __future__ import braces". Or at least make "pass" mandatory for end of block
- xd 15y agoBeing someone that has only ever programmed in languages that use brackets, I really, really don't get this white space thing .. it appears, to me at least to make reading code very difficult. With brackets I can scan a page of code and see the blocks of related code. What are the advantages to using white space?
- jurre 15y agoWell it's a personal preference of course but in my opinion it actually makes code much more readable. It forces everyone to use the same conventions for indentation and it gets the 'clutter (brackets)' out of the way so you can focus on what's important, the code. Blocks easily identified by their indentation. It might take a little getting used to but I find it very pleasant.
- 4bpp 15y agoI can't think of "forcing everyone to use the same conventions for indentation" as a purely good thing, any more than "forcing everyone to write comments in 18th-century English" would be. Sure, you make it easier for the random onlooker to be prepared to always immediately understand what is going on, but at the same time, the programmer who writes for his own perusal or that of a small team of known others will find themselves restricted by a totalitarian scheme telling them what they can express and what they can't. The assumption that most code is written for most people to read is simply not true, and code that is intended for the masses has always been able to deal with the problem by imposing style guidelines.
- joeycfan 15y agoAnd the learning curve of Sisyphus goes on and on....
- jentulman 15y agoCan anyone explain this, from the first paragraph, to a bog standard PHP-for-the-web programmer please? "Its design is oriented toward concerns of “programming in the large”, that is, of creating and maintaining boundaries – both abstract and operational – that preserve large-system integrity, availability and concurrency."
- scanr 15y agoHere's my attempt: - "Programming in the large" - programming produced by lots of people and/or meant to last a long time. - "creating and maintaining boundaries" - when you have a lot of people working on code, it's very useful to be able to isolate code and define the boundaries between code explicitly. Things like interfaces and type safety tend to help do this (the "abstract" in "abstract and operational"). On the "operational" side, having modules that produce dynamic libraries with good versioning semantics helps. - "that preserve large-system integrity, availability" - again, type safety, in-built null pointer protection and garbage collection all help make sure that code doesn't fall over as much as it could without those (there are some philosophical arguments in here that I'm not exploring). - "concurrency" - Consensus appears to be forming around the idea that a good way to manage concurrency is with lightweight processes and message passing rather than threads and shared state. Rust does the former. Rust also encourages the use of immutable state which also helps avoid concurrency issues.
- tomjen3 15y agoOne ofmthe original ideas of oop was that it would be possible to encapsulate how part of anrogram worked from the person who used it. You shouldn't have to care about the inner workings of the storage layer, say, or the gui toolkit. Unfortunately in reality things are usually not that well encapsulated. Things like threads, integration withe the system, etc often interfere as does things like the desire to test a particular piece of software. Basically think of it as enabling the same benefits you get from having a general count function over having specific functions for arrays, directories, lists, etc but to an enti system.
- bitcracker 15y agoI would recommend to read this story about Ada which is the preferred language for highest quality software: http://www.adacore.com/home/ada_answers/business_benefits http://www.adacore.com/home/ada_answers/business_benefits
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- zokier 15y agoPrevious discussions: * http://news.ycombinator.com/item?id=3774075 http://news.ycombinator.com/item?id=3774075 * http://news.ycombinator.com/item?id=3501980 http://news.ycombinator.com/item?id=3501980 * http://news.ycombinator.com/item?id=3027777 http://news.ycombinator.com/item?id=3027777 * http://news.ycombinator.com/item?id=2390980 http://news.ycombinator.com/item?id=2390980
- Maro 15y agoHow does Rust compare with Go? Their goal of being a modern systems programming language are similar.
- sanxiyn 15y agoThe goal is similar, means are much different.
- kxs 15y agohttps://github.com/graydon/rust/wiki/Doc-language-FAQ https://github.com/graydon/rust/wiki/Doc-language-FAQ Has a section called: "Have you seen this Google language, Go? How does Rust compare?" Excerpt: "Go adopted semantics (safety and memory model) that are quite unsatisfactory." Like Null pointers, global GC, shared mutable state etc.
- Maro 15y agoThanks for the link, I upvoted you. I'm a C++ systems programmer, so I'm trying to understand some of the issues here. I'm not familiar with either language, please forgive the ignorant questions. Null: Why is null evil? Doesn't Go use it in the Java sense of releasing a reference to the object? Global GC: Seems more like a runtime implementation choice? Shared mutable state: Doesn't seem so bad for someone approaching a systems programming language. I don't always want to make copies and send it over as a message to the other threads? My higher-level point is that, perhaps these languages could do a better job of selling, differentiating, explaining themselves. I know it's hard, that's why I'm trying to help by posing my stupid questions. Btw. if they're planning to write Firefox in this, maybe the author should maintain a minimal browser written in Rust to show how the language fits its original design goals.
- sanxiyn 15y agoNull is evil because it forces programmers to constantly check for null when compilers can do that much better. There can be situations when null is handy, but it shouldn't be the default. C++ reference can be used for similar purpose. Global GC is definitely a language issue. It affects language semantics. Avoiding shared mutable state does not mean making copies. If you can statically check there is no other reference you can avoid copying. Think advanced move semantics.
- kibwen 15y agoPlease note that Rust is very alpha alpha alpha at the moment. Syntax evolves constantly. Several concepts don't even exist yet, and many are present only in half-formed nascent states. The bottom line is that if you're interested in writing applications using Rust, you should really hold off until 0.4 or so (I'd say give it three months), both to give them time to implement all the missing pieces and then to refactor the Rust compiler to use those pieces, thereby shaking out the bugs and annoyances. But if you're interested in helping out on writing the compiler itself, or proof-of-concept libraries, definitely consider pitching in. The devs greatly appreciate volunteer contributions.
- tkahn6 15y agoThis is actually really cool in that it occupies a space between Haskell and Python. It seems excessively verbose at the moment but hopefully that will sort itself out in the end.
- kamaal 15y agoWhen will this ready for the real world? I mean an actual production release?
- kibwen 15y agoI guess it depends on what you mean by "ready". For instance, Go 1.0 was released just last week, but people have been building useful things with it for a long time now. I suppose it depends on how much instability you're willing to put up with in order to use the shiny new thing. As someone who follows the project closely, I do think that almost all of the core concepts will be present by 0.4 or 0.5 at the latest (fingers crossed), which would probably be the best time for eager early adopters to dive in. Also consider that Mozilla will be using Rust for experimental prototype browser engine implementations soon, likely even before 0.3 is released. But if you're looking for some semblance of stability, I'm not sure what advice I can give beyond "wait for 1.0"--which has no definite timeframe. The Rust devs don't even schedule minor releases more than two in advance, so Rust might jump directly from 0.4 to 1.0, or from 0.9 to 1.0, or from 0.367 to 1.0. But don't worry, when they do make the jump, I'm sure you'll hear about it on HN. :P If you'd prefer to track the project milestones yourself, check out the Github issues page[1] and browse the currently scheduled milestones from the dropdown in the left column. [1] https://github.com/mozilla/rust/issues?milestone=&sort=created&direction=desc&labels=&state=open https://github.com/mozilla/rust/issues?milestone=&sort=c...
- iamgopal 15y agoNow even I want to create a new programming language. for downvoters : pun intended.
- jchughes 15y agoThe syntax is horrible. I would prefer C over that.
- pcwalton 15y agoWhat don't you like about the syntax?
- luser001 15y agoInteresting language. Doesn't require JVM to run. I consider that a plus. But others might not.
- jmilkbal 15y agoI feel like I'm beating a dead horse, but I really can not grasp what the catalysts are for creating Rust or Go or Julia or other new languages that want to be safe, reliable, readable, etc.. 30 years ago these problems were solved in a language Ada. Its exact requirements include all of those and more. See for yourselves: http://www.adahome.com/History/Steelman/steelman.htm http://www.adahome.com/History/Steelman/steelman.htm Later revisions have well-though-out rationales that show off all the changes: Ada 95: http://www.adaic.org/resources/add_content/standards/95rat/rat95html/rat95-contents.html http://www.adaic.org/resources/add_content/standards/95rat/r... Ada 2005: http://www.adaic.org/ada-resources/standards/ada05/ http://www.adaic.org/ada-resources/standards/ada05/ Ada 2012(!!): http://www2.adacore.com/wp-content/uploads/2006/03/Ada2012_Rational_Introducion.pdf http://www2.adacore.com/wp-content/uploads/2006/03/Ada2012_R... The steelman was the end revision of requirements for the original language. There is a comparison of C/C++/Java/Ada wrt the steelman available as well. Ada has become so much more since this document and it's original version one really must see it to be believe it. :o) As a community we have a tendency to embark on projects on a whim, but the effort, time and money required to bring a language to maturity is enormous. Even then any deficiency a preexisting language may have surely is not so insurmountable as to make it viable to develop a new language in house. Can we please have some sanity? Can we please look for mature solutions? Edit: Ada has an amazing GCC frontend developed largely by a successful opensource company (with just massive customers across the globe) and is available across all of its targets: the bsd's, solaris, linux, mac, haiku, android and more. It's a great solution that is hard to ignore.
- tedunangst 15y agoI've used Ada. It was a super major pain in the butt. Go is like an easier to use C, where Ada is like a harder to use C. The solution to "people screw up dynamic allocations" is not "make dynamic allocations brutally difficult".
- jmilkbal 15y agoAda wants to catch as much as it can before runtime. To that end, it is one strict beast when you're used to all the willy nilly (and unsafe) constructs that we can beat C into doing. Ada absolutely is harder; it's built for hard problems. I don't intend to turn away from the topic of TFA, but Ada is on quite a different plane than C for a number of reasons--reasons that I think are compelling. C is wonderful for creating a foundation for low-level software as it has demonstrated for what seems like an eternity, but beyond that--and I think the crazy things we've done over time to make it a little easier to use reflect this--something with more high-level, safe, readable, yada, yada, yada is desirable if not absolutely needed. Dynamic allocations in Ada are a cinch by the way. We use the "new" reserved word. subtype Hacker_News_Article_ID is Natural; -- Numbers 0 .. Integer'Last; type Article_Handle is access all Hacker_News_Article_ID; -- "all" reserved word used allows access to variables on the stack. Favorite_Article : aliased Hacker_New_Article_ID := 3793716; -- "aliased" so we can point to this stack variable. Article_Pointer : Article_Handle := Favorite_Article'Access; -- A sensible default perhaps. later on... Article_Pointer := new Hacker_News_Article_ID (Whatever); Good luck!
- omi 15y agoRusted before any use was gotten?
- thealistra 15y agohttp://doc.rust-lang.org/doc/tutorial.html#pattern-matching http://doc.rust-lang.org/doc/tutorial.html#pattern-matching This is the whole reason why that language has such a big potential. It has high level algebraic datatypes with pattern matching, so you can nicely model your control flow (like haskell or ocaml) but still remaining low-level.
- ecubed 15y agoOut of curiosity, what's Mozilla's motivation for making a new language? Everything I'm reading here in the comments is talking about how this would be a replacement for c/c++, but wouldn't Mozilla be more interested in a language that's more web focused? As I see it, Rust would NOT be a web language, or am I missing something? Is this something they would try and develop future versions of Firefox in?
- gnuvince 15y agoThat latter; they want to be able to build a large and complex web engine and have it be as safe as possible without sacrificing performance.
- jorgem 15y agoLooks similar to F#
- zem 15y agorust seems to get compared to go a lot, simply because they are socially similar (open source c-like language developed by large, popular company). i'd like to see some comparisons with languages like clay and ats, both of which seem closer to what rust is trying to be.