8 ms·
Will someone with familiarity with both Rust and D talk a bit about the similarities and differences?
by dman 10y ago
Will someone with familiarity with both Rust and D talk a bit about the similarities and differences?
- FraaJad 10y agoAndrei Alexandrescu, one of chief architects of D answered this a while ago on Quora [1]. IMO, this is a fair and nuanced answer. [1] https://www.quora.com/Which-language-has-the-brightest-future-in-replacement-of-C-between-D-Go-and-Rust-And-Why?srid=hyT https://www.quora.com/Which-language-has-the-brightest-futur...
- k__ 10y agoHehe, I saw a talk with the creators of Rust, D, C++ and Go. No one of the "older" fellas even knew the Rust guy and I don't even know anymore who he was, was it Hoare? Maybe. C++ was about "We get things fixed, I promise!" D was about "We get shit done!" Go was about "We are good enough!" Rust was about "We try new shiny things!"
- kbenson 10y agoI'm not under the impression that all that much of what Rust does, besides borrow checking, is necessarily all that new. Aren't most the other things from other languages that have used them to good effect?
- k__ 10y agoTrue story. But look at the functional stuff. I mean how much of this is really in broad use? Yes at the moment there seems to be a functional renaissance, but before that 90% of the programmers around the world tought of stuff like Haskell or OCaml as crazy academical experiments.
- kibwen 10y agoWhat "functional stuff" are you referring to? I don't consider Rust a particularly functional language, other than the fact that it has closures and the ability to `map` over iterators. And if closures and `map` are your benchmarks for functional stuff, then Python, Javascript, and Perl have been doing functional stuff for decades now. :)
- nv-vn 10y agoThere is quite widespread use of monads in the standard library (albeit with a very targeted effort to hide their nature and make them very concrete).
- kibwen 10y agoCan you give an example? I can't think of anything in the Rust standard library that I consider a "monad".
- nv-vn 10y agoIterators are monadic (since they have a flat_map method), Option and Result have the and_then method. Both of these are equivalent to >>=/bind. The fact that they don't implement pure/return doesn't change the fact that they have monadic interfaces because that would only be useful once it was generalized to its own trait, and such a function would be trivially implemented for any of these types. For example, Some(x) works as the return/pure function for Option and the fact that the name differs for each type is not an issue because there's no way to make code generic over all monads as it is. It would be like having a unique trait for each type where there's `bind_option` and `bind_result`, etc.
- kibwen 10y ago`Option` et al may have vaguely monadic interfaces, but don't you need `return` in order to satisfy the monad laws? Regardless of what we determine there, I don't think that matters in the broader context of this thread, which concerns the notions that Rust has the potential to scare people away by including unfamiliar "functional stuff". But seeing an `.and_then` method doesn't scream "functional programming"; method chaining has been long popularized in Javascript, Ruby, etc. Furthermore, AFAIK there's nothing about Rust's pseudo-monadic interfaces on iterators that hasn't already been popularized by LINQ in C#.
- pjmlp 10y agoI guess I belong to those 10%. My first FP language was Caml Light in 1995, I was doing "LINQ" in Smalltalk on that same year and Prolog on 1996. Sadly not all CS degrees are how they should be.
- steveklabnik 10y agoOne of the reasons that "Rust" is the name is that Rust _doesn't_ try things that are "new and shiny." Or rather, it depends on where you come from: coming from the PLT perspective, many of the ideas in Rust are pretty old, but if you come from industry, they seem very new. (Also, the person who was in the video you're talking about was Niko Matsakis, not Graydon. And it was August 2014, so, so much has changed with Rust since then.)
- k__ 10y agoI see, thanks. Well, I don't know about how long any of these "ideas" were around somewhere buried in academia. What counts is that Rust tries things differently than Go, D or C++, so it's "new" in terms of an "implementation in broader use" I think you guys are going the right way :)
- makoConstruct 10y agoYo I came across a comment you made a while back asking whether there was a scripting language that does rust-like lifetime checking. That thread's archived now so I have to tell you here, it exists https://github.com/pistondevelopers/dyon https://github.com/pistondevelopers/dyon I don't really see the point, personally. But you seemed to really want it so
- Youk2016 10y agoWell, it's OK for a short reply on a forum. > 10x better theorists. Of the three, Rust is the only language with world-class PL theorists on roster. This can be seen in the precise definition of the language and the depth of its technical approach This argument impressed me. I'm sure Walter Bright does account for a fair share of D's popularity, though, so I take the 10x to mean in numbers :)
- nv-vn 10y agoIsn't Rust's syntax technically more Algol-like than C/C++/Go/D are? Anyways, I don't think it's worth calling that a disadvantage, at least with the way it's stated. I think "high learning curve" is a lot more accurate in this circumstance. And I'd disagree that the syntax serves no purpose, I think it's specifically designed to reinforce the notions of Rust's programming style (for example, implicit returns because Rust code is designed to always return something instead of using void functions). I'd be surprised if the syntax didn't help shorten code in at least a few places.
- qznc 10y agoFor technical differences: D has more meta programming, Rust has the borrow checker for safety.
- PeCaN 10y agoI think this is a valid question. They're pretty different languages in terms of design, but they're definitely worth comparing—their problem domains do overlap in spite of design differences. I've used both, but can't claim to be much of an expert in either. Similarities: • Compile to fast, easy-to-deploy native code • Abstraction continuum ranging from very low-level C-like style to a high-level more functional style • Very easy to call C libraries from • Type inferred and generally less syntactically noisy than C++ Neutral differences: • D is garbage collected; Rust has a novel memory management system based on linear types. This means D can never compete with Rust in performance and real-time or soft-real-time systems. On the other hand, it means with Rust you will spend more time thinking about memory ownership and other important-but-eliminated-by-GC concerns. Both are easier to deal with than C or C++. • Syntax: Rust's syntax is not-quite-C-like; D's is very C-like. It comes down to personal preference. I prefer Rust's. D advantages: • Metaprogramming: D's metaprogramming is more or less unmatched, though I haven't experimented with Rust compiler plugins at all. You can probably do some funky stuff with Rust, but it doesn't feel as integrated into the language as with D. • Compiles super fast. Rust advantages: • Type system. Rust's type system is ML-esque and generally much more powerful. I suppose this might not be an advantage to everyone, but personally I love how ML-y Rust feels. • Concurrency. • Ecosystem? I think ultimately my choice is that if I'm going to use a compiled GC language, I may as well just use OCaml. D's memory management, or lack thereof, kills it for me personally, but it's a well designed language otherwise IMO.
- jjnoakes 10y agoFor some, D's garbage collection isn't quite neutral. Rust, for example, can be used to write a C-like loadable or linkable module for some other system (JNI, Ruby, Python, etc) with a very tiny or nonexistent runtime required. Having a GC makes this a little less seamless.
- FraaJad 10y agoI wouldn't be very sure about the claim that "D can never compete with Rust in performance and real-time or soft-real-time systems". If anything, due to much better metaprogramming (as you mention), you can have D programs that ARE faster than Rust (eg: see JSON parsing benchmark [1]). You can write programs in D that have ZERO garbage collection. In fact, the core libraries (phobos) are being actively rewritten to remove GC altogether. [1]: https://github.com/kostya/benchmarks#json https://github.com/kostya/benchmarks#json