5 ms·
>its culture and ecosystem there's a lot of overlap It's just "being more modern than the 1980s". Rust's the first low level lang to be able to say that.
by shrimp_emoji 6y ago
>its culture and ecosystem there's a lot of overlap
It's just "being more modern than the 1980s". Rust's the first low level lang to be able to say that.
- brundolf 6y agoThat explains some things like the packages and the tooling, but not everything
- mhh__ 6y agoD came before Rust and was and is pretty "modern". Ultimately this depends on what modern means to you, but I'm guessing you can't write the "Tiny RPN Calculator" from the D homepage as concisely[1] - i.e. My point is that Rust isn't the only language that isn't C++ [1]: dlang.org - you can play with the exact code here https://run.dlang.io/is/FiWrHF https://run.dlang.io/is/FiWrHF I wrote it a few years ago (not long after I learnt the language, actually), I wasn't even trying to golf, it came almost straight away just from reading the docs. Note the use of static foreach to generate the switch cases for fun and profit.
- shrimp_emoji 6y agoHaha. True! I knew about D, but I forgot about it[0]. (I also know extremely little about it.) ;w; I feel bad. That code is as beautiful as it is incomprehensible. 0: https://youtu.be/_P5BOietpDY https://youtu.be/_P5BOietpDY
- ibraheemdev 6y agoI agree. The D program is cool, but pretty cryptic. A simple Rust version [0] is only 21 lines yet much more readable in my opinion. I'd take readability over a couple less loc anyday. [0]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=72f9f0bddc75b1dc0bc1e5e37912952f https://play.rust-lang.org/?version=stable&mode=debug&editio...
- mhh__ 6y agoYou miss the point of the original one. When I wrote it the idea was that it is functionally pure and guaranteed to be such by the compiler (the annotation was removed because readln is not pure for obvious reasons). Most uses of loops break down to map, fold, or similar being able to use them cleanly can avoid a lot of bugs and API plasticity.
- Measter 6y agoThere's nothing stopping you from doing a functional style in Rust, neither: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=bd83ad8f79c7a5db63c31c156e95bf6b https://play.rust-lang.org/?version=stable&mode=debug&editio... There is a function on nightly that would make line 16 a little nicer, but oh well.
- littlestymaar 6y agoThe `op.parse()` at line 7 was a little hard to understand for me at the beginning. Only a few seconds after, I understood it was `op.parse::<f64>()` with the type parameter inferred from the type of `stack`, but I think it's easier to understand with the explicit type annotation (the turbofish) than without it.
- nicoburns 6y agoNo memory safety in D though. That's a pretty big deal for those of us coming from high-level languages who are not used to dealing with such issues. I can deal with a fussy compiler that makes me write code in a certain way. But a langauge that compiles fine then segfaults or worse at runtime is far more trouble than it's worth (and requires me to make a big upfront time investment before I can start writing production ready code)
- mhh__ 6y ago> No memory safety in D though. Not true. Even ignoring the GC we have compiler checked semantics for an increasingly large subset of features, and the language has had ways of managing code that is safe, unsafe, or trusted for years and years now. As a newly minted employee of the D foundation, I am aiming to work to expand the memory safety features D has.
- nicoburns 6y agoIs there a way to make it safe-by-default, such that I can't accidentally stray beyond what the compiler can prove safe?
- cle 6y agoTry accessing a struct property that isn't in the declaration, or accessing a value after it has been freed (out of scope). You'll get a compile error. D has lots of memory safety features. It is not the same set of features as Rust. It's wildly incorrect to suggest that Rust has a monopoly on memory safety.
- mhh__ 6y agoThere was a proposal to do just that in our DIP (D improvement proposal) pipeline that nearly made it but it (probably correctly) received enormous backlash. However, if you use @safe (that's the attribute) the compiler will hard-error if you call any code that you use that isn't explicitly also either @safe or @trusted. There is also DIP1000 and DIP1021 which both loosen @safe semantics to perform semantic analysis to allow safe memory behaviour (A small borrow checker in effect, this will hopefully be bigger soon).
- pjmlp 6y agoAda says Hi!
- Tuna-Fish 6y agoAda was designed from 77 to 83.
- pjmlp 6y agoFirst standard was released in 1983, later updated in 1995, 2012, 2014, with an update revision coming up. Has the ability to specificy formal proofs in the type system (SPARK). Which basically beats the point of Rust being the only modern language happening post 1980. Ada was just one possible example, SIGPLAN archive has a couple more to pull from.