1. Introduction
Hello, hello! So, you want to learn programming. Whether that's because you want to bring an idea to life, or find computing fascinating, or just think it'll be fun, everyone has their own reason for learning how to code. I'd like show you how to learn programming in a way that's both practical and enjoyable.
First off, what actually is programming? Put simply, it's a way of telling a computer what you want it to do - generally in a very explicit, clear-cut way.
Computers are really good at taking some input, running some manipulations or calculations on it, and giving back some output. Both the input and the output are data.
What might our data be for input?:
- A text document
- A digital photo
- An MP3
- A spreadsheet of numbers
What calculations would we perform on those?:
- Spellchecking on the text
- Applying a filter to the photo
- Boosting the bass of the MP3
- Calculating tax information on the spreadsheet
We're getting ahead of ourselves, though. When you really get down to it, some of the above gets pretty technical.
Let's start with some arithmetic. Note: you do not need to know advanced math to be a programmer!
Imagine a math problem like 2 + 2
or 3 * 4
.
Very simple on its own, but if you think about it, you can keep combining
more and more simple problems to form a more difficult one. Say...
2 + 8 * 3 / 6 * (10 - 7)
Suddenly you've got a more complex problem, but so long as you follow some rules (PEMDAS / BODMAS), you can break it back down into smaller parts to make it easier to solve:
2 + 8 * 3 / 6 * (10 - 7)
2 + 8 * 3 / 6 * 3
2 + 24 / 6 * 3
2 + 4 * 3
2 + 12
14
Computing works in the same way: every complex procedure is just a series of smaller procedures, that can even be broken down and re-combined in different ways.
This book uses the Clojure programming, which is known to be particularly good for breaking complex problems into smaller, easier ones.