What is Programming?
In very simple terms, Programming is an attempt to create the representation of reality on the computer. A computer program that you are writing is an attempt to solve a problem in the real world.
Lets go through some use cases to understand this better.
Take the example of Railway Reservation. If you are planning a vacation and you wish to travel comfortably by train to your destination, you need to reserve your seat in advance in the train of your choice. To solve this real-world problem, Railways have developed a computer program to implement a centralized reservation system. This system enables you to book your seat in any train you like from anywhere in India or across the world.
Recently app based taxis like Uber and Ola have come up which are solving the real world problem of hailing a taxi ride using a computer program. Other examples can be that of a chess game on a computer which takes the real world chess game into the virtual word of computer program. ATMs are also an excellent example, they solve the real world problem of withdrawing cash from your bank account.
So far we looked at what programming is and a few examples of how computer programs are solving real world problems. There are different ways to solve real world problems with computer programs. These different ways are referred to as Programming Paradigms. We will look at Procedural and Object Oriented programming paradigms.
All computer programs mainly comprise of two things - code and data. In the railway reservation example earlier, data is your name, age, date of journey, origin, destination, train number, etc. while code is all the logic that you will write to lookup the trains between origin and destination, check the availability, make the reservation etc. One way of programming is to break down the problem into a sequence of steps that are required to solve the problem. For each step write a function to perform that step passing the data that it requires. Then from your main function perform each of these steps by calling the corresponding function. This is the Procedural Programming Paradigm. Here focus is on "what is happening", the solution to the problem is centered around its code or the sequence of steps. In other words, we can say that in procedural programming code is acting on data.
Another way to write computer programs is to center it around its data by focusing on who is being affected. This is the Object Oriented Paradigm. Here we identify all the different entities present in our problem domain and how they are interacting with each other. Then we organize our program around these entities and provide well defined interfaces to interact with the entities. Hence we say that in Object Oriented programming data controls access to code. As we will see later on, this approach of organizing your program has some benefits over Procedural Programming. Object Oriented programming is so far the most popular programming paradigm.