What source code is better for studying?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.

What program source studying is more productive?

First Linux kernel release
6
27%
Visopsys
0
No votes
Other OS
6
27%
ZSNES
0
No votes
FCE Ultra
0
No votes
Z26
0
No votes
eMule
0
No votes
Firefox
0
No votes
VLC
1
5%
Other application
9
41%
 
Total votes: 22

User avatar
~
Member
Member
Posts: 1226
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

What source code is better for studying?

Post by ~ »

What do you think that would in general result the better suited source code to learn new things if you are to dedicate a very long time to study it and dissect all components of it?

What I'm looking for is a program that by studying can help me learn the "basic" things that will help me build up a new level of programming ability and knowledge, taking into account a balance of several knowledge branches.
YouTube:
http://youtube.com/@AltComp126

My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
User avatar
xvedejas
Member
Member
Posts: 168
Joined: Thu Jun 04, 2009 5:01 pm

Re: What source code is better for studying?

Post by xvedejas »

Whatever interests you most, because that's what you're going to end up studying the best.
User avatar
~
Member
Member
Posts: 1226
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: What source code is better for studying?

Post by ~ »

Well, I don't have a particular interest in any application right now, because what I'm looking for is to be able to distinguish which one could be the better "generic" learning experience to achieve a proficiency level similar to those programmers and also with the better balanced and understandable variety of knowledge.

I know that studying OS code will require to understand things "from scratch", while studying user space programs will go more towards using OS frameworks and interfaces, but both them have important things. So what is left is to determine which one would be more convenient in general terms (without any favoritism) to dedicate an important amount of attention and time.
YouTube:
http://youtube.com/@AltComp126

My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: What source code is better for studying?

Post by AndrewAPrice »

For a terrific (IMO) example of Object Oriented programming, you can't go past OGRE. Open source, designed to be extremely fast in real time, and an example of flexibility which can be extended in almost any where, and best of all it's widely used so it doesn't just remain theoretical.
My OS is Perception.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What source code is better for studying?

Post by Solar »

Voted "other".

I believe that everything that is to be learned about coding - as in, how to structure your code, coding techniques etc. - can, yes should be learned in user space. OS / kernel space code adds a lot of "special flavor", because you're much closer to the hardware, and much of this is bound to confuse someone not really proficient in the language. At the same time, OS / kernel space code adds nothing, or only very little (and then usually not very good things), in coding techniques.

A behemoth like Firefox, on the other hand, has many "Firefox-ish" things to it, and is of a complexity (both in logic and in source structure) that makes learning from it rather difficult.

What I would recommend, is to not choose one large project, but many very small ones. Tools that do little things, so you can understand what a source file, what a function is for, so you can focus on how the code does something, not the "WTF is going on here". Because you're looking at many small projects, you'll see many different coding styles, project structures etc., see what is good readable code and what's incomprehensible, how different developers achieved similar goals, etc.
Every good solution is obvious once you've found it.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: What source code is better for studying?

Post by NickJohnson »

I would also advocate writing code at least as much as you read it. If you start writing something and it comes out badly, by refactoring and fixing it you not only learn what the proper technique is and what the improper technique is, but also *why* the proper technique is proper and *how* to turn bad code into good code.

I also personally find it almost impossible to understand a program that is more than an order of magnitude larger than anything I have written. So creating something large, even if it is slow or messy, can help you understand other large projects by teaching you to at least comprehend complexity, if not deal with it better.

Imo, the best way to understand a wheel is to reinvent it, albeit the slowest.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: What source code is better for studying?

Post by earlz »

NickJohnson wrote:I would also advocate writing code at least as much as you read it. If you start writing something and it comes out badly, by refactoring and fixing it you not only learn what the proper technique is and what the improper technique is, but also *why* the proper technique is proper and *how* to turn bad code into good code.

I also personally find it almost impossible to understand a program that is more than an order of magnitude larger than anything I have written. So creating something large, even if it is slow or messy, can help you understand other large projects by teaching you to at least comprehend complexity, if not deal with it better.

Imo, the best way to understand a wheel is to reinvent it, albeit the slowest.
Fixing bad code can really teach you how to write good code, but some bad code is too far lost that it would actually be better in every way(other than the learning lesson) to just rewrite it.

