ⓘ Programming paradigm


ⓘ Programming paradigm

Programming paradigms are a way of grouping programming languages by what they do. Languages can be in more than one paradigm.

Some paradigms look at the way the code is run, such as allowing side effects, or having to do things in a certain order. Other paradigms look at the way that code is grouped, such as putting code into one or two pieces or instead, many small pieces. Some other paradigms look at the order and pieces that make the program the way it is.

There are two main groups of paradigms, imperative and declarative. A language can be both at the same time.

Some paradigms can be found in both imperative and declarative languages. These paradigms are usually found with one of the above paradigms instead of going on their own.

  • Meta: Special things in the language let the programmer change the way the language itself acts.
  • Parallel: More than one piece of code is run at the same time.

1. Overview

Programming languages are grouped by paradigms in the same way that machines might be grouped by what theyre used for.

A few languages fit in just one main paradigm, such as:

  • Assembly imperative, but not structured or object-oriented
  • Smalltalk object-oriented
  • Haskell functional
  • Prolog logic

Most languages, though, are in more than one paradigm. Some of the ones that stand out for having more than just one are:

  • Common Lisp
  • Python
  • Scala
  • Perl
  • Ruby
  • F#
  • Oz
  • Scheme
  • Visual Basic event-driven, object-oriented
  • Wolfram Language

Having more paradigms is not always good. One time that having fewer paradigms can be a good thing is when there is a language that is only functional. A function in one of these languages sometimes does less work like only going over the parts of a group of things it actually needs to than it might have to if the language was also procedural.

Many programming paradigms are as well known for the things they do not let people do as for those they do let people do. One time where this is true is functional languages. When a functional language is only or mostly functional, it usually will not allow side-effects. Another time where this is true is structured programming: it is different from normal imperative languages because it does not let programmers use "goto statements" statements telling the program to go to an earlier step. Because of this and other reasons, people sometimes think new paradigms do not allow enough things. It is sometimes okay for the computer to not let people do things, though: it can help people avoid problems with their code, and let the computer make guesses that so it can run code faster, or even check code for problems before the code runs!


2. Problems with paradigms

Some people who study programming languages do not like that paradigms are used to group programming languages, such as Harper and Krishnamurthi. Those people say that a lot of programming languages cant just be grouped into paradigms because languages borrow things and ideas from lots of paradigms.


3. History

New paradigms have been created over time, and people either pointed them out at the time, or when looking back. One of the first paradigms that was recognized as a new way of programming was structured programming from the 1960s. The idea of a "programming paradigm" is from 1978 if not earlier, when Robert W. Floyd used it while teaching. The word "paradigm" in the way Robert meant it was first used by Thomas Kuhn in his book, The Structure of Scientific Revolutions 1962.


3.1. History Machine code

The lowest-level closest to how the computer likes to understand things and oldest programming paradigm is machine code, an imperative paradigm. The directions in machine code are just a set of numbers in a certain order. Assembly language is a little bit less low-level and a little bit less old. In assembly language, the directions for the computer are given mnemonics easier-to-remember names, and memory addresses directions to find a piece of information in the computer can be given names. These are sometimes called first- and second-generation languages.

In the 1960s, assembly languages were made better by adding new things like library COPY, macros bits of "special" code that got transformed to normal code before the program started running, running procedures sets of directions given a name and saved for later, and variables items given names and saved for later from outside the program. This let people use some code in more than one project, and not have to worry about with hardware-specific problems that only happen one kind of computer thanks to commands names for directions like READ/WRITE/GET/PUT.

Assembly was, and sometimes still is, used in systems where it is important for the code to be fast, and it is also used a lot in embedded systems because lets the user have exact control of what the machine does.


3.2. History Procedural languages

In the very late 1960s, people started inventing procedural languages. These third-generation languages the first few of what we now call high-level languages had words related to what they were trying to solve. For example,

  • Programming Language One PL/I – was supposed to be useful to everyone.
  • FORmula TRANslation FORTRAN – uses mathematical words and symbols shapes used in writing and typing. It was developed mostly for science and engineering.
  • C – a programming language meant to do many things. Dennis Ritchie worked on it from 1969 to 1973 at AT&T Bell Labs.
  • COmmon Business Oriented Language COBOL – uses words like file, move and copy.
  • ALGOrithmic Language ALGOL – made for writing algorithms sets of steps telling the computer what to do. It uses mathematical words and symbols, just like FORTRAN.
  • Beginners All purpose Symbolic Instruction Code BASIC – made to help beginners program.

3.3. History Object-oriented programming

After many people had started using procedural languages, they invented object-oriented programming languages. In these languages, data and its "methods" ways of manipulating the data are put in one "object". Some programmers, such as Richard Stallman, do not agree that object-oriented languages are better for explaining ideas to a computer than procedural languages.

Because object-oriented programming is a paradigm, not a language, people have made object oriented assembly languages like HLA High Level Assembly.


3.4. History Declarative paradigms

At the same time, some people were making declarative programming languages. A language that is well known for being declarative is SQL a language for adding and removing things from tables.