So you've picked a language, and you can write simple programs, for example to take in some numbers, add them together and display the result, or to play the number guessing game (the computer thinks of a number, you guess, and it tells you higher or lower). Now you're ready to start to learn how to actually program - how to think like a computer!
If you're not here yet, we suggest going back to the Getting Started page first.
Being very, very literal
Computer languages are very much like human languages. They are how you talk to a computer in a way that it understands. The second challenge we mentioned (in the Getting Started page) when learning programming is to use that language to describe the problem that you want to solve to your computer. This is difficult because while computers are very fast at performing mathematical operations compared to humans they are incredibly literal and have no imagination and no common sense.
Solving lots of Problems
The way to learn to speak computer is to do it. Lots. Solve as many problems as you can think of, no matter how trivial or silly. If you find it hard to think of any, or want some new suggestions, the following resources can help. It'll be easier to learn if you're enjoying yourself, so try and find things that interest you.
Keep in mind when doing challenges like these that you are trying to solve the problem, but also to learn useful things about programming as you do. As you find challenges, don't be afraid or reluctant to look up parts of solutions and learn how things should be done properly. For instance, see the next section about Data structures for one large section of programming skills.
|Mathematical challenges in code form||Project Euler|
|Similar challenges for Bioinformatics||Rosalind|
|Online daily challenges||HackerRank|
|Recreate a video game|
Write battleship, simon says, noughts-and-crosses, pong, towers of hanoi - either the game, or a computer model to play the game!
|Recreate something you use (WARNING - can be quite hard)||
Write a simple text editor, calculator, message-of-the day generator
|Recreate the basic models in your research||
Ising Spin, Lotka-Volterra models, Brownian motion
|Do one of the classics||
Conways's game of life, Langton's ant
Data Structures and Algorithms
When describing a task to a human you can ignore lots of parts of the task because a human already knows how to do them, but computers intrinsically are not very clever at all. If you want a computer to store a piece of data somewhere there has to be some code that tells it exactly where to put that data. In any of the languages that we've suggested you don't have to be that specific but you are often only one level removed. For example, in both C and Fortran you don't have to say where to store data but you do (sometimes) have to tell the computer how much you want to store. If you want to store more data later then you have to tell it to create the larger data store, move the old data across and then release the older data store. C++ and Python both avoid this but there are costs associated with such automation.
When you try getting into actual tasks things get even more complex. Imagine that you want your computer to store a phone book linking people's names and phone numbers. Storing the names and the numbers is fine but what if you want to search for a phone number by name? What if you want to search for a name by phone number? The computer doesn't automatically know how to associate two pieces of data together, you have to tell it. There is more than one way of doing this and sometimes different ways have different advantages and disadvantages. At this point you are into the world of data structures and algorithms, and again there are courses that cover this.