Thursday, September 14, 2023

Introduction to Computer Programming

 

Do you know the most interesting thing about computers?

Oh no, not gaming. Not listening to music. Anything else? Browsing the Internet? You can say that. But even more fun is programming the computer.

If you know programming, you can not only play games, but also make your own games. You can make your own music player. You can even create an e-commerce platform like bikroy.com. You have an account on Facebook, right? If you know programming, you can make an application for Facebook. Then you can use the application together with your friends! Ever wanted to create apps for Android phones? Become proficient in programming without delay!

These are just some examples. Almost anything can be done with a computer. What else can be done is limited only by our programming capabilities. There are other things, of course. For example, devices need to be connected to the computer to perform many tasks. Again, it takes so much time to do some work with programming (we say "Computational Complexity" of the problem is high) that one has to find an alternative way without finding the right solution.

The main attraction of programming: “Instant Feedback”. This means you write a program and run it immediately to see your program working. It takes time to make an electronic circuit and see it work. But programming is instant - you write a program sitting at the computer and immediately run it and see the results of your work!

So, when everything can be done with this programming, how to do programming?

Excellent question!

If you want to get a job done with someone, how to do it? Give him work instructions and he works as instructed, right? The same is the case with programming. You want the computer to do a job. So, while programming, give instructions to the computer and the computer will do the work as per your instructions.

A program is a sequence or collections of instructions to perform a specific task.

There's a problem here – computers don't understand your and my language. If computers understood that would have been fun! We used to say everything we want to be done quickly in Bengali or English and the computer would do everything quickly!

Then?

Although computers do not understand our language, they understand languages that 'follows certain rules'. Those languages are not exactly like Bengali or English, but close. In order to program the computer, all those specific instructions have to be instructed in a language that follows certain "rules" (computer scientists call these constrained languages Context Free Language).

Let's get back to a real example.

How do we use a normal calculator? We give some data (here numbers) as input and specify which operators (like addition, multiplication, etc.) will be applied on the data. The calculator applies operators on the data and displays the results as output.

Now if we could make the operators ourselves, wouldn't it be a lot more fun? We would create an operator to find the average of a set of numbers given as input. Another operator to display a specified number of prime numbers as output. How many more ideas would come out!

From programming perspective, programmers create operators with instructions. On the other hand, the user provides as input the data and the operator to be applied on the data. And see the result as output.

.... .... ....

No comments:

Post a Comment