You may say you find it "almost impossible" I think what you mean is "almost impossible because I lose interest". I recently started a programming job with a huge(10,000+ lines) project written in Delphi. I did not know Delphi or any flavor of pascal when I walked on the job. I was fixing trivial bugs/refactoring within a week, rewriting things to work with a different type of use(as in, having to add some things and remove other things to make a new "use" for the program) in my second and third week, and now its my fourth week and I'm working on the rewrite of it in C#....

So, what my point is, is that you might not be able to understand all code as a hobby project, but if your paid to sit and look at the code for 8 hours a day, you will learn to understand even the most nontrivial of code.

and some wheels should never be reinvented. (who wants to implement sorting again!)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What source code is better for studying?

Post by Solar »

earlz wrote:I recently started a programming job with a huge(10,000+ lines) project...
:shock:

I think I have to readjust my scales. Of the three projects I've worked on professionally so far, none had less than 200.000 lines...
Every good solution is obvious once you've found it.
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: What source code is better for studying?

Post by Firestryke31 »

I think that studying a simple game's source (modern newbie tetronimo game) would be a great way to learn some tricks, then as you get more experienced, you can move on to more complex games, some of which (especially on consoles or older DOS games) are operating systems in and of themselves: memory allocation, file system management (compressed package files), GUI, threading system, etc.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: What source code is better for studying?

Post by neon »

earlz wrote:I recently started a programming job with a huge(10,000+ lines) project...
By my standards, any project less then 100kloc is a small project...
~ wrote:What I'm looking for is a program that by studying can help me learn the "basic" things that will help me build up a new level of programming ability and knowledge, taking into account a balance of several knowledge branches.
I would focus more on software engineering practices

Code: Select all

 and managing complexity [one function does only that one function]. Studying existing programs may help with this in understanding the practices that they used in their project, but you should never stay with just one long term project. Quoting from Solar, "What I would recommend, is to not choose one large project, but many very small ones.".

Perhaps it may be better to focus on a specific area of a program's code rather then the whole program?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: What source code is better for studying?

Post by i586coder »

well last few years i concentrate around operating system codding so i choose
"First Linux kernel release" to find out how linus wrote his OS and learn how to
write my OS :wink:
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: What source code is better for studying?

Post by earlz »

Solar wrote:
earlz wrote:I recently started a programming job with a huge(10,000+ lines) project...
:shock:

I think I have to readjust my scales. Of the three projects I've worked on professionally so far, none had less than 200.000 lines...

hmm... well I'm not too experienced I suppose lol
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: What source code is better for studying?

Post by Brendan »

Hi,
earlz wrote:hmm... well I'm not too experienced I suppose lol
IMHO "lines of source code" is a fairly dodgy measurement. What you can do in ten lines of Delphi, you could probably squeeze into a few lines of unreadable C, and it'd probably take an assembly language programmer about 100 lines.

It also depends on where you live. For example, in Australia 10,000 lines is fifty times more lines than 200.000 lines, but in some other countries 200.000 lines is twenty times more lines than 10,000 lines... :D


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: What source code is better for studying?

Post by Zenith »

And in even other countries, 200.000 lines is twenty thousand more than 10,000 lines! 8)

But back on the original topic, I'd have to agree with Brendan's earlier observation with reviewing multiple and very small projects - but always remember to also review the code and structure of projects that are developed through mass (but organized!) collaboration; programming techniques, development and discipline while working with others, which always (theoretically) display how to organize and properly abstract parts of a code project. And continuing that vein to the extreme, throw in the source of a library like GLIBC to see ways of how abstraction can go wrong :twisted:

Hope this helps!
"Sufficiently advanced stupidity is indistinguishable from malice."
manonthemoon
Member
Member
Posts: 65
Joined: Sat Jul 04, 2009 9:39 pm

Re: What source code is better for studying?

Post by manonthemoon »

MessiahAndrw wrote:For a terrific (IMO) example of Object Oriented programming, you can't go past OGRE.
I second that. OGRE is an interesting project, and it's pretty big but not to the point that it's too hard to follow.

It has a clean design that you might learn from, plus you'd get to learn about a graphics engine.
Post Reply