Functional Programming – Is Clojure a 3GL or a 4GL?

clojuredeclarative-programmingfunctional programmingsql

A bit of background (in case I'm mistaken)…

I think I understand that (it's an oversimplification):

  • manually entering codes into memory (or on a punchcard) is "first generation language"
  • using mnemonics corresponding to CPU instructions would be a 2GL (like assembly language)
  • C/C#/Java/Objective-C are all 3GLs
  • SQL is a 4GL

Where would Clojure stand in such a classification?

I'm particularly confused by this Wikipedia sentence:

The archetypical example of a declarative language is the fourth
generation language SQL, as well as the family of functional languages
and logic programming.

This sentence seems to imply that all functional languages are declarative. Is that correct?

Then Clojure can be used in a functional way (and it is probably recommended to use it "as much as possible" in a FP style), so is Clojure a declarative language ?

Also, I can see that Clojure make it really easy to create 4GLs (e.g. as embedded DSLs, like core.logic reproducing logic programming in about 200 lines of code) but is Clojure itself a 4GL?

Best Answer

Clojure is a 3GL

First, some definitions for the avoidance of doubt.

A first generation language (1GL) is a machine level programming language. No automated translation is in place so programming is through a bank of switches on the front panel.

A second generation language (2GL) is a categorization of assembly languages. This normally targets specific chipsets and allows for source code to be used.

A third generation language (3GL) is a refinement of a 2GL and are termed "High level languages". This introduces logical structure to source code and makes the language more programmer-friendly. Examples include C/C++/C#/Java etc. They usually have an interpreter or compiler.

A fourth generation language (4GL) was in favour between 1970-1990 and is commonly understood to be a programming environment. This tends to be read as a collection of applications that support the creation of 3GL source code. Often this is a visual workbench environment such as an IDE, or perhaps a table-driven system configuration environment (Oracle middleware for example). There is also the possiblility that a 4GL could be considered a domain specific language (DSL).

In light of the above definition, Clojure would appear to fit much more closely within the frame of a 3GL since it is only the rather loose domain specific language interpretation that would lift it to a 4GL.