How do i go about reading source code?

In summary, when starting out, it is important to understand the overall structure of the code, as well as the specific semantics of the language you are using. It is also beneficial to understand common programming paradigms and methods used in the language you are learning.f
  • #1
2
0
I've been learning the absolute basics of a few programming languages and feel like I want to start taking a more "practical" approach to learning, so I've been looking into source code.
My question is pretty simple, where do I start? How do I identify the structure of the files that go into making a game/website/etc?
 
  • #2
It varies depending on the application and the specific language.
However almost every language has a subset of instructions specifically dealing with reading and writing files.
(Open a file, read stuff into memory, write stuff out from memory to a file, Close file - and some others)

I'd suggest starting with visual BASIC (assuming you are using windows OS).
The whole point of BASIC is provide an environment which is very easy for a beginner to comprehend intuitively.
BASIC is not very efficient in use of machine resources, but modern PCs are sufficiently powerful that this won't impact badly on the performance of your projects.
When you have BASIC understood you might then want to look at more 'low level' languages, probably those of the 'C' family to begin with.
 
Last edited:
  • #3
It varies depending on the application and the specific language.
However almost every language has a subset of instructions specifically dealing with reading and writing files.
(Open a file, read stuff into memory, write stuff out from memory to a file, Close file - and some others)

I'd suggest starting with visual BASIC (assuming you are using windows OS).
The whole point of BASIC is provide an environment which is very easy for a beginner to comprehend intuitively.
BASIC is not very efficient in use of machine resources, but modern PCs are sufficiently powerful that this won't impact badly on the performance of your projects.
When you have BASIC understood you might then want to look at more 'low level' languages, probably those of the 'C' family to begin with.

Thanks!
 
  • #4
Have you read through the classic C book by K&R yet?
 
  • #5
Before I do a recommendation, I will assume that you have elaborated enough reading source code and explaining its structure and behavior, in the programs you have already created. This is crucial for going further to whole projects, whether it is for the web or for a desktop or mobile application.

I recommend creating or finding some small example projects on the net, see what the overall structure of the files is and read source code in steps that you can manage. Don't rush it, because this cannot happen overnight.

As rootone said, you can begin with a Windows project. I recommend using Visual Studio in this case, but keep in mind that when you create a software project, the IDE creates the necessary structure and give a lot of templates and libraries, in order to make the life of developer easier. In order to keep all this to a minimum, just start with a small project, in order to grasp how things work and go from there.

If you know - or want to learn, other languages not in the Microsoft family - although many of them are now supported by Visual Studio, you can try another IDE. Two of my favorites are Eclipse and DevC++ (there is a good 2009 edition for this). You can also create a web project, if you know some HTML, JavaScript and some server-side programming language.

There are many free IDEs and tools on the web and a good idea would be to download a WAMP software stack - Windows Apache MySQL PHP in case you have not seen this before. It includes a local web server to test your projects. The main point is the "start small - grow big" thing.
 
  • #6
This is what you need:
1) Source code that does something that you know and can test.
2) A development environment where you can make small changes to the code, run it, and see what the effects are.
3) A reference source (perhaps the www) for the semantics of the language.
4) Persistence and a definite analytic bend in your thinking.

Then fiddle around - you will be learning the language semantic, the library functions (reading files or whatever, and picking up some of the programming strategies used by the author.
 
  • #7
You should learn the basic programming flow for a given language and then extend this with applications to some domain.

Usually the code bases organization is relative to the domain that it is targeted for.

Video games are organized a specific way as are database platforms/engines and other specialized pieces of software.

You will need to understand both the organization of the flow control (in the language itself) as well as domain knowledge to be able to really go through any kind of code (particularly if it is extremely complicated with many tens or hundreds of thousands of lines or more).
 

Suggested for: How do i go about reading source code?

Replies
1
Views
823
Replies
2
Views
581
Replies
11
Views
627
2
Replies
60
Views
2K
Replies
1
Views
162
Replies
12
Views
902
Replies
22
Views
1K
Replies
1
Views
613
Back
Top