You don’t just have different programming languages.
You also have different programming paradigms.
The most popular and well known ones today are
- procedural programming
- object oriented programming
- functional programming
In procedural programming, code is executed in a linear way from the beginning to the end. You tell the computer what to do, from start to finish, and it does.
The name comes from “procedure”. Which literally means doing something, using specific instructions, executed in order.
I think this is the more familiar kind of programming, thinking about it from a beginner’s perspective. We all imagine code being something like a list of things you tell the computer to do. C is a good example of a procedural programming language.
Object oriented programming is a different beast. We try to model the domain of the problem at hand using objects. Objects have a type, which is called class. Object oriented programming, or OOP, was made popular by Smalltalk and later by Java. Programs written using an OOP methodology are more abstract than a list of things the computer must do. We think in terms of objects, and the interactions between them. For example you have a Car object, and a Person object. The Person drives a Car, and so on. Objects can maintain their own state, and encapsulate it. This is really mimicking the real world. A person does not need to know how a car works under the hoods. They simply drive it. The car abstracts away all its complexity and offers a specific way to drive it (brakes, wheel, etc).
Those are just 3 of the most popular methodologies. Which is best among these? It always depends on the problem at hand. And the favorite approach can also be influenced by the status quo, or what the market prefers. For example object oriented programming was more or less the de facto standard. Today I see it widely used, but I also see a lot more people talk about functional programming.
Now there’s another distinction we must make, and it’s between imperative and declarative programming. Imperative means we tell the computer what to do. The exact actions. C is a very imperative programming language. We move X bytes into memory, we retrieve variable Y, and so on. Declarative programming means we describe what we want, and we don’t care how the computer does it.
If you are familiar with HTML, HTML is a declarative language. JSX, if you know about it, is a declarative way to define user interfaces.
Which one is best? It depends. Generally speaking, imperative programming is best suited for lower level languages, like C or Go, which we use to create very performant applications. The more far away we are from the actual details of the machine, the less performant our code is. But also, the easier it is to write it. It’s a compromise. As always.