Programming can seem like a daunting task to a person who has never programmed any time in their life or they have too little experience with it. While programmers can write a code in no time, non-programmers tend to think that they will never be able to program.
Most of my friends and colleagues want to venture into the field of data analytics and machine learning. But somehow fear of using either R or Python frightens them.
And these are the two very important languages that you have to learn if you want to have any sort of career in data analytics or its ilk. You should know at least one of these languages.
But somehow the fear of programming is at such a high level that you do attempt even once to learn. But is learning a programming language so hard for a non-programmer?
When we think of programming, we are always thinking of writing a code that is something only comprehensible to the nerds or geeks.
But is it that hard? Let me debunk the myth for you. Programming is not typing some hard to remember sentences instead what is core to the programming is the logic behind the program. Rest is literally typing and nothing else albeit in a language that is no much human-friendly as far as reading is concerned.
Allow me to give one simple example. It’s kind of tacky though 😀 You work, you earn money, some months you earn more, some months you earn less. Of course, this will only happen if you are running a business or working someplace where earning is incentive based.
You have a rule that you will go to one particularly expensive hotel only when your bank balance is more than Rs. 5000. If you have such rules where an action is taken only when a certain condition is satisfied then let me tell you that you are already using logic.
What if I want to write this logic in Python?
if bank_balance > 5000 then: go_to_expensive_hotel = True else: go_to_expensive_hotel = False
That’s how easy it is to convert your simple logic into the code. No doubt you have to learn how to write code in the language of your choice. But that’s not the hardest part. In fact, it is kind of mechanical once you get the hang of the language.
If you want to learn to program then focus on the logic part more than typing the code part.
Obviously, the logic that you will be using in real life programming is going to be more difficult than this. But again you are already used to logic. It may sound like some hyperbole but do you think the life decisions you have taken were anywhere light on the logic. I don’t think so.
So how to start learning to program?
The first step is to develop the logic. But what if logic is not your strong suit. Well, don’t worry. You can train your brain to think logically. Solve a few problems with pen and paper. Write down the logic that you will use and slowly you will get the hang of logic.
Let’s say that you want to sort a list of numbers. Now, your brain will probably sort it in no time without even knowing that you are using some kind of logic. But slow down. Write down what will be the first step, then the second, then the third and maybe by the tenth step you will have a sorted list.
This step by step thing to solve a problem is an algorithm. I am quite sure that you have heard this word and were thinking that it is something out of this world. It’s just a workflow. Start from point A and end at point B.
Always use a pen and paper and write down every step. After solving such examples I am sure your brain will not be a stranger to logic.
Algorithm and pseudocode:
As a non-programmer, make a practice to write pseudo code. Generally speaking, an algorithm is a graphical representation of various steps included in the solution. While algorithms are great, I will suggest you, write pseudocode instead of drawing algorithms. Because the algorithm contains few figures with specific meanings.
I am not going to go into the details of what each figure represents as it would again unnecessarily put off programming. But at the same time, they are important. So what is an alternative?
The alternative is to use pseudo code. As the name suggests, it is a code but not written in any particular programming language but your own language.
Check out the very simple example given below
# Carry out following steps till a grade is given to all the students # Ask the user to enter marks of a student # Store them in a variable called 'marks' # If marks greater than or equal to 80 # give grade 'A' # Else if marks greater than or equal to 60 but less than 80 # give grade 'B' # Else if marks greater than or equal to 40 but less than 60 # give grade 'C' # Else if marks greater less than 40 # give grade 'D'
Just read above pseudo code a few times. I am sure you must be thinking that this doesn’t sound too difficult. And yes, it is not that difficult.
What to do next?
Ok, so you gave one example of pseudo code. What should I do next? Well, I gave one example of sorting the list of numbers. Write pseudocode for this problem. Apart from that, I will give you another problem.
You have a list of numbers. What if I want to reverse that list.
A computer cannot just reverse the list the way your brain does. Let’s say that there are 10 numbers in the list. As you know computer uses memory, so for the sake of simplicity, we will assume that there are 10 compartments in a container. The container is the memory.
Each number is stored in one single compartment in the container. As some help, I will give you one more similar container. You can use this new container as well if you want to.
Start scratching your brain. At first, it will look like a daunting task. But think and I am sure you will be able to solve this problem.
Alright then, I hope this post helped you realize that programming is not that difficult after all.
Have any question? Let’s chat in the comment box.