Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How do i go about reading source code?

  1. May 31, 2016 #1
    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. jcsd
  3. May 31, 2016 #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: May 31, 2016
  4. May 31, 2016 #3
    Thanks!
     
  5. May 31, 2016 #4

    berkeman

    User Avatar

    Staff: Mentor

    Have you read through the classic C book by K&R yet?
     
  6. May 31, 2016 #5

    QuantumQuest

    User Avatar
    Gold Member

    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.
     
  7. May 31, 2016 #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.
     
  8. Jun 13, 2016 #7

    chiro

    User Avatar
    Science Advisor

    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).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted