r/functionalprogramming • • Apr 29 '25
Question Is Lisp Functional?
Do you guys consider lisp languages (CL in particular) to be functional? Of course they can be used functionally, but they also have some OOP qualities. Do you CALL them functional or multi-paradigm?
39
Upvotes
54
u/justinhj Apr 29 '25
I would say it’s a multi-paradigm, general purpose language now. In its early days, with its origin in lambda calculus it looked functional but by the time it was standardized by ANSI in the 80s it had acquired many features that are not aligned with fp.
Definitions vary however. Some people would say any language with support for first class functions, closures and higher order functions is functional.
8
u/ScottBurson Apr 29 '25
I generally refer to Lisp as "semi-functional". For programming in the small, it is often possible to write individual algorithms in a functional style (especially if you use FSet). But at a larger scale, programs tend to be stateful.
I like having easy access to both paradigms.
6
u/stylewarning Apr 30 '25
Coalton, which is in Common Lisp, is a functional language a la ML or Haskell with currying, static types with type inference, and function-oriented optimizations.
15
u/daddypig9997 Apr 29 '25
We have to answer the question what is a functional language first.
6
u/stevevdvkpe Apr 29 '25
Traditionally Lisp has always had mutation operations (set/setq, rplaca, rplacd) so it's not purely functional. There's a subset of Lisp that is functional if you avoid all the mutation operations.
11
u/drinkcoffeeandcode Apr 29 '25
Some lisp dialects were written with functional programming in mind - Clojure, Scheme (less so than clojure, but still)
Common Lisp is not a strictly functional programming language, or even one that particularly caters to the paradigm, it supports it sure, but not implicitly.
5
u/[deleted] Apr 30 '25
Of course it is. You can pass functions around and that is a key and extensively used feature of the language. You have proper closures etc. higher order functions.
Do you map, filter and fold a lot? It’s functional.
4
u/MonadTran Apr 29 '25
CL is definitely a multi-paradigm language.
Lisp languages in general can be made as functional as you like, the problem is though, real world programming involves side effects, and Lisp languages are not really suitable for isolating these effects from the functional part of the code. They don't have the powerful type system of Haskell and similar languages.
3
u/WittyStick May 01 '25
"Functional programming" used to just mean functions were first-class, so of course this includes Lisp. Lisp has been called a functional language for decades.
But the modern use of "functional programming" has come to mean pure functions, or at least, a preference for them.
0
u/innocentboy0000 Apr 29 '25
no!
2
u/Gnaxe Apr 29 '25
Common Lisp is multi-paradigm. It does have higher-order functions and lambdas. Linked lists can also be directly used as a persistent data structure.
On the other hand, Clojure is more functional, with pervasive immutability as the norm, but it is a hosted language.
2
u/josephjnk Apr 29 '25
If I recall correctly Common Lisp doesn’t support proper tail calls, right? I can’t imagine a modern functional language which didn’t have a way to perform stack-safe recursion.
1
u/daver May 25 '25 edited May 25 '25
I’d call Lisp “functional-ish.” To what degree it’s more or less functional depends on which dialect. Early Lisps ran on machines with tight constraints (remember, Lisp is one of the oldest programming languages in existence), and they frequently compromised for efficiency’s sake. Later Lisps are more functional. So, for instance, Common Lisp is less functional than Clojure. But neither is nearly as functional as Haskell, while both are more functional than C, Java, or Python.
1
u/jonathancast Apr 29 '25
No.
https://stackoverflow.com/questions/11013514/set-car-and-let-in-scheme-language
Full answer: Lisp and functional programming languages are separate families (Lisp is substantially older), but I would restrict the term "functional programming language" to ML and its relatives and descendants.
I would say a functional programming language needs to have or be descended from a language with: first-class functions, binary function application by juxtaposition, let, immutable variables and data, and, probably, algebraic data types. The last one is really a family characteristic rather than a requirement.
The Lisp family doesn't descend from the functional family, because it's older (unless you consider Church's lambda calculus a programming language, which I don't, because it was never implemented as one). Lisps, generally, have (sometimes 'kind of') first-class functions, function application by S-expressions, let, mutable variables and data types, and S-expressions instead of algebraic data types.
So Lisp isn't descended from functional languages and it has pretty major differences in style and implementation.
So no.
1
u/deaddyfreddy Apr 29 '25
yes, some of them
no
-3
u/no-vid Apr 29 '25
Lisp languages are a branch of logic programming in the declarative paradigm, I think
2
u/[deleted] Apr 29 '25
[removed] — view removed comment