What is programming?
Table of Contents
Why learn to code?
Apple's co-founder Steve Jobs once said:
"I think everybody in this country should learn how to program a computer because it teaches you how to think"
Coding is a very powerful tool (especially for researchers)! Have you ever tried to re-analyse your data in Microsoft Excel, only to realise that you can't remember how you analysed it last time? Then begrudged how labour-intensive the re-analysis turned out to be? Or struggled through trying to customise an analysis or plot? If you answered yes to any of these questions, then programming (the words programming and coding will be used interchangeably in this book) may be the answer to your research woes. Programming allows you to easily and quickly reproduce results and figures... publication quality figures.
Like any skill, coding takes a while to learn if you want to do it well. Don’t be discouraged, because it will set you up for life. Much like learning to ride a bicycle or learning a foreign language, the hardest part is the initial learning curve. The aim of this book is to ease you into some of the generic programming lingo. You should then be set to take an introductory course in any programming language.
What is programming?
The first question that we need to ask is: what is programming? Is it magic that requires eye of newt and tongue of toad? Hopefully, you answered no to that last question. Programming is essentially writing instructions for your computer. Much like when you go away on holiday and have a house sitter you leave them instructions, such as: please water the plants twice a week, walk the dog in the morning, feed the dog in the evening, and help yourself to anything in the fridge. In this case you are the programmer and the house sitter is the computer taking instructions.
Unfortunately, computers don't understand human languages, e.g. English. When programming, you need to give the computer instructions in a language that it understands. This is much the same as talking to a pet dog. You expect the dog to understand 'sit', 'stay' and 'walk'. But even the most well-trained dog probably does not understand: "do you think my butt looks big in this?" or "what do you think of the current situation in Europe?". That is well outside of the dog’s understanding of both the English language and general concepts.
Your computer understands many programming languages. Here are a few that you might have heard of:
- R (This course will have an R-flavour to it)
The building blocks of programming
Learning programming is much like learning any foreign language. The key building blocks remain the same across languages: words are classified as nouns and verbs (yes, I know that there are more than just these two classifications!), and strung together into sentences and paragraphs. Programming languages also have universal building blocks that you will learn about in the next section of this book.