Algorithm is a hard word. Developers should know something about it. But today there is something that is missing when you read some questions on Stack Overflow, or when you talk with new developers.
There is something somewhere. And I think that the missing link here, is that people is not learning how to make algorithms, is just learning how to code.
Developers around the world start learning with tutorials, written and video tutorials, that only teach how to work with a language. So the problem is somewhere around there. Developers are not learning how a computer work. Is just learning how to make a computer do what they want to do, but not understanding what is happening. So, a lot of simple task looks difficult, because tutorial only teach simple things, and not the logical around that simple things.
Language divides the simple tasks in keywords. There are instructions that make the things developer want to do. Usually, instructions are divide in some kind of types.
- Iterators (or loops): for, while, loop, do..loop..
- Conditionals: like if, switch
- Exceptions: Try..catch, on error…
- Type definition: dim, as
This not so low level instructions, are translated always to machine language, that is the assembler you have in your computer. But since this language is hard, usually you don’t write it. In fact, is easily not to even know about it.
That’s because the problem with assembler, is that the set of instructions doesn’t have all what you made need to make a program. if you want, check this to read something about assembler. Assembler is a hard language. you have almost no help debuging, no help writting code, there is no such thing like OOP, functions, parameters. All that things, you have to do it by hand. Totally by hand. That’s where using a high level language, help you get faster.
But the problem is that using only this high level language, developers doesn’t understand how to develop algorithm. If a developer doesn’t understand fully a language, and what is does, simple question are made like they are almost imposible things to do. Or worst, developers doesn’t even understand what are writting and what does it do.
I started developing in basic, like everyone, learning a language. The benefits of working in basic, and learning on it, if it doesn’t have any things like functions or OOP or even try…catch.. If fact, I don’t remember it is has a definition for array. (yes it has, was the data keyword)
This language teach me how to repeat an instruction without writing it several times. Also how to jump to other places (GOTO was not a bad word), how to go to a function (GOSUB is your friend here), how to get things in memory places (PEEK and POKE) and how to print things on the screen.
But when you see how they are teaching algorithms now, they are not teaching things like this. They are teaching a language. So you see questions that you can read like Newbie ones, just because nobody is teaching developers how an algorithm should work. Or how to read they own code. Or how to understand what is happening.
Understanding algorithm is not an easy thing. In fact, if you want to program an algorithm, it could take you some time. Even if you use a high level language. But an algorithm is the main thing that let you understand how programming language work.
Let’s make a little example. Supposed we create a new language, and that language doesn’t have all the instructions that you need.. in fact, you need a lot of more instructions. I will cheat a little here. I will pick my language from a game. In fact a game that visualize me with this problem.
My son plays this game. He’s not a great developer (yet), but this game make him realized that something is missing when teaching developing. Human Resource Machine is a simple game, about making a person do a simple task. The person, is in a fact a computer, since you are giving him a recipe (a program) that he has to follow.
We have there some kind of machine language. That is our set of instructions. There are some jumps, some math, some copy instructions, registers to hold data. Yes, a simple language. But your program here need to send things from the inbox, to the outbox, excluding vowels. Think a little about it. First, you don’t have any way to make a loop. Second, the input in this game is not only random, the game test your program not only with the visual input, it test it against several more. In fact, if any of those input failed, it will put it on the inbox so you can try it again. Third, there is only a zero on the floor. Your floor are your storage places, your variables, your registers.
This game let you debug, in a simple way, line by line. So you can check what is wrong. It a fun game for letting a new comer how a computer work.
This is very important. A lot of developers doesn’t understand and are not teached in how to read and understand what they program is doing. Newbie questions on Stack Overflow is a clear example of that. (I’m not against newbie question, this is about who are teaching them in a bad way).
If you want to see how to solve that thing up there, here is a solution, is not a good one, I get zero stars for it, but it solve the problem.
In future posts I will talk about strategies to teach algorithm (like cooking recipes). In the meantime, if you are a new developer, start reading your code, and understand line by line what is happening there. That’s a great start.