Reddit reviews Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14
We found 47 Reddit comments about Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14. Here are the top ones, ranked by their Reddit score.
O'Reilly Media
Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14
IMHO, the best book for understanding C++11/14.
Modern C++ (C++11 or later) books are not nearly as plentiful as those for Classic C++, but there are a few notables.
Bjarne's college text may be what you are looking for:
Programming: Principles and Practice Using C++ https://www.amazon.com/Programming-Principles-Practice-Using-2nd/dp/0321992784/ref=pd_sim_14_2/144-7765085-0122037
It is aimed at engineers, which makes it less general, but might be good for you.
Of course his general intro is also updated to C++11.
The C++ Programming Language https://www.amazon.com/C-Programming-Language-4th/dp/0321563840/ref=pd_sim_14_2/144-7765085-0122037
This is aimed at experienced systems programmers, so it may be a bit heavy for students, which makes the Primer (that you mentioned attractive).
C++ Primer https://www.amazon.com/Primer-5th-Stanley-B-Lippman/dp/0321714113/ref=pd_bxgy_14_img_2/144-7765085-0122037
Be certain to get the 5th edition.
Of Scott's books only the latest is Modern.
Effective Modern C++ https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996/ref=pd_sim_14_2/144-7765085-0122037?_encoding=UTF8
This is less an introduction for students than for Journeymen (Journeypeople?) programmers.
For just plain good programming style consider Ivan's book.
Functional Programming in C++ https://www.amazon.com/gp/product/1617293814
Don't be put off by "Functional." This style of programming will make your students excellent programmers.
There are some modern books of high quality that are niche.
The ultimate guide to templates:
C++ Templates https://www.amazon.com/C-Templates-Complete-Guide-2nd/dp/0321714121/ref=pd_sim_14_1/144-7765085-0122037
The ultimate guide to concurrency:
C++ Concurrency in Action https://www.amazon.com/C-Concurrency-Action-Anthony-Williams/dp/1617294691/ref=pd_sim_14_1/144-7765085-0122037
Some library options:
Despite its name, this is mostly reference. A very good reference.
The C++ Standard Library: A Tutorial and Reference (2nd Edition) https://www.amazon.com/Standard-Library-Tutorial-Reference-2nd/dp/0321623215/ref=pd_sim_14_2/144-7765085-0122037
Arthur's book covers C++17, which makes it one of the most modern on this list:
Mastering the C++17 STL: Make full use of the standard library components in C++17 https://www.amazon.com/Mastering-17-STL-standard-components-ebook/dp/B076CQ1RFF/ref=sr_1_fkmrnull_1
To what extent are you teaching C++ and to what extent are you teaching programing?
Good luck and have fun!
>Also what is this documentation? It's crazy expensive. Why would I want it?
It's the standard. Unless you're a compiler writer or a huge language nerd, you probably have no use for the standard.
You'd still want to learn from typical books, such as The C++ Programming Language (by the language's creator). You'd have to wait for them to be updated, though. The finished standard is very new, so you can expect a bit of a wait for many books to be updated. Granted, it's been a WIP for some time, and there's already some books available (such as Effective Modern C++) and compilers already support a number of the latest features (at least Clang and GCC do; Visual Studio tends to be behind).
I guess I'm going to go ahead and be "that guy".
Don't aim to work with a specific language.
I feel you should reframe your goal to be a "problem solver" that knows how to pick and use various tools to solve a problem. C++ may be one of those tools. Maybe C. Maybe Python. Maybe Java. You want to develop your skill set to be flexible enough to adopt the right tool for a job. Now, that's not to say you can't be a language expert. Language experts are very valuable and becoming one is a perfectly reasonable goal. That said, I think you'll find that you have many more opportunities when you remain flexible.
With that out of the way, I would say good next steps for continued C++ mastery are to read and understand Scott Meyers' excellent books:
Also go through the CppCoreGuidelines.
Beyond the language, make sure you know your standard data structures and algorithms.
In addition to Effective Modern C++ I'm also going to recommend The C++ Standard Library: A Tutorial and Reference and C++ Concurrency in Action: Practical Multithreading.
Books are still the best way to learn C++! C++ Primer, 5th Ed. covers all the basics of C++11 from functions and standard library usage to OOP and templates. Effective C++ reinforces good practices and idiomatic C++ that, despite being written for C++98, is just as relevent today as it was then, some of its contents even more so than ever before. Then Effective Modern C++ then does the same for C++11 and C++14 features, building on top of what C++ Primer covers about C++11 and introducing the subtle changes brought about by C++14. This is my primary recommendation for learning modern C++ from the ground up.
But we live in the internet age! Best make use of it! So many wonderful talks from conferences such as CppCon, C++Now, Meeting C++, ACCU and Code::Dive are all available for public viewing. With regards to modern C++, Herb Sutter's CppCon 2014 Back to the Basics! Essentials of Modern C++ Style and CppCon 2016 Leak-Freedom in C++... By Default are great videos to watch. For more specific topics, here is a list of videos that I've seen and personally found engaging, educational, and worth my time to watch (multiple times!):
rand()
Considered Harmful and What C++ Programmers Need to Know about Header<random>
for random number generation,auto
anddecltype(auto)
(I miss Scott :'( ).There are also shows such as CppChat and CppCast where interesting events, projects, papers, and people related to C++ are brought up and discussed. There are so many interesting blogs to read!
And there is always people on IRC (##c++, ##c++-basic, and ##c++-general) and the Cpplang Slack Channel for live updates, discussions, debates, questions, answers, and/or just plain fun with a group of people that ranges from complete noobs who are learning the basics, to committee members and library authors whose names are known across the community. If you ever have a question or need help, these are the places to go and ask (/r/cpp_questions is nice too! :P ).
And finally, links to videos, blog posts, articles, papers, interesting Stack Overflow questions, almost everything mentioned above is constantly being shared at isocpp.org and on /r/cpp. Subscribe to both to get a constant stream of links to anything and everything about C++.
Edit: as for C++17 material, the standard is not technically completed/published yet, but that hasn't stopped the community from creating material about it! This paper lists all the changes from C++14 to C++17, with links to relevant papers, and this Git repo provides a simple "then, and now" comparisons of the major changes to the language. Talks describing the changes in breadth and in depth have been given at conferences, and blog posts have been written for a more textual description of the changes. C++17 is not a major update like C++11 was to C++98, but full of fixes, conveniences, more language flexibility and utility, and new toys to play with! If you have a solid foundation in C++11, C++14 and in turn C++17 should be relatively easy to pick up compared to the shift from classic (C++98) to modern C++.
TL;DR Learn C++11 the best you can. Once you are comfortable with C++11, the transition to C++14 will feel natural, and C++17 will be waiting just around the corner.
Here are several ways to get yourself started.
You can use clang intelligence thanks to resharper to pick up on even more errors that will tell you that you should be using modern c++ practices. And if you use these flags
It's a book. Books are instruments that record, analyse, summarise, organise, debate and explain information; that are illustrated, non-illustrated, hardbound, paperback, jacketed, non-jacketed; with foreword, introduction, table of contents, index; that are intended for the enlightenment, understanding, enrichment, enhancement and education of the human brain through sensory route of vision - sometimes touch.
C++ is a very complete language withs lots of details. But that doesn't mean you need to know everything.
Don't overuse every feature just to show off. Start with the simple things. Class management, templates creation (the simple ones), data structures and the most important, smart pointers.
Don't go after manual memory management. That's old school and it is only usefull in very specific cases and applications (high performance computing and games). Learn to use smart pointers and you will stay safe, away from the segfault Hell.
Learn to use the STL templates. Lists, Vectores, the good stuff. They have been developed by highly skilled people and has taken years of beating by professionals. Use them whenever you can. It will make your life easier when debugging and make your program easier to port between different archs.
There are great books out there. Effective Modern C++ is one of my favorites.
The correct answer to:
Q. Should I learn C or C++ first?
Is:
A. Yes.
WARNING: Highly Opinionated Analysis of C vs C++
I see a lot of people recommending one way but no one offering an analysis of BOTH the Pro's & Con's.
I've been using C++ since ~1990. I've briefly worked on a PS3 C++ compiler when I worked for Sony. I've seen 2 major problems over the years with C++ programmers:
1. People don't exercise discipline and restraint in K.I.S.S.
They use (and abuse) every language feature because they can. There is this tendency to over-engineer even the simplest things. Take a look at this complete clusterfuck of CRC in the Boost library.
1109 lines of over-engineered C++ crap for a simple CRC32 function instead of a mere 25 lines of code!?!?! The C version would:
The trade-off would be is that it is less flexible, but WHEN was the last time you needed to use a custom CRC polynomial!?!? One would instead use a different algorithm such as MD5, SHA, etc. that:
This excellent SO on hashing is but one example of focusing on the big picture.
2. People lack a basic understanding of the cost let alone the implementation of C++ expressions.
I've seen people stick a virtual function inside an inner loop and wonder why their performance is crap. I've seen people fail to grasp a basic understanding of pointers. I've seen people not understand memory management and how to guarantee zero memory leaks. I've seen people spend more time on writing an "über" template and waste hours debugging that instead of just writing something in 1/10 of the time and move on.
IMO, due to the bloated, over-excessive verbose nature of C++ it is for these reason that I strongly recommend a beginner learn C first and then learn C++. You'll have a better understanding of why C++ is designed the way it is, what the design trade-offs are/were, what C++ hacks are, and how to best use the languages to their potential.
However, this is ignoring the benefits and disadvantages of the Pro's/Con's of why one would learn C++ or C first.
Learn C++ first
Learn C first
{
{
With that said there are numerous C++ books I would recommend to ALL C++ programmers. They are sorted from beginner to expert:
If you can get only one book, get the The C++ Programming Language.
Even though Bruce's book is ancient he keeps it simple and is a fun easy read. Remember this is before C++98 where the language is much simpler.
You can find it online for free
Lastly, just because you can, doesn't imply you should. Use balanced C++ and you'll be fine.
Books: First A Tour of C++ and then Effective Modern C++. Website: isocpp.org (it features many blogs, conference announcements, Stackoverflow questions regarding C++11/14).
Scott Meyers made Effective Modern C++ which has a lot of changes in the language documented and documented well. If you're proficient in C++ I highly recommend checking it out. (Or watch: https://youtu.be/xnqTKD8uD64)
The big one is ownership semantics leading to smart pointers.
The general rule of thumb is you should never use a raw pointer, except when you're not transferring ownership. Also, consider
weak_ptr
, and references, always references.SFINAE in class, really? I'm impressed. Use
constexpr if
instead when you can (90% of the time). SFINAE should really only be used for firmware and library engineers and is on its way out, if concepts ever get finished.Metaprogramming in C++? More like dark magic, taking advantage of C++17 plus SFINAE. No, I think you mean meta template programming, most likely. Meta template programming has been replaced with
constexpr if
as well. Don't do it, unless you like pranking your coworkers. You can write meta template programming to crashes IDEs when they try to read the file.>data structure/algorithms (arrays/linked lists/trees/maps/stacks/queues/searching/sorting/graph searches and efficiency considerations)
That's more data structures than algorithms. I personally think algorithms are more important, but I digress:
std::deque
is important, and no it's not a doubly linked-list. All the different hash and tree structures likestd::unordered_multiset
are super helpful to know, even if you never use them. Understanding sets and tuples too. None of this is specifically modern C++, except that most of these data types didn't exist or were incomplete 'till C++11. cppreference is super helpful and imho should be used regularly.Oh and C++ has a whole slew of algorithm functions and classes now. Check them out on cppreference, but imho they're not super helpful like they are in Python or R. Really, learning how to make an algorithm is more important.
Oh, I've been rambling about old stuff. Okay back to modern: the different kinds of bracket initializations are important. Previously initialization had a lot of () in it, so
auto foo = Bar(0);
, should that be a () or a {}? Looking at it I can tell you it most likely should beauto foo = Bar{0};
but it's not a guarantee. I'd have to look at Bar's source code to verify.There are modern idioms that should be considered, like aaa or almost always auto, and should be followed when possible and reasonable to do so.
Lets see, what else..
nullptr
instead of NULL. A lot of the pre processor can be replaced withconstexpr
andconstexpr if
.Ranges is definitely worth learning but that's a C++20ism.
std::expected
is super helpful to know but that's a C++20ism as well. (Just to know there are more ways to handle exceptions and which to use.)They teach perfect forwarding in classes you go to? What classes are you taking? That's impressive. I'd say
std::move
is super important to know and understand, but it's a given if you understand ownership semantics.Oh, there are new keywords.
default
anddelete
should be used liberally when creating a new class, in conjunction with the 0,3,5 idiom.override
is important on the inheritance front, and imho should be enforced using a compiler flag.Oh! Threading and file handling have had a complete over hall. Now C++ does it instead of using the OS' libraries. Threading is a bit of a sinkhole and should be known inside and out if you're working on your own project. If the project is large enough the framework should handle all of the threading for you. Otherwise, it is important. (eg, lockfree programming is kind of important in most situations.)
And of course lambdas. Super useful. No more
void *
. I can't believe I almost forgot them. Pass code around, not variables.RVO is important when considering ownership semantics. Basically, don't
std::move
on return unless necessary. Don't return a pointer or a reference unless necessary.Gosh there was something else..
Let's see, inheritance isn't taught right in any book or class I've seen. There is a prerequisite of understanding how to make types. This is important for quant work, because you'll probably be using custom types everywhere. Learning how to make them in C++ is important, not just use them, because it builds the prerequisite conceptual understanding for multiple inheritance.
Inheritance in Haskell terms is subtyping or abstract typing. Abstract classes (not necessarily fully abstract, just not concrete) are a type of class, sometimes called a subtype or abstract type. Inheritance isn't just for gluing code together. It's for having types of classes, or categories of classes. This is something understood on a senior level, but because it is so difficult to understand modern languages tend to just ban multiple inheritance out right. C++ has it, so understanding the thought process to not doing it right, but thinking about it right, is important.
I'm sure there is more. Oh, there is a new syntax Herb Sutter has been pushing which is pretty great, if the whole code base has it. .... and I can't find the video. The skinny is
int foo(double bar)
becomesauto foo(double bar) -> int
. The philosophy is the function name should be as far as possible to the left hand side to make code more readable, because types can get stupidly long sometimes. The C++98 equiv, which thankfully most of the code bases I've worked on do:int
foo(double bar)
Oh and
std::variant
combined withconstexpr
replaces unions.Basically, if it's in C there is a C++ equiv. Use that instead. The exception is native types, and functions. Even loops have changed to range based for loops eg
for(auto it : foo)
and withstd::for_each
, though C style loops are still useful and used sometimes. Oh and structs are still around and can be popular, butstd::variant
orstd::all
might be a better option depending on what you're doing.And the most important saved for last. Read http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines learn it, love it. For example, checkout F.15. Super helpful. This is official, so you can use it for coding disputes and what not.
phew \>.\<
Disgusting. Scott himself comes here to share news about his book, and this is the first reply he receives. I dislike the abundance of memes, but this is apt: "This is why we can't have nice things."
Perhaps it's been up for awhile at this point, but the book can now be preordered at Amazon. My preorder is in, just as it was for Bjarne's TC++PL 4th edition.
If you haven't read these books already, what are you doing, go and read them now.
Effective C++
More Effective C++
Effective STL
Effective Modern C++
Scott Meyers is good -- check out Effective Modern C++. He has a training course, Overview of the New C++ -- I haven't taken it, but I've seen enough of his stuff to recommend him.
If you want more introductory C++ stuff, look at some of the online courses by Kate Gregory (some free trials available -- which might be good to assess if it's what you're looking for).
Once you get going, I'd recommend Sutter's Mill. In particular, check out his "Elements of Modern C++ style". There are also loads of videos online from CppCon (just google it).
But keep in mind that one limiting factor in your request is the "for C programmers" part. A big part of recent evolution of C++ has been getting rid of the need for core C features like pointers. By keeping the C angle, you may be anchoring yourself to the past.
And if you want to go that route anyway (ie keep the C angle), then there is less harm including some older stuff too. I really liked Bruce Eckel's Thinking in C++, which you can find online for free (it isn't quite ancient or modern).
Posting this as a top level comment so people can see this without digging. Here are some of the resources I have used plus additional ones I've found that may be useful:
http://www.learncpp.com/
https://www.sololearn.com/Course/CPlusPlus/
https://www.amazon.com/Primer-5th-Stanley-B-Lippman/dp/0321714113
https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996 (this one is a little more advanced, should be read when you are comfortable with c++)
https://www.amazon.com/C-Programming-Language-4th/dp/0321563840
At my previous employer (where I was not an engineer but was testing their software), everyone was carrying around this book:
Effective Modern C++
https://www.amazon.com/dp/1491903996
There's also this list you can browse here https://github.com/rigtorp/awesome-modern-cpp
I enjoyed reading A Tour of C++ by Bjarne Stroustrup. It is short of 200 pages, recommended by Herb Sutter in one of his CppCon talks as the bare minimum every C++ programmer should now, and touches the basics of modern C++ (up to C++11).
Scott Meyer's books are highly revered in the industry as well, based on what I have fathomed. I am gonna read this next.
There is a new version of effective C++ that covers C++11/14:
http://www.amazon.com/dp/1491903996
I would guess that it is still as good and relevant as the older version.
Effective C++ / Effective STL by Scott Myers are a good starting point. They can be hard - if they are not, come back in a few months.
Marshal Cline's C++ FAQ is an assorted collection of everything in small bites. The book makes excellent toilet table material, though you have to piece together yourself the deeper insights that Effective X aims for.
Guru of the Week is a sometimes-dated but very well presented series of questions and answers, aiming at a wide range from beginner to, well, guru. The only drawback is that in C++11 and beyond, it's a bit different, or there are other / easier solutions.
Herb Sutter has started reviving the series
Code Complete gets half-a-recommendation. It is important material about programming in general, but for most people it's just too big. Anyway, the first edition can be acquired for pennies and is "good enough", so in case it doesn't work for you it could keep you warm for half an hour or so (lighter not included).
---
Other than that: I repeat the recommendation by /u/Heiroglyph to read and try to make sense of other people's code.
---
Side Note: My recommendations are intentionally non-game-programming related. Reason is^* I had quite a few run-ins with game programmers on Q&A sites and the like, and I'm left with the impression that they have a culture of sticking to their own puddle, but thinking it's the ocean. Certainly, game programming has some very particular problem that need very specific and sometimes awkward solutions, but that's no reason for isolaitonism.
^^*) ^^besides ^^the ^^obvious ^^"I ^^am ^^doing ^^too ^^little ^^game ^^programming ^^to ^^be ^^of ^^use ^^for ^^that"
( quand je dis HTML+javascript, c'est javascript le langage de prog.)
Si tu veux apprendre le C++, sous windows tu peux télécharger VisualStudio Community (je crois que c'est comme ça que ça s'appelle la version gratuite maintenant) de Microsoft et essayer.
Sur le net ya des tonnes de cours sur google, en français en anglais pour commencer. Il faut déjà pratiquer et mettre les mains dans le cambouis.
A savoir après des années de stagnation le C++ évolue (presque) vite, certains livres parlent de C++11 alors qu'on est au standard C++17 et bientôt C++20
Après, si tu veux vraiment apprendre des trucs pour :
https://www.amazon.fr/Programming-Principles-Practice-Using-C/dp/0321992784
https://www.amazon.fr/Tour-C-Bjarne-Stroustrup/dp/0134997832/
https://www.amazon.fr/C-Programming-Language-Bjarne-Stroustrup/dp/0321563840/
https://www.amazon.fr/Effective-Modern-C-Scott-Meyers/dp/1491903996/
Sans oublier sur le net les bonnes pratiques, à jour:
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Et sur youtube il y a plein de vidéos aussi, et des conférences.
Et je conseille d'apprendre le C en même temps, parce qu'en C++ on utilise beaucoup de librairies en C.
https://www.amazon.fr/langage-2e-éd-Norme-ANSI/dp/2100715771
http://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996/ref=cm_cr_pr_product_top
I do, though I haven't really programmed in 3 years as I posted, I did read https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996 when it came out about a year ago and try and stay up to date on /r/cpp
The C++ Programming Language, 4th Edition - Bjarne Stroustrup
Effective Modern C++ - Scott Meyers
21st Century C - Ben Klemens
Learn You A Haskell For Great Good - Miran Lipovača
The Book & Rustinomicon - Rust Contributors
A Byte of Python - Swaroop Chitlur
Java The Complete Reference 9th Edition - Herbert Schildt
These are the books I got the most out of. None of them are good for beginners to programming, except maybe A Byte of Python.
But they have given me deeper essential knowledge over the tools that I'm working with than any sort of "zen of patterns" or "corporate feng shui" style book has offered.
Of course I have also come across other computer science books that are fantastic, namely AI and machine learning stuff. I know a handful of solid game engine and graphics books have also come out in the past few years.
Stoustrup has quite a good summary of the new features of C++11 at http://www.stroustrup.com/C++11FAQ.html. Scott Meyers Modern C++ book https://www.amazon.co.uk/Effective-Modern-Specific-Ways-Improve/dp/1491903996 will tell you more than you may want to know about the new reference types, constexpr, and the like, but it does require a reasonable C++ background. I'm not aware of any book that focuses on functional programming in modern C++, but I'd certainly like to read one!
If you actually want to learn to implement efficient algorithms and data structure in C++ you might have a long road ahead of you since loads of them are quite complex. If you're interests are purely in machine learning than I would suggest you make use of the containers and algorithms provided by std and boost.
Going more domain specific and using things like armadillo or eigen. The later is used in many popular NN libraries/frameworiks such as tensorflow while the former is (based on my subjective opinion) quit easy to use, more similar to matlab and used in a number of libraries such as dlib and opencv. These "higher" level libraries are likely even better suited for your needs since they may help you use multiple cpus and gpus for your algorithms.
Further more, if you are interested in getting something shipped out quickly check out some C++ ML libraries, my personal favorite is Dlib but its quite limited in scope. However, I assume you wish to implement your own algorithm, in which case you are in luck because most of these libraries are open source:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow
https://github.com/davisking/dlib
https://github.com/opencv/opencv
https://github.com/Somnibyte/MLKit
(are some examples of such libraries).
For familiarizing yourself with C++ I'd recommend:
-> so documentation
-> [Programming: Principles and Practice Using C++](https://www.amazon.com/dp/0321992784/?tag=stackoverfl08-20](https://www.amazon.com/dp/0321992784/?tag=stackoverfl08-20)
-> Effective Modern C++
Stack overflow documentation has plenty of examples that explain things which might otherwise seem strange about the language, Programming: Principles and Practice Using C++ was written by the creator of the language, Bjarne Stroustrup, who also happens to be a university teacher, so I would say it could be considered an objectively reasonable starting point for learning C++ for someone not very experienced with programming and Effective Modern C++, while aimed at programmers that are already experienced with C++, might give you a bit of insight into understanding why old codebases look the way they do and how to improve them and not repeat their mistakes (its also quite a well written book in many aspects, quite a pleasure to read).
Also I would avoid any C++ centric book on algorithms and data structures written pre 2011 like the plague, since the language has evolved a lot and you might find yourself learning a very old.
Scott Meyers has got some decent books. The latest one, Effective Modern C++ should be a great start to begin properly using the newer C++11/14.
I think C++ Primer is nice, and I still keep it around at work as its a useful reference to have. Being able to open up to a section about a topic and know I'll find some reference info, example code, and some good exposition is great. It covers C++11 fairly well, too. Make sure to get the most recent edition. The book does a nice job of providing a decent amount of example code, and the included exercises are very useful.
Effective Modern C++ is great, once you have a bit more experience under your belt. I pull this one out all the time to take a quick look through it when I question how I'm using some feature, and the paradigms of "Modern C++" in general are just great to follow and fun to use.
The C++ Programming Language is a reference guide: its good for more advanced programmers who want a quick reference guide that also has a bit of exposition on various concepts/features (beyond what can be found on cppreference). I still don't think it would be well suited to you- it lacks the example code and useful exercises of the C++ Primer.
As you probably well know though, the best way to learn a programming language is to write in the language. Books are good for making sure you don't do outright "bad" things at first, and in that case I'd definitely recommend the C++ Primer. I had the problem of following online sites for my first C++ experiements, and these sites never used or mentioned any of the wonderful things C++ offers like the
algorithm
library (learn to love everything that offers!) or even something as basic asstd::vector
! Instead, I was using lots of raw calls tonew
anddelete
and doing other suboptimal things.So, I'd say go with C++ Primer to start. Follow along like you would with a maths textbook and do the example problems, and transcribe and run much of the example code yourself.
Effective C++ would be next, to help you brush up on using various features of Modern C++ and better understanding small but vital details like
constexpr
and move semantics.I started learning C++ in August of this year, so I still remember a lot of what it was like to start. Feel free to ask me more if you have any questions about other materials, websites, or resources.
These are books I actually own and would recommend. Of course there are other great/better books out there, but I'm going to stick with what I've actually bought and read or "read".
I say "read" because several books are NOT meant to be read cover-to-cover. These typically have about 1/3 that you should read like normal, and then skim the rest and know what's in the rest so that you can quickly reference it. These books are no less important, and often even more important. I've marked these kind of books as #ref for "read for reference". Normal books that should be read cover-to-cover are marked #read
For learning your first language: This is really the hardest part and unfortunately I don't have any books here I can vouch for. I started with "C++ for Dummies" and am not including a link because it's bad. Your best bet is probably "Learning <language>" by Oreily. I also love the Oreily pocket books because you can carry them and skim while on the bus or the john, but you can just do the same with your smartphone. Pocket Python, Pocket Java, Pocket C++
Top Recommendations:
Accelerated C++ #read Made for people who already know another language and want to pickup C++. Also great for people who need a refresher on C++. I really like how it doesn't start with OOP but gets you familiar with the imperative parts of C++ before diving into OOP.
The Algorithm Design Manual #ref This is my new favorite book and the first I would send back in time to myself if I could. Each algorithm & data structure is given a mathematical breakdown, pseudocode, implementation in very readable C, a picture (very helpful), and an interesting war story of how it Saved The Day.
Cracking the Coding Interview #read I originally avoided this book like the plague because it represented everything I hate about coding interviews, but many interviewers pull questions straight from this book so this book can equal getting a job. Put that way, it's ROI is insane.
The Pragmatic Programmer #read Must-have for any profressional software engineer that covers best-practices for code and your growth. You can also find the raw tips list here
Head First Design Patterns #read Many prefer the "GoF/Gang of Four" Design Patterns which is more iconic, but Head First is a modern-version using Java to cover actual design patterns used day-to-day by programmers.
For Intermediates:
Effective Java or Effective C++ and Effective Modern C++ #read When you're ready to go deep into one language, these books will give you a huge boost to writing good Java and C++.
Design Patterns #ref You'll want to get this at some point, but early on it's too much for a beginner and many of the patterns are obsolete.
The Art of Computer Programming #ref The programming "bible" but like Design Patterns you should hold off on this iconic book until you've got your basics covered. It would make for a great purchase with your first paycheck or first promotion :)
Stephan T Lavavej is the Standard Template Library (STL) maintainer for Visual C++ at Microsoft. He put together an excellent series on Core C++ that describes all of the essential elements of C++. However, that series does not cover "modern" C++ (C++11/14/17). For that, I strongly recommend Scott Meyers Modern Effective C++ from the Definitive List of books.
As a personal note, please keep in mind that C++ is not C. The structure of programs is fundamentally different. You want to forget everything you know about manually allocating memory, using global variables, passing parameters by pointer (C++ has references). Learn to love
const
. And, above nearly all else, use the STL. If you have questions, don't be afraid to post them here!which books exactly, please guide me.
these ones?
Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)
Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14 1st Edition
More Effective C++: 35 New Ways to Improve Your Programs and Designs 1st Edition
What is the difference between them? It seems effective cpp 3 is from 2005 and more effective cpp is from 1996. Is there a point in reading more effective cpp after reading the third edition of effective cpp?
Also, what do you think about C++ How to Program?
I'm in the same situation as you and can recommend some good books I started reading:
The C++ Programming Language
Effective C++
Effective Modern C++
You can also find other good books here -> http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
Meyers' Effective (Modern) C++ really is a good place to start, assuming he understands the basic syntax and concepts. The basics of C++ don't change just because there's a new standard out. Start with Effective C++ to get the basics quirks of the language down then go to Effective Modern C++ to add in the new things from C++11 and C++14.
I'd say that learning any language, which doesn't have objects and forces you to do your memory management manually before moving to C++ is a big plus. The language doesn't matter, the concepts do. You'll know that there are things like heap and stack, that you can have a memory leak if you're not careful with pointers, that there is something called data type, condition, loop, etc. C can teach you all of that but it's not the only one, Pascal can do the same thing even though it is old, the syntax is horrible,... but it has all things I mentioned above. And debugging memory access is less painful because it crashes right away after you access unallocated memory, not 20 lines later as C once did for me.
That first language should give you solid undestanding of basics needed to move on to more advanced object-oriented languages like C#, C++ or Java. However I would not recommend C++ for learning object-oriented programming, C# (or Java) is much more suitable because it let's you focus only on the OOP and modern programming concepts such as encapsulation, inheritance and polymorphism, generics, etc. while doing all the tedious memory management for you. Also the OOP concepts in C# just work, you don't have to think about accessing an object through reference for virtual functions to work (because in C# almost everything is a reference) or about multiple types of inheritance or about any other weird C++-specific stuff.
After that you should be able to learn C++ with almost no problem. Except for the C++-specific things like special member functions, l-values/r-values, more kinds of inheritance, templates and how they work, allocation on stack vs. allocation on heap (and how to choose where to allocate your object),... But most importantly you should learn the abuse the standard library (STL) as much as you can. It provides you with smart pointers that can do allmost all memory management for you so you'll never have a dangling pointer (but can come with some runtime cost), generic containers such as vector, map, etc., and countless other useful things. I also recommend reading Effective Modern C++ (https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996) because it shows you the way how you should program in MODERN (post-C++11) C++.
C++ has gone through many changes in the last decade, so many that we've taken to calling it "modern." There's still lots of caveats so I'd highly suggest reading https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996
In this book you'll learn all about many of the gotchas many compilers won't warn you about.
Edit: wording/grammar
There's a ton of instructional videos on Coursera, YouTube, etc. As I learned C++ many years ago, I can't really recommend a specific course. But find one that works for you.
&#x200B;
I strongly recommend you learn the C [not C++] programming language first. It's super simple, and you won't get bogged down by all the bells and whistles which complicate C++. Plus, most of the complicate C++ language features won't be used in a data structures course.
The C Programming Language, K&R
The book is about C, not C++. However, the C programming language is incredibly simple, and you'll learn the core concepts without all complexity of C++. This book is a quick read [185 pages, not including the reference section]. As you're coming from Python you'll need to understand types, memory allocation, pointers, and headers.
The Google C++ Style Guide
Google's C++ style guide is battle tested. It offers than mere style recommendations, but also many lessons in avoiding pitfalls in C++ code.
Effective Modern C++, Scott Meyers
Read this book 5 years ago. Can't recommend it enough. It covers more advanced features and pitfalls. So you can read it after you have a basic grasp.
C++ Reference
Incredibly dense technical reading, but the more you read the easier it becomes.
Many best practices depend on the language. Taking a guess from your question, you're writing C++, in which case you should start with Effective Modern C++.
Cool, you will probably find these books to be useful (as I did): Professional C++, 3rd edition and Effective Modern C++
https://www.aristeia.com/TalkNotes/ACCU2011_MoveSemantics.pdf
&#x200B;
That should give you plenty of background. r-value references may not be the best solution, but it's definitely a problem that needs solving. Scott is an excellent presenter and there are plenty of his talks on YouTube. E.g., a video abridgement of his excellent book, Effective Modern C++.
Yea, I'm making my way through this to get up to speed.
I've spent about half of my graduate life with C# and the university/rest of graduate life with C++98, so I'm trying to get up to speed
a good book
When I started, the most memorable three resources I know I had were the following:
After you're done with the two above required books, here are some useful readings:
The above readings will probably be a solid 6-12 months to read and absorb assuming you spend a couple hours a day, but I think it'll be well worth it in the long run since this type of stuff sticks with you for a long time. I read the above around 2013, and I can still talk about the CFS/other schedulers, software interrupts, and how the CPU cache works. It'll also make converting to other languages even more of a breeze because you'll know how everything works underneath the hood.
Effective Modern C++ is a great way to catch up. It's worth reading the earlier books too (Effective C++ and More Effective C++) in order to make sure there aren't any gaps, and for you to understand idioms in older code that you end up maintaining.
[Book1] (http://www.amazon.com/C-Programming-Language-4th/dp/0321563840/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1451948095&amp;sr=1-1&amp;keywords=the+c%2B%2B+programming+language )
[Book2] (http://www.amazon.com/Effective-Specific-Improve-Programs-Designs/dp/0321334876/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1451948117&amp;sr=1-1&amp;keywords=effective+c%2B%2B )
Book3
I would recommend these two:
Discovering Modern C++
Effective Modern C++
Start with the Discovering Modern C++ and then move on to the Effective Modern C++. Effective Modern C++ is a must read, but it is very advanced, so take it slowly. I always keep it on my desk.
EDIT: This book is also a must if you are a sane person
EDIT2: I just noticed this: "Just looking for a hobby to do in the evenings and programming is something I'd be interested in." If you do not know how to program, pick some other language. It's no use to start with the 'hardest' one out there.
EDIT3: I hope you have thought this through, Op
978-1491903995