Reading Time: 3 minutes
When I talk with some people about software development, I have the feeling that they look at it as some sort of dark magic. The kind of thing that somehow puts the world in motion, without anyone completely understanding how it works.
Like all magic, usually, only the magician knows the tricks behind what ordinary people see. In this case, the trick is nothing else than a few different rules that we write with a special syntax. And voilá!
But, the interesting thing here is: if we really think about it, we will understand that this software magic exists since the first philosopher. At the University, I learned a very important assumption of software development with a simple(but still really good) story.
That story was originally told, in 1965, by Dijkstra and is called the “Dining Philosophers Problem”. Here it is:
There is a table with five plates, five forks and a big bowl of spaghetti, where are sitting five philosophers. The forks are placed between each pair of them and each philosopher must alternately eat and think.
Assuming that the philosophers know how to think and eat, our job is to write a version of get and put forks that satisfy the following constraints:
- Only one philosopher can hold a fork at a time.
- It must be impossible for a deadlock to occur.
- It must be impossible for a philosopher to starve waiting for a fork.
- It must be possible for more than one philosopher to eat at the same time.
Take two minutes to think about this problem. Ok, you can take more time if you want. If, after this time, you have a practical solution to solve the problem, congratulations! You’re closer to making magic happen.
But, if you got to the answer too fast, I advise you to think a bit more. Sometimes there are obvious solutions that aren’t good enough. Here’s an example:
- Think until the left fork is available; when it is, pick it up;
- Think until the right fork is available; when it is, pick it up
- When both forks are held, eat for a fixed amount of time
- Then, put the right fork down;
- Then, put the left fork down;
- Repeat from the beginning.
This situation would work, but philosophers could wait eternally for each other to release a fork. That happens if each philosopher picks up a fork on the left and waits for the right to become available.
That being said, there is usually more than one solution to the same problem. You can try to find many for this specific one… Or you can just google for “Resource hierarchy solution”, “Arbitrator solution” or “Chandy/Misra solution”.
Everyone can be a developer
The problem we just saw is a good example of a what it is to be a developer. On a regular basis, you’re presented with a problem that you have to understand as a regular person and that you have to solve given the situation and rules of the game. All you have to do after that is translating your solution into syntax using a code language.
In my opinion, any person in any context can be a developer. All they need is a problem that requires a solution. If Tales, Pythagoras or Socrates had a computer, would they be software developers? The answer is: I truly don’t know, but I believe that any thinking person can find solutions. And if they can, then they can be developers. We all can.