5 ms·
Ask HN: Do you recommend learning C++ first then Rust? My logic is that learning C++ and navigating its pitfalls would lead to a better understand of Rust and t
by ridhwaan 6y ago
Ask HN: Do you recommend learning C++ first then Rust? My logic is that learning C++ and navigating its pitfalls would lead to a better understand of Rust and the underlying reason behind certain design decisions.
- steveklabnik 6y agoThat is one argument. The other argument is that learning Rust first teaches you modern C++ well. I’m not sure which is correct.
- neutronicus 6y agoThere's definitely a dialog between Move semantics in C++ and Rust's ownership model. If I weren't a C++ programmer first, I don't know that I would really grok the value proposition of Rust (not dealing with Move Constructors) or the trade-offs (library code has to provide differently-named functions that trash resources as an optimization, rather than just providing an overload that eats temporaries).
- O_H_E 6y agoI too am in that position right now.
- Koshkin 6y agoBeware the possibility of falling in love with C++.
- nicoburns 6y agoI recommend learning Rust first on the basis: 1. The learning materials are much better. The official Rust book is excellent. And it doesn't take long to do a first run through it. 2. You'll learn much quicker with Rust. With C++ it could take you years of experience to gain a full appreciation of the pitfalls because they're often not apparent when you first write the code, only when you actually run into the bug further down the line. With Rust, you'll get a compile error and enlightenment is quick google and a reading of a blog post away. 3. Some parts of Rust only seems to be difficult for C/C++ programmers who have learnt the C(++) way of doing things and expect that to translate into Rust. They get frustrated when Rust doesn't let you use certain patterns. However as C++ is generally less strict, if you learn the Rust way first, then you'll generally be able to translate that fairly directly into C++.
- neutronicus 6y agoRegarding learning materials, I do agree about the quality of the Rust book, but I will say that if you're the type to learn from a project, especially if said project is a game or GUI Application, life will be easier and learning materials better in C++. I also think 2 and 3 are ... overstated.
- pixel_fcker 6y agoI think it will take years of working in c++ to fully appreciate the nightmarish many-tentacled footgun monster it can be. At the end of it you might even develop Stockholm syndrome and be one of those posting “if you just restrict yourself to these parts of the standard and run this 6 static analysers on your code then c++ is perfectly safe if you’re not an idiot”. If you don’t want to learn c++ for its own sake, that’s time you could better spend learning a language that’s not actively trying to harm you. Source: coded c++ for 20 years, now writing rust as much as possible.
- Koshkin 6y agoWhy not D, then? Just curious. D is “a better C++,” and it is a mature language.
- pjmlp 6y agoI love D's community and what they were trying to achieve, but it appears that the language has lost its opportunity to adoption or sense of direction. What I liked on it over Java and .NET languages, is no longer relevant after GraalVM, and the low level features in C# 7/8 adopted from Midori, came to be. Also C++20 now makes much D less relevant. Unfortunately the recent @safe and @live discussions don't inspire confidence in which direction they want to drive the language design.
- pixel_fcker 6y agoI looked into D once or twice. Found learning materials severely lacking. Having to read up on the differences between 2 (3?) compilers and choose between them wasn’t a great intro. For the work I do GC is also a non-starter. I know it’s got some level of no-gc now but the last time I looked it wasn’t well-supported. In short it seemed interesting but on-boarding felt hard. And with that the value proposition wasn’t there or well-advertised: It’s supposedly “better” in some ways such as faster compile times and better meta-programming and frankly that didn’t seem worth the effort. Rust by contrast does an excellent job of onboarding and making it easy to learn the language (at least at an introductory level). It also comes with a very straightforward value proposition: just as fast as c++ but whole classes of bugs simply aren’t possible. Add in a little bit of ergonomics and functional flavour and I was hooked.