Learn to think like a computer, to code like a guru [Part 1]

15 May

So, you are thinking about becoming a programmer, if so then this post is for you. Many people that I know who have started to learn programming just walked away after a few days from starting to learn. By talking to them they said that programming was very hard to understand and it was very hard for them to build a working application. The problem was that almost all of them have started to learn programming using a high level programming language like C# or Java. They just got overwhelmed from day one with lots of details and jargons that they couldn’t handle.

As I have also noticed that those who were able to survive and continue learning are not able to solve relatively simple programming assignments. From my point of view that was expected. The question is why did that happened to them, and how it can be avoid. For the first question the answer is that they don’t understand the mechanism of how computers think and work, they don’t understand the logic that computers use to think. For the second question the answer is that they first need to learn (in plain English) the computers thinking logic, before they can start to learn any programming language at all.

In this post and the several coming posts (GOD only knows how many of them there will be) I will teach you how computers think. In order to learn the computer thinking logic I have asked a friend of mine to lend me his Robot, as robots think the same way computers think. So please welcome “Jazari” the robot.

Please welcome Jazari

Please welcome Jazari

Now as we have a robot, we need to make use of him, it doesn’t now make any sense to own a robot and not ask him to do our tasks; at the beginning I’m suggesting to ask him to get me some deserts from the fridge. Okay, let me ask him to do.  “Jazari, would you please get me some Baklava from the fridge”, as you can see below “Jazari” is not moving at all. Let me check its manuals.

Ahaaa the manual says that our orders to “Jazari” need to follow three simple rules otherwise it will not work at all, those rule are listed below.

  1. Sequence
  2. branching
  3. Repetition

So what does that mean? For now I will explain what sequence is. A Sequence is an ordered finite list of commands that the robot or a computer will execute one by one from top to bottom. Now let’s see how to ask “Jazari” the same question but in a way he can understand.

  1. Move 10 meters forward
  2. Grasp the fridge door handle with right hand
  3. Pull the fridge door handle
  4. Un grasp the fridge door handle
  5.  Grasp the baklava plate with right hand
  6. Grasp the fridge door handle with left hand
  7. Push the fridge door
  8. Un grasp the fridge door handle
  9. Move 10 meters backwards

Although that might sound very stupid for a human, but for computers and robots it always had to be like that, a sequence of a very primitive commands that explain every single step to complete needed to a task. Let’s assume that I have forgot the command number 8, in this case the robot would have moved backwards while still grasping the fridge door handle, dragging the fridge to my living room.

So for today we have learned that computers and robots are not as smart as we think, we have also learned the correct way to give orders to a computer or a robot. Now as I feel thirsty after eating the baklava, would you please ask “Jazari” to get me a cup of tap water, just write the sequence and send it to me. While writing it don’t focus on the words as much as you focus on simplifying the commands for “Jazari” to be able execute them one by one, and remember that it is a must that each line should contain a single command for “jazari”.

Advertisements

4 Responses to “Learn to think like a computer, to code like a guru [Part 1]”

  1. ali May 15, 2012 at 7:16 pm #

    waiting next part 🙂

    • abmera May 15, 2012 at 8:56 pm #

      I will post it tomorrow ISA

  2. khaloufi May 17, 2012 at 6:54 pm #

    thank you for this nice article , keep up the good work 😉

    • abmera May 17, 2012 at 7:01 pm #

      Thanks a lot Yassin, I’m really glad you have liked it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: