Related
I am an undergraduate student and I recently was hired for a co-op for this summer and next fall. From what I understand I will be writing a lot of C++ which I am comfortable with but I don't have a huge amount of experience actually writing C++ in particular.
I wanted to take the time to really dive into C++ and become much more proficient with it. Does anyone have any particular resources that I could use to get some more experience before I start my job?
TopCoder was featured on This Developers Life recently and the algorithm challenges are a great way to hone your skills in various languages including C++
Getting involved in Open Source projects is a regular suggestion.
Good books from many authors are listed conveniently in many places including Amazon.com
To really deeply understand the language and learn some best practices I would recommend to read Herb Sutter's books, in following order:
C++ Coding Standards
Exceptional C++
More Exceptional C++
Exceptional C++ Style
The first one is very useful if you don't have experience with industrial development in C++.
Read The C++ Programming Language by Stroustrup cover to cover, and then read it again and again. Then, as you work with C++ programs, keep referring back to that book to remind yourself of the details of various topics.
It is, by far, the best book on C++ available, and since the author invented C++, you will get a good sense of the intentions and rationales of the various language features.
Once you have mastered the contents of that book, the next step is to familiarise yourself with the C++ 03 and the upcoming 0x standards. Reading a language standard can be hard, but once you get used to the style, standards are invaluable resources.
It is very important to be familiar with the authoritative resources and not get lead astray with possibly incorrect or out-dated information out on the web. I've seen programmers make really dumb mistakes because they just searched on Google to find out how some language feature works.
You need to practice and read manuals (tutorials) for c++.
Else you can try to look at internet website who are not protected and look at the source code.
Everybody work hard for what they learn and apply.
Good luck!
I was developing for quite long time already on C/C++ (mostly C, which makes style poorer). So, I know how to use it. However, quite often I stuck with style decisions like:
- should I return error code here, throw exceptions, return error through a parameter
- should I have all this stuff in constructor or should I create separate init function for that.
and so on.
Any solutions WILL work. However, each of them has cons and pros, which I know and most importantly which I don't know.
It would be very nice to read something regarding overall C++ development style, coding practices and so forth. What do you recommend?
Here is a list of really good books on C++:
The Definitive C++ Book Guide and List
Read few of them as per your level. That would most certainly improve your coding style!
I would personally suggest you to read:
Effective C++ series C++ by Scott Meyers
Exceptional C++ series by Herb Sutter
Exceptional C++ discusses exception-safe code in-depth. After reading this book, I learned how exception-safety effects design of classes, and interfaces. Highly recommended!
I've been recommended this by many people and I have a copy.
Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)
http://www.amazon.com/exec/obidos/ASIN/0321334876/christopherheng
One book in particular jumps out: C++ Coding Standards. This book does recommend some slightly questionable/useless ideas (like postfix _ for members) but mostly it's very solid.
Next important ones for style are the "Exceptional" book by Sutter. The good thing about them is that they cover important areas where C++ is rather..."different". It covers how to protect your code against exceptions and explains in detail the effects of exceptions upon coding practices.
The Myers books are good too, but a little dated. The Red books are more important IMHO.
Another dated book that is often overlooked is Generic Programming and the STL. It's almost, possibly IS, pre-standard but it discusses the hows and whys of the STL, which is pretty darn important for any C++ developer. Always amazes me how amazed people are when I show them a bit of tag-dispatching code.
It's an older book, but I'm a big fan of 'Code Complete' from Microsoft. It helped me to think about some of the design choices like the ones you've described. They advocate a strategy of designing code that helps to debug itself.
A very rudimentary example is variable testing in an if statement
if(nCheck = 1) {
// will always do this because nCheck was assigned 0
}
if you get into the habit of writing your if statements like the following
if(1 = nCheck) {
// Now the compiler will catch the assignment as an error
}
Your code should help you by catching most of the easy syntactical bugs. This is just the tip of the iceberg. The book has many such examples of clever practices that microsoft has used over the years.
For better understanding C++ and for style I would recommend
Effective C++ series from Meyers
C++ FAQs (the book) from Cline
Both are also an "easy reading" thanks to the small-pills format.
Some background: My job involves maintaining a large multi-threaded multi-process C++ / C# application, and so I'm often tasked with understanding access violations, memory leaks, heap curruption issues and the like.
I quite enjoy this, and I've amassed quite a good understanding of various low level concepts, but the trouble is that I don't program in C++, and aside for the purposes of maintenance I don't really intend to.
What I mean by that is that if I ever need to develop something then at the company I work at the best choice is C# (more developers, other apps also in C# means better interops), so its not that I don't program in C++, it's just that whenever I do program in C++ it will be purely for the purpose of learning C++, and so I want to get the most out of it.
My view is that "Teach yourself C++" books and the like aren't very suitable as they focus too much on getting things done - there are usually many ways of doing things and so they tend to pick one method, so when I'm presented with some code that does things a different way I'm stuffed (e.g. a book teaches MFC, I then get presented with some ATL code and the book hasn't even taught me what ATL and MFC are, let alone how to recognise that what I'm looking at is different!)
I'm really looking for teach yourself C++, with the emphasis on understanding other peoples code.
IMHO C++ in particular is a language that you cannot learn by reading a "teach yourself" book, you really need to have several sources and one of these is actually to look at other people's code.
I would recommend reading Effective C++ and More Effective C++ by Scott Meyers to learn some of the pitfalls when programming in C++, it is a good way to learn especially when you are looking at people's code. Another site than can help is gotw as well, some excellent information is there as well.
Since you'll never be creating C++ programs from scratch, I recommend you narrow your vision and just look at the applications you will be supporting, concentrating on the things you do not fully understand and tackling them one-by-one.
I find http://www.parashift.com/c++-faq-lite/ to be a good basic resource for C++. When dealing with specific technologies like MFC or ATL, do some research beforehand on which book(s) will suit you best. My favorite method: a strong coffee, a comfy chair and a pile of candidate books at Barnes & Noble to review. Focused on-line searching will suffice as well.
There are no shortcuts to knowledge and mastery, but by limiting your focus you can save yourself some wasted effort. Generally speaking, the more complex the technology--or the more fundamental the design screw up--the more you need to know to fix it. It's the facts of life!
The C++ FAQ is a great source of information.
Despite others' answers, I don't think your problems will lie mainly with the language. Sure, you can look at the standard or Stroustrup, but these will only teach you language constructs.
Most of what you will have trouble learning, I imagine, will be windows-specific and whateverplatformyouareusing-specific.
Do read stroustrup and other language guides, but be prepared to delve into the docs for the libraries and systems you are using.
It sounds like you really need a copy of the C++ standard. (ISO/IEC 14882 - available in draft form for free online. the final version costs a few bucks)
Of course, Stroustrup's book would be a good choice too. But in general, focus on material that describes the language, rather than, as you say, "how to get things done".
If you're having to maintain C++ code that uses MFC and/or ATL to a large degree then the best way to learn how it works so that you are able to properly maintain the code is to write small applications that use MFC and/or ATL so that you get an understanding of hwta is going on when the code is run. Reading a book by Stroustrup will not help you in any way to understand MFC and/or ATL. The other thing you should probably be focusing on is how COM works since ATL is basically a framework of templates, macros, etc that makes using COM easier.
Hope that helps.
I've been doing C++ for 3-4 months in a local college and I'm doing extra reading / learning using Accelerated C++ and so far, I've "finished" it. Now, I'm wondering which book to get next that'll help me code better in C++.
I've looked around and found this: The Definitive C++ Book Guide and List
I'm sorry if this question may seem stupid for most of you here but I'm a bit tight in cash and I would really want to invest in something that's "right" for me at this time.
Right now, I only know the basics of stuff like (classes, templates, STL, iterators, dynamic memory management).
Do you have any suggestions? Should I focus on STL or templates..? Or should I read something like The C++ Programming language?
If you haven't yet read Stroustrup's books, they are definitely a good read. There's nothing quite like reading about the language from the person who designed it.
Whenever I learn a new language, I always try to find the canonical reference material written by the language designer or somebody very close to them.
In addition to reading Stroustrup's books (suggested by another answer here), I'd suggest his two FAQs as a great starting point:
Bjarne Stroustrup's FAQ
C++ Style and Technique FAQ
They both link to further reading material.
These two, along with the C++ FAQ Lite, are required reading for new programmers at my workplace.
Once you're even a bit more comfortable, consider jumping in to the community: subscribe to something like the boost mailinglists, watch the blogs of big name figures like Herb Sutter, read Alexandrescu's Guru of the Week articles. You may feel like you're in over your head (I still do often after many years of reading the lists) but you'll learn a ton, especially watching the language grow and evolve. (And this stuff is free!)
You can get more understanding from watching how a language changes over time, and how people actually use it, than you can from a million hours of memorizing the standard. (Not that shelling out a few bucks to have a copy of the ISO/IEC standard around is a bad idea, mind -- great for reference from time to time.)
As for books:
after the Stroustrup books,
start with the Meyers ("Effective") books.
I'd also recommend C++ Coding Standards -- a great amount of work went into gathering the "common sense" of the users of the language in this book.
Then if you want to blow your mind you can look at Modern C++ Design or some of the fun template metaprogramming resources...
Above all, just stay connected and interested. Mailinglists, blogs, websites, academic papers, magazines, whatever -- choose what suits you best, don't expect to follow everything all the time, but keep your ears and eyes open; find aspects that interest you and follow them!
The C++ Programming Language would give you the best overview of the language. It sounds like you have that but the section on object oriented programming is worthwhile. I'd probably spend more time learning about object oriented programming at this point than more specific C++ features.
A book like "Code Complete" might be a good choice for you.
I feel like you can probably make more progress learning to program by tackling real programming problems, rather than reading another book.
I certainly don't discount the value of books as a programming resource but I do think there is no better way to learn a programming language than writing real code. Given your financial constraints, you have the additional motivation that writing code is free.
Concentrating on a particular part of the language or a pattern for programming might be interesting, but a specific problem to solve will give you context that, in my opinion, is a more powerful learning mechanism.
Of course, you can't write code in a vacuum. You have already read Accelerated C++ which will probably give you more than enough to get started writing code, but there are also a whole pile of resources on the net that will help (StackOverflow is a great place to start).
Tutorials for Win32
Online C resources
VC6 Tutorial
These are my favorite:
Effective C++ - Scott Meyers
C++ Standard Library Tutorial and Reference - Nicolai Josuttis
I might suggest a library card, or hanging out and reading Border's, to make sure the books are helpful for you.
a Good book for templates - C++ Templates by David Vandevoorde, Nicolai M. Josuttis
Learn STL more and more, there is a
lot more to learn.
learn Boost. This would change how
you think about programming in C++.
If you want to go very deep, read Stroustrup's papers. Select a paper now and then, print it, read it carefully. Stroustrup is an excellent writer. reading his papers would make you a superior C++ programmer for sure.
My favorite list is :
A History of C++: 1979-1991, A
History of C++: 1979-1991. After
I read those papers I loved C++.
What is Object-Oriented
Programming?
Why C++ isn't just an
Object-Oriented Programming
Language.
Sixteen Ways to Stack a Cat.
This is a jewel that everyone ought
to read :)
If you don't want to spend money, you should learn multi-threaded programming. The basics are already in the books you have, and described in API documentation. Try to actively create a program with many threads that communicate back and forth, and then multiply the number of threads to see if you've made a good design.
You'll want to read up on Semaphores, Mutexes, and Critical Sections.
I take three approaches to multi-threaded programming:
Use a PostMessage style communication between threads
Pass thread-safe objects between threads through which data is stored and relayed
Initialize a thread on start-up, let it run on its own, and then retrieve the data at the end of the run
If you're ready to spend money, I would recommend Design Patterns as a good next-read. It's more generic, and you'll find some of the ideas make sense.
I think you started out with just the right book! For those who didn't know, this book starts with STL at the beginning and leaves pointers for the end. Most programmers learn C first, and consequently have a forever distorted view of what C++ can be.
It might be really interesting for you to now read 'The C Programming Lanugage' by Kernigan & Richie at this point. This is probably a necessity if you want to understand the mindset behind most C/C++ code in the world today.
But more important than your next programming book is to find a medium-sized program you really want to write, and go after it. Use all kinds of reference materials for the project. Incorporate a boost library or two in your program.
If you are tight on cash, read How to Think Like a Computer Scientist. Also read the FAQ lite.
I have been learning C++ for three months now and in that time created a number of applications for my company. I consider myself fairly comfortable with C++ / MFC and STL, however I don't just want to be an OK programmer, I want to be a good programmer. I have a few books on best practices but I was wondering if anyone could suggest reading materials that helped them and any disciplines which should be encouraged?
Thanks!
I would start with the Pragmatic Programmer, Code Complete, Refactoring and Design Patterns.
For C++, Scott Meyers books are very good, and will help take you to the next level.
If you don't already have it C++ by Bjarne Stroustrup, 3rd Edition
Uhm... Teach Yourself Programming in Ten Years (Peter Norvig)
3 months into c++ and you're already comfortable with it? Sheesh, I've been learning c# for over a year and have taken numerous Microsoft courses and I'm nowhere near comfortable with it.
That being said, you'll hear Code Complete tossed about as a very good book. I'm in the process of reading it now.
Marshall Cline's C++ FAQ Lite.
Herb Sutter's Exceptional C++.
Large Scale C++ Software Design by John Lakos gives guidance on design methods that will make your C++ more maintainable. It is pretty hefty but you can dip in and still get some benefits.
Somewhat off-topic: rather than suggesting books to learn, I'd like to mention some broad topics to consider.
Threading. This one is not much in demand if you use MFC, but in many other areas it's indispensable. The mechanics of threading APIs are easy to pick up, but learning all the corner cases takes a lot of time and practice.
Closures, Map-Reduce and other lisp-like techniques. Find out what they are, why they are not supported in C++, and how they are imitated in C++ (functors, and many other cases of stateful callback objects). For this I actually have a book: "Structure and Interpretation of Computer Programs".
Command Line. This gives you an idea on when not to code your own programs. Command line would be Unix command line - I don't know about MS's latest experimentation in this are, but cmd.exe is awful. Get Cygwin and start experimenting.
Scripting languages. This gives you an idea on when not program in C++. My favorite is Perl, but many people say Python, Ruby and whatnot. Hey, learn XSLT if you're so inclined!
I am sure I left out other areas. I'll mark this as Community Wiki - feel free to add.
Good blogs:
Guru of the Week, and all the books by Herb Sutter. Those will give you quite a lot to chew already.
Modern C++ Design by Alexandrescu if you want to get a good feel for what you don't yet know, and probably don't want to know.
Code Kata's for practice!
I have read several (not complete but some parts) of oreilly books on VB.net they are quite good, but if you want to be pro and have the time...
You can try out MSDN forums, help other people and discuss with them hard and complex problems, I think it's the best way..
learn another language. even if you won't use it, it's great for mind-opening.
I'd advice Lua, Scheme and Python. but almost anything else would do. (the most different from C, the best)
Josuttis and Vandevoorde - Templates: The Complete Guide
As I see, nobody mentioned Bruce Eckel brilliant books "Thinking in C++". IMHO, it`s one of the best books to start your C++ development from. From my point of view, first volume is more helpful that the second, but both of them worth reading.
http://www.amazon.com/Thinking-C-Introduction-Standard-One/dp/0139798099/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1227890306&sr=8-1
I lot of folks can suggest more modern, up-to-date books. But I still recommend The Annotated C++ Reference Manual by Margaret A. Ellis & Bjarne Stroustrup.
The ARM was published back in '90. It's become somewhat outdated with respect to templates. STL is (obviously) absent. (Though the website at sgi.com does a good job of covering STL!)
However, the ARM is dirt cheap (used). (Shipping will exceed the cost of the book.) Its signal-to-noise ratio remains off the scale. It's very good at digging into C++'s dirty areas, explaining what was done & why.
I still use it as a reference. I rank it up there with K&R.
Dietel/Dietel "How to program C++"... I still have this book on my desk (10 years in).. Every once and a while I re-read a chapter. I'd definatly get the Code Complete, as other have suggested. Infact read that first.
To get a better understanding of object orientation, spend some time in a Smalltalk. Squeak is a free download. Then read Richard P. Gabriel's Patterns of Software and thereafter his Objects have Failed.
Thinking in C++ - Bruce Eckel
Symfonia C++ Standard - Jerzy Grębosz
If you do nothing else, program.
When you are not doing that read about programming and when something strikes you as interesting, go implement something with that knowledge. I've found that this is the only way to really set the principals.
Staying up to date on blogs can be fun, but it is scattered knowledge. It seems to distract more than help. But combined with google and a desire to research something specific can really cough up tons of information. But dont' just subscribe to alot of rss feeds and expect to get better.
I think really studying specific topics helps expand your ability. Research topics that intrigue you, meet people doing things like you (conferences, user groups, irc, facebook, stackoverflow, etc) and above all practice your art.
You can check out the Boost library and a number of the books written about it. While this may not have been what you had in mind, IMO, the Boost libraries are examples of well-designed modern C++ libraries that use the features of the language in pretty much the way they should be used to create among the most effective solutions for their problem domain. Granted of course, there are bizarre libraries like preprocessor and MPL which make you wonder if you'll ever have any use for them, but they're all round quite good. From my own experience, exploring the library and its literature has given me insight into how C++ can be used effectively.
Boost
Beyond the C++ Standard Library: An Introduction to Boost