I heard a guy say, there are four programming paradigms. First of all, I did not know that, second of all, he did not explain them, or not in a way that made me go lightbulb. So… well, any programmers here?? I have a buddy who makes about 5K a day when he is getting work, well he’s not actually by buddy as he hates me because I once nearly killed his cat. He won’t teach me anything, I think he dislikes me even besides the pain of his cat, but he says that paradigms are bullshit.
I will google.
barbarianhorde:
I will google.
Here’s a cookie.
Holds out cookie
Does it have a hole in it? If so I am terrified.
Anyway I googled as I said .
Programming paradigms that are often distinguished include imperative, declarative, functional, object-oriented, procedural, logic and symbolic programming .[1][2][3] With different paradigms, programs can be seen and built in different ways; for example, in object-oriented programming, a program is a collection of objects interacting in explicitly defined ways, while in declarative programming the computer is told only what the problem is, not how to actually solve it.
IMPERATIVE
In computer science terminologies, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state. In much the same way that the imperative mood in natural languages expresses commands to take action, imperative programs define sequences of commands for the computer to perform. Imperative programming (necessary programming) is focused on describing how a program operates.
The term is often used in contrast to declarative programming, which focuses on what the program should accomplish without prescribing how to do it in terms of sequences of actions to be taken.
DECLARATIVE
In computer science, declarative programming is a programming paradigm, a style of building the structure and elements of computer programs, that expresses the logic of a computation without describing its control flow.[1] Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish in terms of the problem domain, rather than describing how to go about accomplishing it as a sequence of the programming language primitives[2] (the how being left up to the language’s implementation). This is in contrast with imperative programming, in which algorithms are implemented in terms of explicit steps.
Declarative programming often considers programs as theories of a formal logic, and computations as deductions in that logic space. Declarative programming may greatly simplify writing parallel programs.[3]
Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming, functional programming, and configuration management systems.
FUNCTIONAL
In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions. In functional code, the output value of a function depends only on the arguments that are input to the function, so calling a function f twice with the same value for an argument x will produce the same result f(x) each time. Eliminating side effects, i.e. changes in state that do not depend on the function inputs, can make it much easier to understand and predict the behavior of a program, which is one of the key motivations for the development of functional programming.
Functional programming has its roots in lambda calculus, a formal system developed in the 1930s to investigate computability, the Entscheidungsproblem, function definition, function application, and recursion. Many functional programming languages can be viewed as elaborations on the lambda calculus. Another well-known declarative programming paradigm, logic programming, is based on relations.[1]
In contrast, imperative programming changes state with commands in the source language, the most simple example being assignment. Imperative programming does have functions, not in the mathematical sense, but in the sense of subroutines. They can have side effects that may change the value of program state. Functions without return values therefore make sense. Because of this, they lack referential transparency, i.e. the same language expression can result in different values at different times depending on the state of the executing program.[1]
Functional programming languages, especially purely functional ones such as Hope and Rex, have largely been emphasized in academia rather than in commercial software development. However, prominent functional programming languages such as Common Lisp, Scheme,[2][3][4][5] Clojure, Racket,[6] Erlang,[7][8][9] OCaml,[10][11] Haskell,[12][13] and F#[14][15] have been used in industrial and commercial applications by a wide variety of organizations. Functional programming is also supported in some domain-specific programming languages like R (statistics),[16][17] Wolfram Language (also known as M or Mathematica, for symbolic and numeric math),[18] J, K and Q from Kx Systems (financial analysis), XQuery/XSLT (XML),[19][20] and Opal.[21] Widespread domain-specific declarative languages like SQL and Lex/Yacc use some elements of functional programming, especially in eschewing mutable values.[22]
Programming in a functional style can also be accomplished in languages that aren’t specifically designed for functional programming. For example, the imperative Perl programming language has been the subject of a book describing how to apply functional programming concepts.[23] This is also true of the PHP programming language.[24] C# 3.0 and Java 8 added constructs to facilitate the functional style. An interesting case is that of Scala[25] – it is frequently written in a functional style, but the presence of side effects and mutable state place it in a grey area between imperative and functional languages.
OBJECT-ORIENTED
Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A distinguishing feature of objects is that an object’s procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of “this”). In OO programming, computer programs are designed by making them out of objects that interact with one another.[1][2] There is significant diversity in object-oriented programming, but most popular languages are class-based, meaning that objects are instances of classes, which typically also determines their type.
Many of the most widely used programming languages are multi-paradigm programming languages that support object-oriented programming to a greater or lesser degree, typically in combination with imperative, procedural programming. Significant object-oriented languages include Python, C++, Objective-C, Smalltalk, Delphi, Java, Swift, C#, Perl, Ruby and PHP.
PROCEDURAL
Procedural programming is a programming paradigm, derived from structured programming, based upon the concept of the procedure call. Procedures, also known as routines, subroutines, methods, or functions (not to be confused with mathematical functions, but similar to those used in functional programming), simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program’s execution, including by other procedures or itself. Procedural programming is a list or set of instructions telling a computer what to do step by step and how to perform from the first code to the second code. Procedural programming languages include C, Go, Fortran, Pascal, and BASIC.[1]
LOGIC
Logic programming is a programming paradigm based on formal logic. A program written in a logic programming language is a set of sentences in logical form, expressing facts and rules about some problem domain. Major logic programming language families include Prolog, Answer set programming (ASP) and Datalog. In all of these languages, rules are written in the form of clauses:
H :- B1, …, Bn.
and are read declaratively as logical implications:
H if B1 and … and Bn.
H is called the head of the rule and B1, …, Bn is called the body. Facts are rules that have no body, and are written in the simplified form:
H.
In the simplest case in which H, B1, …, Bn are all atomic formulae, these clauses are called definite clauses or Horn clauses. However, there exist many extensions of this simple case, the most important one being the case in which conditions in the body of a clause can also be negations of atomic formulae. Logic programming languages that include this extension have the knowledge representation capabilities of a non-monotonic logic.
In ASP and Datalog, logic programs have only a declarative reading, and their execution is performed by means of a proof procedure or model generator whose behaviour is not meant to be under the control of the programmer. However, in the Prolog family of languages, logic programs also have a procedural interpretation as goal-reduction procedures:
to solve H, solve B1, and … and solve Bn.
Consider, for example, the following clause:
fallible(X) :- human(X).
based on an example used by Terry Winograd [1] to illustrate the programming language Planner. As a clause in a logic program, it can be used both as a procedure to test whether X is fallible by testing whether X is human, and as a procedure to find an X that is fallible by finding an X that is human. Even facts have a procedural interpretation. For example, the clause:
human(socrates).
can be used both as a procedure to show that socrates is human, and as a procedure to find an X that is human by “assigning” socrates to X.
The declarative reading of logic programs can be used by a programmer to verify their correctness. Moreover, logic-based program transformation techniques can also be used to transform logic programs into logically equivalent programs that are more efficient. In the Prolog family of logic programming languages, the programmer can also use the known problem-solving behaviour of the execution mechanism to improve the efficiency of programs.
SYMBOLIC
In computer programming, symbolic programming is a programming paradigm in which the program can manipulate its own formulas and program components as if they were plain data.[1]
Through symbolic programming, complex processes can be developed that build other more intricate processes by combining smaller units of logic or functionality. Thus, such programs can effectively modify themselves and appear to “learn”, what makes them better suited for applications such as artificial intelligence, expert systems, natural language processing, and computer games.
Languages that support symbolic programming include LISP and Prolog.[2]
Seems my “friend” lied to me.
Where’s that cute kittie?
In computer programming, symbolic programming is a programming paradigm in which the program can manipulate its own formulas and program components as if they were plain data.[1]
Through symbolic programming, complex processes can be developed that build other more intricate processes by combining smaller units of logic or functionality. Thus, such programs can effectively modify themselves and appear to “learn”, what makes them better suited for applications such as artificial intelligence, expert systems, natural language processing, and computer games.
Languages that support symbolic programming include LISP and Prolog.[2]
This sounds pretty interesting.
Nanny 1, bring it on…
I’m sure Lars does’t actually do this. I need to get into something where I can piss on his shit.
The three most popular paradigms today are Object Oriented, Functional and Procedural.
Procedural is old-school, gives you more power but, as spiderman would say, more responsibility (easier to fuck things up).
Object-Oriented is what’s most common today, its claim to fame is that it encourages clean ways of organization and modularity.
Functional is gaining a lot of steam, but the concepts required are often more nuanced and mathematical. It’s more theoretical and cutting-edge in a lot of cases, and part of what makes it difficult is that a lot of the techniques you’d use in Procedural or OO simply won’t work in a Functional way – you need to rethink how you approach the problem entirely.
A lot of languages are some combination of these. For example, the language that as far as I can tell is the most liked by programmers (not necessarily the most used, just the most praised) is Scala, which is a combination of Functional and Object Oriented (funnily enough, I just looked up Scala and that’s the headline on its front page ).
A lot of the object oriented languages are picking up more and more functional patterns though. For example, I know how to use about 4 languages (some more than others) : Python, Java, C# and JavaScript.
Python and Javascript are both dynamically typed object oriented languages, and they actually enable quite a lot of functional stuff because of the way they treat functions (they both treat functions as objects, I think).
C# and Java on the other hand still remain mostly traditional OO, probably in part because they’re statically typed and it might be harder to add functional features to languages like those. But even those languages have had functional features added in recent history, eg lambdas. C# even has first-class functions now apparently, and fully-supported closures. Java’s lagging.