Hacker News new | ask | show | jobs
by forgotpwd16 2335 days ago
I'm wavering between D and Rust for which one could be used as a better alternative to C++. (Though I don't see C++ getting replaced anytime soon.) Even if Rust is getting most of the attention, D also seems to be a strong candidate.
5 comments

I've been using Rust for a year or so and while it's very nice once you get used to it I recently started working in D since I feel _so_ much more productive in it thanks to the GC while it still feels powerful and is fast where it matters (you can avoid the GC at performance critical places). The lack of libraries is a little annoying at times but thanks to dstep it's somewhat easy to use C stuff.
D is also getting an Ownership/Borrowing system:

https://github.com/dlang/dmd/pull/10747

D is fun! It's so easy to get started. Rust has an initial learning curve that just doesn't doesn't seem to fun to me, but I guess I'll have to actually scale it some day.
I'd say the main determinant is what kind of C++ are you writing and what features of C++ are most important for you. If template metaprogramming is your kind of thing, then you absolutely need to try D, D makes heavy use of template metaprogramming (yes, the lengthy errors you know from C++ make a comeback in D too). If your C++ is more like C with classes, you'll feel right at home in D too.

However, if the most important features of C++ is RAII, shared pointers, unique pointers, move semantics, then you'd probably enjoy Rust more, because it focuses on this kind of memory/resource management techniques.

Rust is definitely more difficult but it has it benefits, I guess? For me as a Python guy D was just easier both concept wise and syntax wise. I could write a relatively complex algorithm after 2 weeks of reading a D programming book with just standard ops. And it was definitely faster. Maybe not as fast as C but I felt efficient. Personally, I liked that D does pray FP like Scala while also being a multiparadigm language. Aaand it is definitely more readable.
*does not pray FP