Introduction to Computer Programming
Coding. Software engineering. Programming. Call it what you will, but there’s no doubt that in today’s world, this skill is big business. So what exactly is it?
Computer programming is skill of creating computer software. It is common to see the phrase ‘writing a program’, and this is because that is exactly what is involved: as human beings, we are most comfortable communicating in natural language – those are the languages we read, write and speak, like English – but machines are fundamentally different. They operate not on natural language, but by performing calculations in binary (0s and 1s). It is very difficult for human beings to give the computer these instructions in binary directly: even the simplest of tasks would involve a great deal of tedious and repetitive instructions. Imagine, then, how difficult it would be to create something like an iPhone app by writing the instructions the processor inside operates on directly: impossible!
To solve this problem, computer scientists have worked over the decades to create a number of ‘languages’, which let programmers write instructions in words. These instructions are then translated, by another computer program, into instructions that the computer can process. This saves an awful lot of work, and makes spotting mistakes easier: it’s much easier to see that you’ve given the computer a ‘dodgy’ instruction when the words are in English than if you had to look at machine code directly!
My main aim in this blog post, now that you know what a programming language is, is to make clear that programming languages can be classified as one of two types: interpreted or compiled.
As I am sure that some of you have heard the names of some popular programming languages, I’ll start by saying that Python, Ruby, and Perl are all examples of interpreted programming languages. Whereas languages like C and C++ are compiled.
So, what’s the difference? Well, compiled languages are probably the easier of the two to understand. You write an application using the compiled language of your choice, and then a computer program called a compiler translates your code directly into machine code, and creates a new file (usually an .EXE file!) that contains these machine instructions. You can then transfer this file to another computer, without needing the compiler on that computer, and your program will run just fine.
Interpreted languages, on the other hand, rely on the use of an interpreter program. This ‘reads’ your source code – a software engineering term for the lines of programming language you’ve written – and executes instructions as it reads. So instead of creating a new executable file, the ‘interpreter’ goes through the source code line by line, reading what’s there and telling the computer what to do. The disadvantage most beginner coders notice pretty quickly, is that you can’t transfer your program to another machine without first installing the interpreter software on it.
It’s important to have an understanding of the basic distinction between the two. But knowing this won’t make you an excellent software developer: you need to write some code.
On that front, I’d like to offer four pieces of advice for the beginner coder that I wish I’d had someone to tell me when I started.
1. Depth over breadth. Don’t make the mistake of thinking that the path to success is to try to master every language there is! What you’ll really end up doing, is having a low-mid tier knowledge of lots of languages. The truth is that lots of concepts in programming are the same between many languages, they are just implemented a little differently between each. So it’s much better to focus on mastery in one or two languages. What you learn there will assist you when you choose to pick up another language in future.
2. Make sure you fail a lot. Don’t worry about getting it right all of the time! The only way to learn is to tinker and experiment with the language. If you get it wrong, the worst that will happen is you get a helpful (or sometimes not so helpful) message from the compiler/interpreter telling you that you’ve done something a bit wrong. And that’s how you learn. So just go for it.
3. Start small. If you’ve never coded before, don’t dedicate yourself to having your very first attempts make you a Silicon Valley millionaire. You’ll just get disheartened. The learning curve can be very steep, especially if you want to write very efficient code. So set goals that are challenging but attainable. In time, you’ll get to the skill level you want.
4. Code every day! Practice makes perfect is just as true in programming as it is everywhere else. As you become more skilled, you can work on projects with friends or on the internet. There are lots of ways to get coding experience each and every day.