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.
  • #1
Kott
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?
 
Technology news on Phys.org
  • #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
rootone said:
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).
 

1. How do I start reading source code?

To start reading source code, the first step is to make sure you have the necessary tools, such as a code editor or a web browser with developer tools. Then, find the source code you want to read and open it in your preferred tool.

2. What should I look for when reading source code?

When reading source code, it's important to look for patterns, comments, and documentation. These can give you valuable insights into the code's purpose and functionality.

3. How do I understand the logic behind the code?

To understand the logic behind the code, try to trace the flow of the program by following the functions and methods. Pay attention to variables and how they are used, and try to identify any loops or conditional statements.

4. How can I improve my understanding of source code?

One way to improve your understanding of source code is by practicing reading and analyzing different types of code. You can also seek out resources such as tutorials or online courses that can help you learn specific languages or frameworks.

5. How do I deal with complex or unfamiliar code?

If you encounter complex or unfamiliar code, it can be helpful to break it down into smaller parts and take time to understand each component. You can also try researching the language or framework used and consult documentation or online forums for clarification.

Similar threads

  • Programming and Computer Science
Replies
1
Views
627
  • Programming and Computer Science
Replies
2
Views
278
  • Programming and Computer Science
4
Replies
107
Views
5K
  • Programming and Computer Science
Replies
21
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
8
Views
866
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
2
Replies
55
Views
4K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
Back
Top