Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am learning C++ as a first language. I feel like I am about to hit a ceiling on my learning (I am not learning through a class) if I don't start looking at actual code soon. Here are my two main questions:
Where can I find source code
What is a good litmus test on code's quality (I've obviously never developed in a work environment)
I hope this is relevant to SO, but I can see the need to close this. Thanks for the help.
Related:
Examples of "modern C++" in action?
I would recommend Boost. Using Boost will simplify your program design. Reading Boost source code can show you how to use C++ to solve some challenging problems in a concise way.
This add on library is itself written in C++, in a peer-reviewed fashion, and has a high standard of quality.
I think your two best bets for finding C++ code are to go to the popuplar open source repositories.
CodePlex: http://codeplex.com
Google Code: http://code.google.com
SourceForge: http://sourceforge.net/
These all have high quality C++ projects you can take a look at. I don't think there's a great metric for judging quality on a large scale. I would start with the more popular projects which may be more likely to have quality code.
The List:
SourceForge: http://sourceforge.net/
Boost: http://www.boost.org/
CodePlex: http://www.codeplex.com/
Google Code: http://code.google.com/
Google Code University: http://code.google.com/edu/
koders.com: http://www.koders.com/
The net is chock-full of open-source C++ code. Why not pick a few such projects, and, even better, start helping out of them? No better way of learning than by doing!
I would recommend getting a good book, which will be packed full of source code examples!
C++ in a Nutshell
You can also search open source code at www.koders.com
I think you got some good answers already, I would like to add this suggestions for picking a project from one of the open source project repositories: Pick a widely used but preferably smaller project that has been around for a while and targets a domain that you are specifically interested in. That way you will be able to get a better idea of production ready code and be able to learn something about that domain.
I found the source code and documentation of POCO are quite readable, and
unlike some other open source projects that focus on handling one specific problem, say GUI or Logging, this library focuses on developing a complete application, thus covering a quite broad area(file system, text processing, networking, logging etc ).
it uses modern C++ idioms. So by reading the implementation you can learn modern C++ skills as well.
I would recommend OpenSG
It is an interesting topic, it uses concurrency modeling, networking, includes links to scientific papers, is well documented, uses real c++ not c with objects stuff and almost all subparadigms and doesn't overuse them, is easily accessible AND who would have guessed... I am a fan of it ;)
OpenSG - Home
C++ is a great language, but kind of heavy as a first language. Try python.
1) Where can I find source code
Reading code is harder than writing it. This is especially true of large, complex languages like C++. Without already knowing the intricacies of the language, you don't stand much chance of getting knowledge from the complex code others write in production. You're going to have to learn the very smallest parts first, on your own by writing it. As you learn c++, you will also learn programming.
2) What is a good litmus test on code's quality
There isn't one. That's not going to be an easy thing to learn, either. It comes from experience. But really, the way you know the good code from the bad, is that after you've had some time to familiarize yourself with the layout of a project, you can understand what any given piece does, after you look at it. Readable code has quality, whereas confusing code falls short.
Looking at other peoples code is a hard way to learn the basics. Find a tutorial on the net and get your feet wet that way. I'm sure there are many, fine printed books on the subject as well.
As you go, and get stuck or confused or lost, post questions here.
Code Project is the best place for source code.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have been a self taught web developer for a few years now, and usually use C#/ASP.NET, Python, and PHP. But I want to try to advance my skills by doing something more advanced. I am looking to try to build a database program like SQLite, or a mini MySQL sort of thing in C/C++ just to practice and learn new things.
EDIT:
My project doesn't have to be a RDBMS. It can be something like a simple web server or something. Just something to see if I like doing that kind of thing more than web development.
However, I can't seem to find any kind of book or tutorials online that teaches this sort of thing. Does anyone know where I can find resources regarding this? I have a C book that teaches the language itself, but I learn how to think through things a lot better when I try to build something specific like a database engine etc. Thanks for any input.
For literature I could recommend something like Accelerated C++ or Thinking in C++. I also recently got my hands on Code Complete, found it in a shelf at work, and it is as good as people say. Solid language agnostic advice.
Also you should separate C and C++, they may seem similar and people clump them together but it's really two different ways of thinking. Now the new C++11 makes the differences even more important to understand, C++ is just not C with classes.
Why don't you try something a bit smaller like a ray tracer? Its very attainable to write a simple one that can produce some nice images, and its something you can come back to again and again to add features.
You can read the book Learn C the Hard Way by Zed Shaw. He teaches you how to write C using Make and Valgrind. Later exercises have you write your own software package installer and a tiny web server. Best of all, it's free.
Updated broke link
Bookmark this resource, http://nptel.iitm.ac.in/courses.php?disciplineId=106
This is often a great/massive start point for in depth knowledge about everything from algorithms, dbms, graphics to real time systems. Complete video courses/lectures or written course materials. A place to expand knowledge or get ideas.
For example you could check the video lectures about dbms development
-> http://nptel.iitm.ac.in/video.php?subjectId=106106093
...Or why not this one about artificial intelligence -> http://nptel.iitm.ac.in/video.php?subjectId=106105077
No c/c++ examples but they drill down each part, patterns, strategy and algorithms.
...The only sad thing is that most professors speak in really bad English.
Well after #MitchWheat said that even writing something like SQLite was pretty ambitious, I chose to try an do a little web server instead and found this post which included a few links for doing that. Thanks for the input.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I was wondering how valuable open-source projects are to learn from?
I still consider myself "beginner" due moreso to lack of experience than lack of knowledge- I've read many C/C++ tutorials and taken classes and such, but I just really lack experience. Therefore, even though I understand the major data types and coding techniques, I don't have a solid grasp on what approach to take to use them in my own programming. Therefore, while I continue to read/practice/learn, I have been downloading lots of open-source code (random applications, emulators, games). It is worthwhile looking at them to help learn? I find it extremely interesting, but more often than not just get lost.
Second question, where does one usually start when doing this? Do you hunt down a main() function somewhere? Do you look at headers to see what functions will be available throughout the code and get an idea of what is around to work with?
Please let me know!
R
I personally wouldn't recommend the reading of the source code of open-source projects to a beginner, especially if they're mature projects. It may be overwhelming for a beginner since they tend to be rather large projects with thousands of lines of code, most likely of a non-trivial design.
If you lack experience, then the best way to gain experience is by writing your own programs and taking on your own projects that are of interest to you, in my opinion. You can certainly read other people's code to see "how it's done", but actually trying to implement those ideas yourself in practice does more to help you understand how to write code than just passively reading code. In turn, the gained understanding and experience will allow you to make better sense of other people's code.
It's sort of like math; you may know the formulae, and you can see how mathematicians/teachers/professors/etc. use those formulae, but you won't really understand them until you try them out yourself. Once you do understand them, then the kinds of things mathematicians write will make much more sense.
Try to focus on things you want to do, there's not a lot of point in looking at code for an application that you have no reference point for.
The best place to start would probably be to look at a project like Boost
But formulate a series of application tasks that you'd like to investigate, perhaps graphics, text editing or socket programming... and then work from there.
Getting a good IDE or programmers editor that will help you navigate the code is a major plus.
For example, Emacs + ECTAGS/CEDET/Semantic will help you browse all the functions / classes in a C / C++ project.
I'm agree with #In silico. It's very useful to see other's code, but only when it's a little bit over your level, so that you can learn something. I've seen quite a few projects that were too "over-engineered", so that learning from them when you can't really tell the good from the bad will be a bad idea.
Another thing is to learn from another programmer, when you could ask why he did one way and not another. In this case the difference in levels does not matter.
So I'd suggest programming by yourself, and looking on the other people's code for the same thing after you've tried it. In this way you'll be able to compare the choices you've seen and the decision you've made with someone else (when you don't know a problem in depth, any suggested solution would seem right). You know, In theory, theory and practice are the same. In practice, they are not.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Reading the reviews at Amazon and ACCU suggests that John Lakos' book, Large-Scale C++ Software Design may be the Rosetta Stone for modularization.
At the same time, the book seems to be really rare: not many have ever read it, and no pirate electronic copies are floating around.
So, what do you think?
I've read it, and consider it a very useful book on some practical issues with large C++ projects. If you have already read a lot about C++, and know a bit about physical design and its implications, you may not find that much which is terribly "new" in this book.
On the other hand, if your build takes 4 hours, and you don't know how to whittle it down, get a copy, read it, and take it all in.
You'll start writing physically better code quite quickly.
[Edit]
If you want to start somewhere, and can't immediately get a hold of the book, I found the Games From Within series on physical structure useful even after reading Large Scale C++ design.
Interestingly, "More C++ Gems" contains a shortened (to 88(!) pages) version of Lakos' book, which can also be browsed (fully, I believe, as it belongs to the first half of the book) online at Google books.
So, enjoy everyone interested:)
Lakos used to work for Mentor Graphics, who makes EDA software. He was involved in building EDA software in C++, where they wanted to use C++ efficiently ('no more than 5% overhead over C code') and sort out how to build software on early workstations that really would take a long time to compile a large C++ application.
The book is quite a good read - it discusses a wide variety of topics, and Lakos really did know his stuff. He really comes from a background of having to get efficient code out of a C++ compiler, as well as how to set up a C++ program so it is maintainable and compiles and links reasonably quickly.
I think that Lakos has a lot of insight, and I would recommend that you read it. However, it is 'trad' C++ from a time before features like templates were widely available. My copy is not for sale ;^)
I thought the book was a good read back in the late 1990s. It was out of date back then, now about as relevant as telephone book from the 1950s.
I worked with Lakos for several years where he tried to implement these ideas. I also had my modern C++ project I built of about 2000 source files-- large scale enough, and I've built a few more since. Build times are easily reduced by parallel distributed builds, using programs like icecream. Every complier will cache opened headers-- only by doing something really outrageous any modern build tool like scons will scale to thousands of translation units without doing anything really special, with build times, including tests, takes a couple minutes from clean.
Limiting your libraries interface to a few "vocabulary types" (not the same sence as the OO concept, he means just use Int, float, string, char, and a couple of other I don't recall) is extremely poor advice to scale anything. Your build is going to be looking for a type mismatch, you don't want this at runtime just to make it easier to write a make file.
And that's largely the gist of the book-- how do I write C++ in order that it works with tools from 1993? Additionally, the Mentor Graphic project the book describes was a disaster from all accounts. Even the book itself alludes to that.
Large Scale C++ is delivered in source code form-- these are the "physical dependencies," not link libraries (and the book never mentions other more important dependencies like databases, sockets, processor architecture, etc.).
The book is full of ideas that sound good, but there are much better ways to scale up in practice. If you want to study large C++ libraries, take a look at Boost or Xerces and see what they did. They really are implementing large projects, not writing about them.
It's a little out of date (in fact it was out of date when it was written). If I recall correctly, a lot of it was about reducing dependencies which you would probably do now with templates.
Although that's probably one of the lessons to learn on large scale projects, you aren't usually using cutting-edge features and tools.
Is “Large-Scale C++ Software Design” by John Lakos a mind-provoking (but usually overlooked) gem?
Yes.
It is an excellent book and an important one from a historical point of view.
Note that to implement the practices described in the book, you need considerable discipline and agreement within the team. Here are a few things to note:
Lakos has precise definitions for what he calls "components" and "packages". These are key for large scale design. However, they require adherence to conventions for how source and header files are named and the sequence in which they are included. It is a shame that most people (including those who quote Lakos) rarely follow these conventions.
The book is all about C++ but the concepts are more widely applicable. However, because C++ is such a complex language, a large part of the book is teaching you how to use C++ effectively. If you can get past that, you can actually find it useful even if you use other languages.
Some of the prescriptions such as on the use of "name spaces" maybe considered controversial now. Many believe that name spaces should be used in a limited way in C++.
Yes, in some ways, the book is a little dated and some of it is C++ specific. Nonetheless, it offers a lot of useful advice about dealing with complexity and coupling in large programs, and most of his advice applies to any object-oriented language. I also found it very readable.
If you can track down a copy, I'm sure you'll find it worth reading. It's in my top ten list of programming books.
I read it a long time ago, but I remember getting quite a lot from it; though as MadKeithV points out, that may just have been that I knew less then ;)
Certainly from a "how do I reduce how long this takes to build" perspective it's has lots of useful stuff, especially around reducing compile time dependencies, though possibly some of it is no longer relevant, or even possible, given how much templates are used these days.
And no, you can't have my copy either :)
I've studied C++ as a college course. And I have been working on it for last three years. So I kinda have a fairly good idea what is it about. But I believe to know a language is quite different from using it to full potential. My current job doesn't allow me to explore much.
I have seen you guys suggest studying a open source project and perhaps contributing to one too. So my question is, can you suggest one(of both?) to start with that is simple and doesn't overwhelm a starter.
I was in the same situation 12 years ago when I got my first programming job out of college. I didn't do any open source but I managed to gain a lot of practical and advanced C++ knowledge by reading books (the dead tree kind).
In particular, there was an excellent series by Scott Meyers which I feel helped the most in turning me from newbie to professional:
Effective C++: 55 Specific Ways to Improve Your Programs and Designs
More Effective C++: 35 New Ways to Improve Your Programs and Designs
Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library
The topics in these books range from beginner to advanced. It took me about 2 years working in C++ to understand every chapter in these books, so don't be disheartened if it goes over your head at some point... just try reading it again later :)
If you're willing to climb the very steep learning curve, I would think that you could do worse than studying parts of the boost libraries. I don't think there is another similar body of C++ code out there that is pushing the boundaries of what can be done in C++.
re project selection: you'll want to hack on something that has some relevance to you, otherwise it's just unpaid work. i might suggest eg. Pure, but will you find enough interest?
re advanced code: see Boost
Obviously learning something like this does not happen overnight; You can study existing open-source projects like other posters suggested. However, I have one more suggestion: I suggest joining one of the big IRC c++ channels (for example #c++ on efnet or freenode). Of course most of the questions / discussions going there are basic; however quite often interesting discussions and questions come up. Over the several years I've learned quite a bit just by participating in channel discussions.
My main advice would be that you do not need to stick to C++ to learn technique.. Study Erlang, Lua, and Haskell (lots of others). You will learn so much from these language that you can apply in C++.
Google protocol buffers is a very well written C++ application that sticks to the features of C++ that are proven in the industry -- i.e., they don't go over the top with features that cause headaches for using the code.
In terms of learning to use C++ to its full potential, well the full potential is often hidden. There are very few exceptional C++ programmers, even in the open-source community. So I suggest you read some books. Like the books from Scot Myers and Herb Sutter (all 6 of em).
Boost is an amazing library and has a lot of good code, ranging from simple techniques to very advanced techniques. It definitely touches all of the bleeding edge of C++ idioms. The problem with boost is, it doesn't work well with modern IDE features (code-completion being the main problem), and it has a LOT of symbols :D. It is the place to learn about generic programming and template meta-programming, the former represents the most advanced and immediately-usable idioms, and the latter you can skip for the immediate future.
Apart from the Scott Meyers books DSO has already suggested: Participate on SO and try to answer other people's C++ questions. If you don't know the answer, wait a little until some good answers are posted. You will probably get some idea where the gaps in your knowledge are and you could do some more reading to fill those afterwards.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I haven't done C++ for about three years and looking to get back and ready. What is the best way? any open source projects that I might want to look at to recall all the details and be ready for interviews?
I started reading (again) C++ Primer 5th edition but was wondering whether there's more efficient way since I did program in C++ for few years before.
Just wanted to add: Does anyone know about open source projects related to finance? (e.g. servers, fix, etc)
I was facing a similiar situation a while back, and my conclusion was - no matter how many smart books you read nothing will suit you better then practicing.
Find some tutorials or set yourself some simple goals and learn by doing.
Hope that helps
PS. A friend of mine asked me once "How do you eat an elefant? - in small pieces, one at a time"
I'd start in on a real project.
If nothing else, download an open source C++ project that's in the same realm as the jobs you want to target, and start modifying. Practice helps more than anything for being comfortable.
If you're going to focus on reading, or in addition to practice, I'd actually focus on reading books that work more on using C++ well, not necessarily learning C++. Effective C++, More Effective C++, and Effective STL are great for this - you'll learn new things while refreshing your old knowledge. You can always use the primer book as a reference to study things you've forgotten as you read about them elsewhere.
Pick something that you know very little about and attempt to make a program that works with that subject area. For example if you've never done GUI work fire up C++ and try to create a simple paint program in the GUI framework of your choice (Qt, WTL, whatever). Or if you've never worked with a database grab SQLite and create a little app that manages your time. Or better yet, combine all these areas into a larger program.
The key is to force yourself to learn how to do real, practical things and solve problems using the languages paradigms. Books are great to reinforce certain practices but they'll never replace hours of frustration trying to figure out why your pointers aren't pointing where they're supposed to.
If you are good at maths (or statistics, probability, finance, geometry) and want to recall how to build re-useable functions, classes, and templates, you are welcome to help us at mathlibcpp. I recommend it, its good learning. Building a complete library on a large subject is very educatively hard ;) I found a chance to use all OO methods I know in C++, even forced to learn more.
Regarding Fix, there is QuickFAST, a very efficient implementation of the 'Fix for streaming' protocol.
Regarding C++, I would look for something that uses Boost, as it seems to be a premiere library for C++ (QuickFAST uses it to some degree).
Check out http://www.topcoder.com. This is an amazing tool for practicing programming in many different languages (C++, Java, C, C#). You can even win money if you get good at it:)
As with anything, write many programs, (re)read the best books (such as Effective C++, already mentioned). :-)
And ledger is an open source finance program written in C++. (GnuCash is another but written in C.)
Most of KDE is written in C++, albeit with Qt's signal extensions. Probably lots of examples of good code there.