r/functionalprogramming • u/kichiDsimp • Jul 08 '25
Question why not Lisp/Haskell used for MachineLearning/AI
i have a course on topic of AI: Search Methods and it the instructor told about Lisp, found out it was a func-lang, also told about functions like car & cdr why in the real world of AI/ML func-langs aren't adopted more when they naturally transfom to operations like, map->filter->reduce->functions
am I missing something ?
56
Upvotes
40
u/no_brains101 Jul 08 '25
Because data scientists get taught python because it has good graphing libraries, tensorflow, and jupyter
No, you arent really missing anything, and the core stuff is written in C either way.
17
u/[deleted] Jul 08 '25
LISP was literally designed to work with AI
14
u/pane_ca_meusa Jul 08 '25
Machine Learning requires a lot of prototyping. Python and Jupyter are the best tools for quick prototyping out there.
Haskell is very good in situations where mistakes are very expensive: finance, defense, health.
LISP is very efficient, but requires much more skills than Python.
5
u/grimonce Jul 08 '25
In the current state of 'AI' it literally doesn't matter what language you feed the model with... It's just tensors, every language has an array and list implementation.
What exactly would make lisp any better here than python or C or Java?
4
u/[deleted] Jul 08 '25
As others have commented AI these days means Artificial Neural Networks (ANN) and Large Language Models (LLM). I can't speak for Lisp but there are several reasons for not using Haskell for development here:
Don't get me wrong, I'm a passionate Haskell user and would love to see the language used for these models, but we need work on the ecosystem and on the language before it can compete with existing approaches.
3
u/jimtoberfest Jul 08 '25
I try to force functional paradigms all the time for LLM pipeline state management - it’s a disaster, IMO, as currently practiced.
But my answer would be because of Python and JS/TS the two most popular languages in the space that most people are working with.
But at scale it does lean more functional for parallelism.
5
u/funbike Jul 09 '25 edited Jul 09 '25
Your argument is flawed.
LISP was chosen for AI due to its excellent symbolic processing capability. Symbolic processing contributed to early AI, but its limitations lead to the disillusionment that caused the first AI winter.
We now know that the GPT algorithm and deep learning far exceeds what's possible with symbolic processing, and therefore the strong incentive to use LISP is diminished.
62
u/OptimizedGarbage Jul 08 '25
Lisp was designed for working with AI. However, AI in the 60s and 70s was extremely different than now. They thought the human mind worked primarily by logic, rather than by association, and this misunderstanding lead people to pursue research agendas that flailed for decades at a time without making progress. Modern AI has basically no logical component at all, it's pure statistics. Haskell and Lisp is therefore good at things that don't matter for it, and bad at many things that do matter. Lisp is great at macros and source code generation, but now we use language models for that instead. Haskell has wonderful compile time guarantees, which means absolutely nothing in ML because we need statistical guarantees, not logical guarantees, and to the best of my knowledge there are no type systems that provide them. Python may not be as elegant, but it's easy to work with, has fast interop with C and CUDA, makes it easy to write libraries that support automatic differentiation, and is good at interactive debugging (which is important when the model you're training has been going for three days and you can't restart the whole thing just to add a print statement to debug)
2
u/recurrence Jul 08 '25
Haskell is lazily evaluated which is terrible for machine learning use cases.
3
u/zasedok Jul 08 '25
"AI" today means basically LLMs and neural networks. In both cases it ultimately comes down to very large linear algebra operations and Lisp is a particularly un-suitable language for that. Haskell could work but doesn't really offer any special advantage in that area either, and its runtime performance lags behind C, C++, Rust and especially Fortran.
If it's to drive high level logic using a specialised high performance ML package, Python is easier to use.
4
u/Voxelman Jul 09 '25
In my opinion F# is a good alternative because you can run it as script and you can use it in a Jupyter Notebook like Python
2
u/[deleted] Jul 09 '25
Lisp, ok. But haskell? Those are basically hacky scripts, gluing things together, like c++ modules. Python is just way better at that. Lisp at least is good for scripting.
2
u/ILoveTolkiensWorks Jul 09 '25
we've gone full circle
2
u/codeandfire Jul 09 '25
If you’re referring to the course by Prof. Deepak Khemani, I’ve taken that one. The point is that old-school AI deals with very fundamental problems in symbolic reasoning and that is implemented very well in functional languages especially Lisp. Modern AI stems from pattern recognition in statistical data for which a general purpose language like Python fits the bill as long as the actual performance critical heavy lifting is done in C/C++.
2
u/StephenSRMMartin Jul 10 '25
R is the Lisp-like of stats / ml.
R is *literally* modeled after Lisp, and borrows function names and concepts from Lisp in its C code.
2
u/Mission-Landscape-17 Jul 10 '25 edited Jul 10 '25
Lisp was used heavily during the first AI craze. There where even serval companies building dedicated Lisp Machines. Back then expert systems where all the rage. In the end they failed to deliver on user expectations and commodity hardware improved to the point that Lisp machines where no longer worth it.
You don't see more Lisp now because many developers just don't like lisp syntax. Meanwhile trying to do something useful in Haskel is its own brand of torture.
If you are interested in more esoteric languages their is also Prolog and Erlang. The former is entirely based on predicate logic, and is pretty amazing for writing domain specific languages. The latter has some amazing concurrency and redundancy features, the surrounding infrastructure includes support for zero downtime software upgrades.
PS: Javascript is Lisp in disguise. Lisp is what Branden Eich wanted to embed in Netscape but the syntax was made C like because that is what management wanted.
2
u/paicewew Jul 12 '25
Same reason why python is so popular while we have C, C++, C#, and data science languages like R, and while everyone knows there are significant problems with some of the libraries. Convenience trumps suitability.