3 ms·
Ask HN: C++ for Rubyists/Minimalists
I'm looking to pick up C++ as a skill and do some systems programming, but there's a lot of information out there on C++ and a lot of it is contradictory. What I'm trying to discern is what are the best features of the language to use if you like minimal, non-complicated programs. In other words, if you could remove the "bad" parts of the language you wish nobody would ever use and only leave the "good" parts, what are those "good" parts?
I'm fully prepared to accept that there are no non-complicated parts of C++, but I had to ask.
- jbandela1 10y agoFor some guidelines take a look at https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC... If you want to look up some information about the C++ library, look at http://en.cppreference.com/w/ http://en.cppreference.com/w/ Here is my advice if you are learning C++ for the first time. 1. Use the latest released version of either GCC, Clang (preferrable) or Visual C++ if you want the best IDE 2. Do NOT start off with pointers. Doing so will only confuse and frustrate you. 3. Use std::string and std::vector. Learn about the std::algorithm. Learn about lambdas 4. Learn about RAII, constructors, and destructors. Focus on invariants - how you set them up and how you maintain them. 5. Learn about exceptions and exception safety 6. Learn about references and polymorphism 7. Learn about dynamic memory and std::unique_ptr 8. Learn about copy/move construction and assignment 9. Learn about std::shared_ptr 10. Implement your own version of std::vector. You will learn about memory management and pointers by implementing the iterators. 11. Learn about std::list and std::forward_list 12. Implement your versions of both. You will learn a lot about pointers. 13. Analyze the exception safety of your implemented versions of std::vector, std::list, and std::forward_list. Make sure you do not leak memory or end up in an invalid state. This should get you acquainted with the basics. Now here is how to test yourself in various areas to see how comfortable you are. Templates: Implement std::tuple Memory management: Learn about memory allocation strategies and implement in an allocator that you can use with std::vector or std::list Unions: Implement std::string small-string optimization Atomics/memory model: Implement an atomic shared_ptr, where multiple threads can access the same shared_ptr atomically