5 ms·
>Clojure (like all Lisps) is an imperative programming language. "Imperative" languages are contrasted with "declarative" languages. Wikipedia, and probably ev
by LesZedCB 12y ago
>Clojure (like all Lisps) is an imperative programming language. "Imperative" languages are contrasted with "declarative" languages.
Wikipedia, and probably everybody, defines truly functional programming languages (which includes Clojure and the other Lisps) to be declarative, not imperative. [1]
[1] http://en.wikipedia.org/wiki/Declarative_programming http://en.wikipedia.org/wiki/Declarative_programming
- mrottenkolber 12y ago> truly functional programming languages (which includes Clojure and the other Lisps) This is wrong. I don't know how to say this... Lisps do usually support functional programming paradigms, but most Lisps are indeed anything but functional (in the ML sense).
- dragonwriter 12y agoLisp was considered a functional programming language before ML existed. Lisps generally don't have as strong and exclusive support for the functional paradigm as some newer languages (and pretty much anything else still in use is newer than lisp), but then C++ is known as an OOPL despite having less strong and exclusive support for the OO paradigm than many older languages, so there's that.
- AnimalMuppet 12y agoLisp is a multi-paradigm language. It can be functional, but it doesn't have to be. It can be OO, but it doesn't have to be. Classifying it as "being" any of these is asking for argument, unless you have very clearly defined (and agreed-upon) definitions of what it means to be a member of one of those categories. In particular, does membership mean that you require programming in that style, or only that you allow it?
- bitwize 12y agoLisp was considered a functional programming language before ML existed. That was then and this is now. Today, functional programming means side-effect-free with a strong type system, and efficient use of higher-order abstractions over functions, including things like typeclasses to define entire morphisms given a few functions which establish relationships between objects. Lisp doesn't really support this effectively. Arguably, with concepts C++14 is more functional than Lisp.
- sramsay 12y agoI'm not sure I see what having "a strong type system" has to do with whether or not a language can be considered functional. It seems like it's just a way to say that Haskell and the MLs are the only languages that qualify. And that sounds more like PR than a formal definition. It's also not really historically accurate. People were referring to languages based on the untyped lambda calculus as "functional" before things like Hindley-Milner appeared (in the 70s). Were they (and I'm talking about PL researchers) all speaking incorrectly?
- dragonwriter 12y ago> Today, functional programming means side-effect-free with a strong type system Functional programming has always meant the style or paradigm of programming that prefers side-effect-free declarative code that can be modelled in the substitution model; type systems have always been (and remain) orthogonal concerns. A functional language is one that supports the functional paradigm, but it has never been most commonly used for languages that exclusively support that paradigm. Pure functional code is the term that has been used for code that is exclusively in that style, and pure functional language is the term that is generally used for a language that has exclusive support for that style.
- mtrimpe 12y agoThat's a very precise definition of the class of functional languages. Unfortunately in the real world the definition tends to be much more varied. ;)
- mjn 12y agoI don't think everyone uses that definition of declarative, though it is one of them. A very common different definition is that declarative programs specify "what", not "how", i.e. desired outcomes are explicit, while algorithms for computing them are implicit. From that perspective, Prolog, SQL, constraint solvers, answer-set programming, etc. are declarative paradigms (albeit sometimes with non-declarative escape hatches, like Prolog's "cut"). But languages in which you write algorithms, whether C or SML, are something other than declarative, and instead are oriented towards explicitly specifying computations rather than the desired results of computations.
- dragonwriter 12y agoIts worth noting that declarative and imperative styles (and this is true of things like the functional and OO paradigms, as well), when applied as descriptors of languages, aren't binary categories. Lisp is a fairly early functional language (that is, one, compared to contemporary alternatives, focussed on the functional paradigm), and the functional paradigm is a declarative paradigm centered around the substitution model of computation. OTOH, that doesn't mean it is impossible to have imperative code in Lisp.