tags:

views:

329

answers:

8

Something well-written that does more than just print "Hello world!" and is much less complex than the Linux kernel.

For example the program SetTime which comes with Visual C++ source code and project files. This is described by its author as being written "with meticulous care as a programming example to legibly demonstrate a variety of Windows programming techniques and constructs".

Just any source code is not necessarily good for learning from, see Uri's caveats in answer to a similar question.

A: 

All open source programs maybe ? The best way i can propose you trying learning is reading AND understanding HARDER open source applications than you can usually understand so you get better, you just need a lot of patience and googling. Just 2 cents, mate. Hope my suggestion will help you.

Just because there is source code doesn't mean it's any good as an example for learning from. See Uri's caveats at http://stackoverflow.com/questions/144568/learn-c-from-open-source-code#144609
Rob Kam
A: 

If you want to explore some slightly more advanced (yet still very basic) concepts, you can write iterative and recursive functions to do Fibonacci series. This is commonly used as a teaching example in programming classes.

http://en.wikipedia.org/wiki/Fibonacci_number

Adam Pope
+3  A: 

"Scribble", the Microsoft Foundation Classes (MFC) tutorial program.

And, of course, EVERY program in Petzold's "Programming Windows":

http://www.charlespetzold.com/pw5/index.html

If you are doing WIN32 API programming, Petzold has been the place to start for about 20 years.

Corey Trager
A: 

I don't know if there is a repository of programs of the type you describe. Many times a good book will use several examples to illustrate the concepts being discussed. These example programs would be non-trivial depending on what concept you are learning. However, most of these programs do not translate well into real life because they a based on artificial examples created "with meticulous care" to illustrate the single concept at the expense of others.

So the short answer is: You will find the examples you are looking for in books and tutorials.

However, I second newoldman's answer that if you wanted to learn code you have to read code, and finding existing code that implements real life solutions as many open source projects do is a difficult but sure way to learn code. The only problem is that the "real" code would not be written with you (the learner) in mind, but more experienced programmers.

Vincent Ramdhanie
A: 

In the Java world, I've found it helpful to browse the source code for the Spring framework, Google collections and, most of all, the JDK.

In the Ruby world, I've found it helpful to develop the Depot application used in Agile Web Development with Rails and then add features of my own to it. That prepared me to to go off and develop a Rails app on my own.

Choosing a set of interesting programs to teach is an acknowledged problem in the computer book publishing business. One can either use a whole bunch of disparate and unconnected programs which might never do much more than say 'Hello world'. Or one can pick a specific project and develop it throughout the book. Advantage of the former approach is that you don't have to read the rest of the book to get the example. Its disadvantage is that it misses the interdependencies that every real world program will have with its other modules. Advantage/disadvantage of the latter approach would be the converse of the former.

Alan
A: 
nmiranda
A: 

Minix was designed to help teach students about operating system kernels. Quoting Minix creator Andrew S. Tanenbaum:

I just wanted to show my students and other students how you could write a UNIX-like system using modern technology. A lot of other people wanted a free production UNIX with lots of bells and whistles and wanted to convert MINIX into that. I was dragged along in the maelstrom for a while, but when Linux came along, I was actually relieved that I could go back to professoring.

CesarB
Keep in mind that this only applies to Minix 1 and 2. Minix 3 was written as a full-blown OS with a focus more on security and reliability than on teachability.
Jörg W Mittag
A: 

Not entirely the answer, but there is Logo.

Logo was created for educational use, more so for constructivist teaching, by Daniel G. Bobrow, Wally Feurzeig and Seymour Papert. It can be used to teach most computer science concepts, as UC Berkeley Lecturer Brian Harvey does in his Computer Science Logo Style trilogy.

From Wikipedia.

chakrit