I have a confession to make: I really like tidying up. Whether it’s my room, my laptop, someone else’s room or code. I really like stuff being neat and tidy and organized. I am obsessed with making plans and lists and lists for what plans and lists I have to make and so on.
And this is exactly why programming is perfect for me. When you break it down, coding is nothing more than writing a todo list for the computer.
Let’s look at a code example. The famous “Hello World” in Java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
How is this a todo list you might ask. Here’s how:
- You define which areas the todo list is concerned with, in this case the class HelloWorld (e.g. my house) and the method main (my room)
- You tell the program what to do: It is supposed to print the sentence “Hello World!” in the console (my wallpaper, although my parents would kill me for that)
Now, a pseudo-code example that is closer to reality might look like this:
SophiesHouse {
SophiesRoom {
while(desk == not tidy){
put one item where it belongs;
}
}
}
So basically, as long as my desk is not tidy, I will put away one thing that’s on there but shouldn’t be. And just so we’re clear which desk I have to tidy, we specify that it’s the desk in my room in my house.
And that's all there is to it. Of course, it gets complicated very fast but a program is and always stays a todo list. That's the beauty of it. Even a behemoth like Google's search engine is one big todo list with millions if not billions of sub-todo-lists and sub-sub-todo-lists and so on.