About programming - Part 2

In the previous post, I talked a little bit about programming where I compare programming with building a house. Although not entirely same but the concept in typing a computer code and making a house is almost the same. You can't easily type anything to create a computer code. Same as building a house where you can't take wood or brick and nails or cement and build a home. You must learn about it. So, this article is my attempt to describe about computer programming in general.

So, what is a computer code? Computer code is an instruction you give to computer to do something. For example, print instruction will print something into the screen. Before the computer can understand what you want it to do, the code need to be written or translated into a binary format that the computer can understand. As most of computer science student know, the binary format is a represent by 0 and 1. For computer, 0001 and 0010 is different although for us, it almost look a same. It is easy right. Just type the instruction, translate it into a binary format and the computer can run it. But it is not that easy. Not many of us can translate computer code into a binary format. Maybe some of us can but most of us can't. So, you need a tool to do it for you. That's why we've got programming languages for developing a computer program.

Basically, there are two type of programming languages, compiler-type and interpreter-type. There are also a hybrid of both compiler and interpreter. Some of you must hear about 4th generation programming languages and etc. Trust me, it is not as important as it is. It is just a classification. Knowing which is compiler-type and interpreter-type is more important than which is 4th generation and 3rd generation and etc. To make it simple, C and C++ are compiler-type while Perl is more towards interpreter-type. What about Java? For me, I consider Java as a hybrid between compiler and interpreter-type. The difference between compiler and interpreter is simple. For compiler-type, you need to compile the executable for every type of operating system that you have because the executable can only be run on the specific platform. For example, executable for Windows XP 64-bit most probably can't run on Windows XP 32-bit OS. And of course anything compile on Linux can't run on Windows platform. While for interpreter-type, just bring your program to other platform and you can run it as long as you do not put a specific instruction for that platform. I always encounter assignment from student who use Windows command in their program. And when we run it on Linux platform those program can't run properly.

Before we write a computer program, we must know the basic of the programming language. For example, you can't just driving a car without at first knowing about how to start the car's engine, where is the brake pedal, how to turn on the light and etc. It is same as programming language. You must know the variables that you can use, the language syntax and so on. Some computer science students always make the mistake. They can't understand why we need to put ; (semicolon) after each instruction in C or C++ or why we need to declare variables or why we need to use "why" or "for" statement for loop and etc. They can't understand the basic but they attempt to make a program. When their program get an error, they can't troubleshoot it and some of them will cry and sometimes they scolded me because of their mistake. Yes, some of us can learn as they do the programming but most of them already grasp the basic before they do the programming.

The sad thing about this kind of attitude is, we lost lots of potential programmers each year. They have potential but when they encounter small error on the way, they broke up and don't want to do programming anymore. It is a lost actually. A very big lost for Malaysia and in computer field because time and money spent to train them is quite a lot actually.

This is the end of the article. If I'm not lazy, I will continue and introduce you with basic variables that are common in programming languages.

No comments: