DEV Community

Cover image for Classification of computer languages (II)
Valentiina VP
Valentiina VP

Posted on • Edited on

Classification of computer languages (II)

Continuing with the previous post , the following classification of programming languages ​​is by paradigms. If you want to see the whole thread of this post, here I leave the table of contents:

Paradigms

A programming paradigm is a methodology or programming philosophy to follow with a central core unquestionable, that is, the languages ​​that use the same programming paradigm will use the same basic concepts to program.

Paradigms Groups
Imperative : Programmer indicates how to obtain the desired result.
Declarative: Programmer indicates what he wants to obtain the desired result.

Imperative paradigm

The code consists of a series of steps or instructions for performing a task organizing or changing values ​​in memory. The instructions are executed sequentially, until the previous one is not executed, the next one will not be executed. Examples: Java, C, C ++, PHP, Javascript, Visual Basic...

Within this group are different programming methodologies. Among them, the structured methodology and the object-oriented methodology.

Alt Text

Structured methodology

At the end of the 70s, this methodology was born which allowed 3 types of structures in the code:

  • Sequential.
  • Alternative (based on a decision).
  • Repetitive (loops).

The structured program theorem states that each computable function can be implemented by combining structures sequentials, alternatives or repetitives.

Using these structures, encodings like the one in the image on the left can be replaced with a structured code like the one in the figure on the right:

code-Structured

The structured methodology evolved by adding the module as a basic component giving rise to structured and modular programming.

evolutonimperative

The programs were made up of modules or processes on the one hand and data on the other. The modules needed input data to get output data which in turn could beused by other modules. Example: C.

Module: independent code that performs a specific task.

With this evolution of structured programming methodology, it was possible to divide the problem into several subproblems that they can be solved separately and by joining them they get a final result.

  • It is desirable that the modules have high cohesion and low coupling.
    • Cohesion: measures the strength of the relationship between instructions for a given module.
    • Coupling: is the level of independence there is between modules. Low coupling is normally a sign of a well-structured system and good software design.

Object Oriented Methodology

In the 80's it emerged the methodology oriented objects that considers the object as a basic element. It became popular in the early 90's. Examples: Java, C++, and Javascript supports this methodology, although it is natively based on prototype-oriented programming.

  • Object: Abstraction of real life objects, both physical and abstract. All these objects have a state and a behavior. Each object is an instance of a class.

    • Reals: car, house, bed, animal, person...
    • Abstracts: a notification, a search ...
  • Class: A class is a plane or mold from which individual objects are created.

Programs contain objects that relate to or collaborate with other objects of the same class or from other classes. The class is made up of attributes (data) and methods (processes).

The most fundamental concepts within this methodology are:

  • Encapsulation: Hide internal details of a class. Keywords within this concept are: Private, public, protected ...

encaps

  • Inheritance: subclasses can be declared that inherit the properties and methods of the parent class.

inehernec

  • Polymorphism refers to the property by which it is possible to send syntactically equal messages to objects of different types. The only requirement that must be met by objects that are used in a polymorphic way is to know how to respond to the message sent to them. Let's try to give an example of this: all animals make a sound, but this sound is different depending on the type of animal that emits it. Everyone will inherit the emitSound method from the parent class, but each subclass will do it differently. Let's see it graphically.

poli

The world of object-oriented programming is big, in another post, I will continue to cover this topic. For now, let's continue with our classifications.

Declarative paradigm

The form of coding in this paradgim contains a set of conditions, propositions, affirmations, constraints, equations, or transformations that describe the problem and detail its solution. The programmer has to think about the logic of the algorithm and not in the sequencies of steps to perform. There are also different groups within this paradigm.

  • Logic programming
  • Algebraic programming
  • Functional programming

Logic programming

This methodology emerged as a simple form of communication between humans and machines, unlike low-level languages, making use of mathematical logic, which is the simplest way for the human intellect to express and formally prove complex problems. The language by excellence within this methodology is Prolog.

logiv

Algebraic programming

Methodology used mostly in relational database query languages ​​such as SQL or Maude. This language makes use of a collection of relational schema operations that is used to manipulate relationships. The result of an operation, in turn, is also a relation, which allows you to chain calculations by applying an operator to the result of a previous calculation. These operators are the ones used by relational algebra:

This is an example of using relational algebra with the unary SELECTION primitive operator in SQL.

algebra

Functional programming

This type of languages, manage their entire structure through functions. There are no loops, or repetitive structures, and instead the concept of recursion is used. They makes use of mathematical functions. The difference from functions in the imperative paradigm is that imperative functions can make changes to previously performed calculations. Example: Heskel, Miranda. Javascript is not purely functional but supports such methodology, as well as Perl, Python, Ruby or Rust.

funcion

There are concepts within this methodology:

  • First-class and higher-order functions: they are functions that can take other functions as arguments or return them as results.

  • Pure functions: have not side effects (memory or I / O). They are widely used in code optimization

  • Strict(eager) vs. Non-Strict(Lazy) evaluation: concepts that refer to how function arguments are processed when an expression is being evaluated.

  • Type systems: The use of algebraic data types and pattern matching makes manipulation of complex data structures convenient and expressive, the presence of strict type checks at compile time makes programs more reliable, while type inference relieves the programmer of the need to manually declare the types for the compiler.

We have learned a lot today about paradigm classification of some languages. In the next post we will continue with the last classification ways. See you soon.

Top comments (1)

Collapse
 
cviniciussdias profile image
Vinicius Dias

Nice article. Congrats.

Just a small adition: PHP also has some nice functional programming stuff like First-class and higher-order functions

:-D