9 ms·
> but it’s the first language I’ve experimented with that has made them a first-class feature It is a feature of ALGOL68, Pascal, Ada and quite some newer lang
by flyx86 10y ago
> but it’s the first language I’ve experimented with that has made them a first-class feature
It is a feature of ALGOL68, Pascal, Ada and quite some newer languages:
https://en.wikipedia.org/wiki/Tagged_union https://en.wikipedia.org/wiki/Tagged_union
- Manishearth 10y agoOne interesting thing about Rust is that none of the language features are really new. Even the borrow checker is from research papers and languages from quite a while ago. The only thing I can think of that might be truly unique to Rust is the concurrency safety model (Send+Sync), though that might be old too. Rust has just managed to take all these features and put them together well, and strive to be more than a research language by working on things that would make others actually use the language. (Of course, this particular feature is common in many, many languages)
- vvanders 10y agoYup, a lot of people like to say X has Y, however execution of Y is just as important(if not moreso) than the initial idea of Y. Technical ideas don't thrive in isolation, they need to be nurtured and grown. Just look at the dominance of Javascript in the programming landscape, you're seeing decades of high quality executions of the language(I include community in the "execution" definition) despite it being far from the best technical language.
- junke 10y agoAda and Pascal are not really research languages, though. But still, there are improvements taken from research, see Ada 2012 contracts for example.
- Manishearth 10y agoRight, like I said, this particular feature exists in a million languages. I'm talking about the whole set of features that Rust has; some are from research languages and may have never been seen in the industry before (e.g. regions/borrow checking), but they're not really new. This particular feature in Rust descended from the ML family (since Rust used to be ML-like), which in turn probably got it from Ada or w/e.
- nv-vn 10y agoML predates Ada by about 7 years, so that's unlikely. The way it is implemented in ML is most likely just an implementation of the mathematical concept of sum types rather than a feature influenced by existing programming languages.
- Manishearth 10y ago> ML predates Ada by about 7 years, so that's unlikely. Ha! I didn't know that. Thanks :)
- optimuspaul 10y agosorry if this is a dumb question, but what classifies a language as a research language?
- bluejekyll 10y agoThat's a great question! I would probably restate it though. What is research vs. a product. I just read about 1nm transistors, but we're probably looking at 10 years before Intel, et al, have built all the infrastructure to reliably deliver a CPU based on it. In the case of a language, I would say it's similar, do you have the support infrastructure in place? Rust is amazing in this regard: Cargo, crates.io, docs.rs, rustup, etc. on top of that you have at least one large company and many others pushing the language in a large and distributed product. I would classify Rust as a production ready coding platform.
- optimuspaul 10y agoThanks! It seems very obvious now. I was thinking the purpose of the language was for performing research, but that didn't make much sense. I see now that it's the language itself that is the subject of research, not the tool. English is fun.
- grayrest 10y agoThere are lots of languages in the world. The majority of them are written by a single person for themselves or (if there's funding involved) a small group of people who deeply understand the compiler. These are either research, hobbyist, or company languages depending on the context of the author. They exist to explore a particular idea or solve a specific problem and don't aspire to be widely used. If you hear the term used disparagingly it's because they tend to have issues you generally wouldn't want to put up with when you're on the clock: compiler bugs, lack of error messages, large missing pieces in the standard lib, spectacularly bad performance, etc because those weren't the problems the language was meant to explore.
- dannyobrien 10y agoYes, worth noting that this was an initial goal of Rust: to use research that was rarely implemented, but established and non-novel among CS academics. See http://tim.dreamwidth.org/1784423.html http://tim.dreamwidth.org/1784423.html -- I remember some comment about this being part of the choice of the name, too, but I can't find anything specific or definitive about that.
- Manishearth 10y agoThe name "Rust" has so many origin stories; IIRC the creator kept changing the story each time he was asked :)
- rurban 10y agoPutting them well together in Rust is debatable. Writing proper and safe concurrent code in Rust still looks horrible compared to languages which supports it natively in the type system, e.g. ponylang type capabilities. You still have to manually maintain locks, and it's also much slower. There's a safety model, but it's only best practice, not enforced by the language nor the compiler. So calling it "safe" and "truly unique" is way off. Even parrot has a better, safe and lockless threading model, which guarantees safety.
- gpderetta 10y agoHaving a language-imposed concurrency model would be useless and actively harmful in a system language. Rust provides the building blocks to build whatever safe abstractions are appropriate for the problem and domain at hand, plus a set of out of the box abstractions relatively low level that will be familiar to people coming from other system languages. And of course the means to get rid of any abstraction and safety when required. edit: accidentally a word
- rwmj 10y agoOnly if development of the language and OS are separate. If you co-develop the language with the OS, then it makes perfect sense to push safety features into the language (or conversely, to remove them from the language when they are no longer appropriate). LISP-strength macros give you most of this capability.
- bandrami 10y agothe concurrency safety model (Send+Sync), though that might be old too Smalltalk has had that since the early 1980s
- Manishearth 10y agoInteresting, thanks!
- steveklabnik 10y agoI'd like to read more about this, do you have a recommendation of where I can look? I have a basic fluency in Smalltalk, but it's been a while.
- gpderetta 10y agothat's interesting, AFAIK smaltalk is fully dynamic and has no compile-time type checking, so how would it statically enforce the equivalent of Send and Sync constraints?
- stcredzero 10y agoIn most implementations, Smalltalk is compiled to bytecode, and uses late binding. It's usually run on a JIT. how would it statically enforce the equivalent of Send and Sync constraints? In some Smalltalks, normal execution is synchronous. Many of them also use read and write boundaries for various purposes. The former gives you Send and Sync constraints for free. The latter can be used in difficult edge cases. (Like when you're calling out to the OS.)
- Manishearth 10y ago> The former gives you Send and Sync constraints for free. Uh, no, it gives you thread safety for free. When my comment was talking about Send and Sync I was talking about the specific way Rust's typesystem enforces thread safety. I'm not saying that other languages don't, I'm saying that Rust's method of enforcing it might be one of the few unique things it does
- 10y ago
- catnaroek 10y agoIndeed. Regions are 20 years old. Substructural types are 30 years old. Type inference is 40 years old. Hierarchical module systems fancier than Rust's are at least 30 years old. With the exception of regions, all this stuff is older than I am, myself. But Rust took all these isolated good ideas and made a practical programming language out of it.
- pcwalton 10y ago> Even the borrow checker is from research papers and languages from quite a while ago. Eh, that's underselling Rust's contributions. Rust is more flexible than anything I know of when it comes to enforcing aliasing-xor-mutability. Cyclone for example was much more restrictive in disallowing aliasing (see Grossman's "Existential Types for Imperative Languages"). The key feature that Rust has is flow-sensitive permissions on unique loan paths, which is actually pretty novel as far as I'm aware.
- Manishearth 10y agoI guess, yeah. I meant that what Cyclone does is along the same lines. > The key feature that Rust has is flow-sensitive permissions on unique loan paths, which is actually pretty novel as far as I'm aware. Huh, right.
- barrkel 10y agoThe tag in Pascal is (a) optionally stored (only the type of the tag is needed to distinguish between the different variants in the declaration, the field can be omitted) and (b) not actually strongly typed (that is, the tag is not consulted before access to one of the variants is made). It is however a fine way to encourage sensible use of unions. But it's mostly just a suggestion.
- titzer 10y agoThey look a lot nicer in ML and Haskell, IMO. Of course I implemented them in Virgil, too. (shameless plug: https://github.com/titzer/virgil https://github.com/titzer/virgil)
- harrisi 10y agoI don't intend to derail the discussion further, but I'm curious about Virgil. I can't find any information on it that tells me who is behind it or how to contact them. Do you have anywhere I could look to learn more about the project in general?
- titzer 10y agoSure! It's pretty much just my perennial side project since at least 2004. Some information is available in publications (latest: http://dl.acm.org/citation.cfm?id=2491962 http://dl.acm.org/citation.cfm?id=2491962), and there is some documentation in the wiki branch (https://github.com/titzer/virgil/tree/wiki https://github.com/titzer/virgil/tree/wiki).
- dkersten 10y agoI've come to the conclusion that most "modern advanced" features were actually in ALGOL. Algebraic datatypes with (even just basic) pattern matching (preferably with compile-time exhaustiveness checking) are things I've wanted in C++ ten years ago. This gets me part of the way there, at least. :)
- masklinn 10y agoThey're specifically saying that it's the first language they've experimented with, not the first language in general, FFS.
- frankmcsherry 10y agoI know, right. The full quote is apparently less fun to argue against: > I’m aware the idea for type-safe unions isn’t unique or original to Rust, but it’s the first language I’ve experimented with that has made them a first-class feature.