Pretty much the entire digital world that is so central to our lives today is built on computer programs. These are essentially a set of instructions we give our devices to perform certain functions and solve problems. While machines work with binary code - just 0s and 1s - we humans have developed hundreds of programming languages that enable us to communicate with our computers.
It’s not clear exactly how many programming languages exist today, but more are being created all the time. So it’s useful to organize these languages into categories that help us understand the similarities and differences between them. While there is no one definitive way to classify types of programming languages, one common approach is to divide them into core paradigms. These determine how your code is structured and organized.
The first distinction is between imperative and declarative programming languages.
We can also understand the difference between imperative and declarative with real-world examples. There are many out there, but here’s a simple one that we like:
Suppose a friend is coming to visit but doesn’t know where you live...
The imperative approach would be to give detailed directions for a particular route to your house.
The declarative approach would be to give your friend your address and let them decide which route they take to get there.
Now that we understand the key difference between imperative and declarative programming, we can look at some of the main programming paradigms in each category.
This language deals with procedure calls, which are also known as routines or functions. These contain a series of computational commands to be carried out to achieve a certain outcome. It is essentially like a recipe, with a list of step-by-step instructions for the computer program to follow. The code can easily be reused in different parts of the program. One benefit of this is that the code can be easy to learn and read in simple programs. However, when dealing with something more complex you run the risk of ending up with a huge volume of code.
Examples: C, Pascal, BASIC.
This paradigm is based on the idea that code can be broken down into ‘objects’ that have different properties and perform different actions. Objects can interact with each other to achieve desired outcomes. A core principle of OOP is ‘encapsulation’, which involves wrapping all the object components (i.e. data and methods) into a single, self-sustaining unit (sometimes known as a ‘class’). OOP is a popular programming paradigm as it mimics our ‘real world’ view of objects, making it relatively simple to grasp. Due to encapsulation, objects/classes can be reused easily, while it is also scalable and secure.
Examples: C++, Java, Python.
The basic idea behind this paradigm is to break up different parts of a task among multiple processors, which simultaneously work on a problem. It’s like having someone make a sauce while you prepare the pizza base - you reduce the time it takes to complete the whole task. With a computer, this implies connecting multiple processors to memory, which is either pooled across all processors or distributed over a network. The side effects of this include a requirement to use both software and hardware resources. A number of programming languages can support parallel processing.
Examples: C, C++, MPI.
This programming is based on the notion of formal logic. Programs are written as a series of facts and rules that follow a logical structure (e.g. ‘X is true if Y and Z are true’). This logic serves as a knowledge framework through which computers can produce certain results - rather than being told explicitly what to do, a computer is given the boundaries for what it should be considering. Logic programming is primarily declarative as machines can use reason to solve a problem, though in some cases imperative commands can also be included in the code. Logic programming can be used for research and testing complex theorems - it is also closely connected to development of machine learning and artificial intelligence. Key benefits include flexibility and minimalist syntax. However, it can be confusing if the logical rules are not expressed well.
Examples: Prolog, Datalog, Mercury.
As the name suggests, this paradigm is based on the execution of a series of mathematical functions, which form the building blocks of the program and perform all manner of tasks. These functional languages avoid flow controls like loops and instead favor recursive functions. This paradigm reduces code complexity and can be used to solve complex problems. However, it can be difficult to learn and tricky to scale for larger projects. As with the logic paradigm, some functional programming languages can also support imperative style programming if required.
Examples: JavaScript, Haskell, Scala.
As with many things in software development, there is no objectively ‘right’ or ‘best’ programming paradigm. It all depends on what you need to do, what resources you have available, what operating system you’re using, and who else is working on the project. Often, you’ll find that blending some declarative and imperative programming is the optimal solution.
Most important is finding a skilled and experienced programmer that knows when to use the different paradigms to maximise the benefits of each. And that is something that we at Jobsity can help you out with - just get in touch to find out how!
--
If you want to stay up to date with all the new content we publish on our blog, share your email and hit the subscribe button.
Also, feel free to browse through the other sections of the blog where you can find many other amazing articles on: Programming, IT, Outsourcing, and even Management.
Interested in hiring talented Latin American developers to add capacity to your team? Contact Jobsity: the nearshore staff augmentation choice for U.S. companies.
With over +16 years of experience in the technology and software industry and +12 of those years at Jobsity, Santi has performed a variety of roles including UX/UI web designer, senior front-end developer, technical project manager, and account manager. Wearing all of these hats has provided him with a wide range of expertise and the ability to manage teams, create solutions, and understand industry needs. At present, he runs the Operations Department at Jobsity, creating a high-level strategy for the company's success and leading a team of more than 400 professionals in their work on major projects.