473,473 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Source code reading list

Since the best way to learn how to program well is to read other
people's programs, which open source projects written in C stand out
as examples of well-written code?
--
There's no place like ~!
David Delony
E-mail: ic*****@gmail.com
Blog: http://ddelony.livejournal.com
Jul 21 '07 #1
7 1754

"David Delony" <ic*****@gmail.comwrote in message
news:sl*******************@davids-powerbook.local...
Since the best way to learn how to program well is to read other
people's programs, which open source projects written in C stand out
as examples of well-written code?
It really isn't.
You should read other people's code of course, but there are all sorts of
reasons why reading working "real" programs won't tell you how to do a good
job yourself.
Think of a program as a building. Not a house. A functional building like a
factory that has to be built to budget and always has some special
requirements. Normally the procedure will be to buy in a lot of pre-formed
components - walls, stairs, roofs and so on. Then they are bolted together.
But because our factory is a real building housing a unique process, some
will have to be modified. You might need air flow towards the "dirty end",
so you've got to seal all the windows, take out all the firedoors, and put
in fans, for instance. Then because you've taken out the firedoors you might
need to put in a sprinkler system to comply with regulations. So we end up
with a lot of standard components, modified components, and some custom
built components, all welded together and then put under a facade to make up
a finshed building.

To really understand how to make a building like that youself, it is best to
go to the standard components. The finished building will often confuse.
Code, such as mass of defines to make a file compile under both Windows and
Unix, can be well-written in the sense that it achieves the goal, whilst
being very hard for a human to understand and not a good basis for other
code, often not even a good basis for another cross-platform program. Often
there will be bits which have been micro-optimised, or hacked to get round
some late-breaking design problem.

"The only thing that is worse than pseudo-code [in academic texts] is real
code". I don't actually agree with this, but it has a point. Real code can
be hard to read, unless it is deliberately written for the purposes of
instruction.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm


Jul 21 '07 #2
Malcolm McLean said:

<snip>
"The only thing that is worse than pseudo-code [in academic texts] is
real code".
Bunk.
I don't actually agree with this,
Neither do I.
but it has a point.
No, it doesn't.
Real code can be hard to read,
Then rewrite it so that it is easy to read.
unless it is deliberately written for the purposes of instruction.
All code should be deliberately written for the purposes of instruction.
If your code isn't readable, it isn't finished yet.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 21 '07 #3
Richard Heathfield <rj*@see.sig.invalidwrites:
All code should be deliberately written for the purposes of instruction.
If your code isn't readable, it isn't finished yet.
I just found a new signature.
--
"All code should be deliberately written for the purposes of instruction.
If your code isn't readable, it isn't finished yet."
--Richard Heathfield
Jul 21 '07 #4
Malcolm McLean wrote:
>
"David Delony" <ic*****@gmail.comwrote in message
news:sl*******************@davids-powerbook.local...
Since the best way to learn how to program well is to read other
people's programs, which open source projects written in C stand out
as examples of well-written code?
It really isn't.
You should read other people's code of course, but there are all
sorts of reasons why reading working "real" programs won't tell you
how to do a good job yourself.
I agree with this. I believe that reading other's code teaches you how
to read code. This is an important, allied, skill to programming. It
doesn't teach one to programming. You learn that, not surprisingly, by
programming.

I personally think it's a huge mistake for newbies to do what people
often recommend, go and read code off in sourceforge or whatever. I
think they should (after working though a good textbook and doing many
exercises) find a small project that interests them and code it up.


Brian
Jul 22 '07 #5

"pete" <pf*****@mindspring.comwrote in message
news:46**********@mindspring.com...
Richard Heathfield wrote:
>>
Malcolm McLean said:

<snip>
"The only thing that is worse than pseudo-code
[in academic texts] is real code".

Is K&R, an academic text?
No. It's a primer for a computer language. Academic texts describe new
algorithms or mathematical results.
>
A text description accompanied by C code is best,
but given a choice, if I want to learn an algorithm,
I prefer to see it coded in C,
rather than described in English.
I agree with that. However journal editors normally don't. They want to see
funny E notation rather than loops.
What's annoying is that, without fail, there is always one term in the
expression which isn't properly defined in the text, or is hard to obtain,
like "the second derivative of ..." where ... is some stupidly complex thing
with imaginary numbers and the like all over the place, that is quite beyond
my calculus skills.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jul 22 '07 #6
On Jul 22, 4:08 am, David Delony <icky...@gmail.comwrote:
Since the best way to learn how to program well is to read other
people's programs, which open source projects written in C stand out
as examples of well-written code?
Last time I looked, this project had exceptionally
well laid out source code, compared to other
open-source projects:
ftp://ftp.thangorodrim.net/pub/angba...d-3.0.6.tar.gz

Jul 22 '07 #7
David Delony <ic*****@gmail.comwrites:
Since the best way to learn how to program well is to read other
people's programs, which open source projects written in C stand out
as examples of well-written code?
If I may be permitted to toot my own horn, I would like to point
to Pintos, an educational operating system, as an example of
well-written, easy to understand code, at
http://www.stanford.edu/class/cs140/.../pintos.tar.gz
or
http://www.stanford.edu/class/cs140/pintos/pintos/
It is not strictly conforming C by any stretch of the
imagination.
--
Ben Pfaff
http://benpfaff.org
Jul 22 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Michael Foord | last post by:
I'd like to formalise slightly the license I release my projects under. At the moment it's 'free to use, modify, distribute and relicense'. This is basically fine as I don't want t oprevent people...
29
by: Frank Millman | last post by:
Hi all I am writing a multi-user accounting/business system. Data is stored in a database (PostgreSQL on Linux, SQL Server on Windows). I have written a Python program to run on the client,...
17
by: wana | last post by:
I was reading through original source code of ping for some insight and was confused by unusual code. Entire listing available at: http://www.ping127001.com/pingpage/ping.html #include...
4
by: kj | last post by:
I consider myself quite proficient in C and a few other programming languages, but I have never succeeded in understanding a largish program (such as zsh or ncurses) at the source level. ...
2
by: Booker Washington | last post by:
ORIGINAL POST BELOW.. this is an addendum.... read from THE ORIGINAL POST first and below... andthen come back up to this section now upon further reading, i can provide some more...
0
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a...
4
by: Peyman | last post by:
Hi, I was reading the source code of an implementation of STL by HP company 1994, and Silicon Graphics Computer Systems, Inc. 1996, 1997. Which I found that for implementing a Linked List, they...
10
by: Pavel Shved | last post by:
Is there a program of wide use that automatically extracts template parameters requirements from source code of template functions? I mean the following: assume we have a template function that...
6
by: Paul Wilson | last post by:
Hi all, I'd like to be able to do the following to a python source file programmatically: * Read in a source file * Add/Remove/Edit Classes, methods, functions * Add/Remove/Edit Decorators *...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.