You don’t actually need to know any of the functional programming languages to work in the AI sphere. Moreover, codebase in pure funcional languages is hard to understand and maintain, that’s why they are rarely used in production. Of course you can learn any language for funsies, but I’d recommend Kotlin as a modern hybrid OOP language with a solid functional toolkit
Moreover, codebase in pure funcional languages is hard to understand and maintain, that’s why they are rarely used in production.
hahahah how to trigger a lot of people working with these pure functional languages (like me).
I’ve worked with both “normal languages” like C++, java, Perl, javascript (node + UI), etc… and then I switched to Haskell and Clojure. And our current production code is a LOT better than in traditional languages. In particular, maintenance is a lot cheaper that what I was used to when working with more traditional languages.
Regarding the community impact I would advise to use Clojure instead of Haskell (or Purescript, or Elm). Clojure is a nice middleground that has a huge advantage of being very stable (by that I mean, the code you write today will probably be very easy to deploy in 10, or 20 years from now).
Note however, the language alone is not sufficient to write good code, but it helps you choose better abstractions that will be easier to maintain. If you dive into the spirit of the language, you will have a better intuition and understanding about state management of big applications and will probably make more visible some design issues.
This is incorrect. Functional code bases exist in many production environments. Twitter (pre musk) migrated their bloated code base TO Scala because functional code bases are easier to maintain and understand.
If you think about it, it makes sense, side effect free code will be easier to maintain just due to the lack of side effects.
Moreover, codebase in pure funcional languages is hard to understand and maintain, that’s why they are rarely used in production.
This is incorrect. They are rarely used because procedural languages have momentum. It’s way more likely you’ll get Joe Codemonkey to learn and be productive quickly with functional features added to a procedural language than to learn and be productive quickly with an entirely different paradigm. So that’s what happens.
Your crossposted question was a choice between Clojure and Common Lisp. Between the two I would say Clojure is more functional, but it comes with the baggage of the JVM. Common Lisp on the other hand is more of a 1980s language where you can use a functional style some of the time, and with some pain.
If you want a Lisp-like language, the usual starting point is Scheme, and if you want something with more creature comforts, try Racket. Either way, you’d start by reading SICP (fulltext here). But I think that whole approach misses out on an important aspect of FP, which is how type systems classify values.
So I’d say go with a typed functional language. OCaml is something like what you are used to, while Haskell is more “drinking from the fire hose” (steeper learning curve, but I think you will get more from it).
For Haskell, learnyouahaskell.com is a good place to start. I don’t know if there is something similar for OCaml. Haskell can be seen as a gateway drug to even more pointy headed languages like Idris.
Yet another thing to look at as a possible migration point from Ruby is Elixir. It’s not really so FP, but it’s very practical if you’re mostly interested in web development rather than programming languages per se. It’s dynamically typed like Ruby and uses Ruby-like syntax, so you should be able to switch to it fairly easily.
Common Lisp on the other hand is more of a 1980s language where you can use a functional style some of the time, and with some pain.
Isn’t the main issue with it that you’re not forced to be functional? It’s supposed to be pretty good at it with the correct libraries.
Either way, you’d start by reading SICP
You really don’t want OP to learn lis
Isn’t the main issue with it that you’re not forced to be functional? It’s supposed to be pretty good at it with the correct libraries.
I’d say CL’s main issue is that it’s anachronistic by now, and when used idiomatically it’s an imperative language (think of LOOP). You can use some functional idioms in it, but it gets painful to do so.
Look at the article “Why Functional Programming Matters” and imagine rewriting the code examples in Scheme (confusing but straightforward) and then in CL (ouch).
Most ML development is done in Python to my knowledge. The reason is mostly the readily available side packages like torch, scikit-learn, etc. And Python, although not constructed as such, does indeed support a functional style. A quick search revealed a HowTo:
As a data scientist working in ML: it’s essentially all python outside of some really niche stuff
Elixir is a nice functional language. Not as purely functional as Haskel mind.
It is based off of Erlang and runs on the Erlang VM. Syntax is Ruby inspired. It is not a high performant language (like C, Rust, etc), but it excels at distributed computing and fault tolerance. There is excellent documentation and tooling for it as well.
I recommend picking up Graham Hutton’s short text Programming in Haskell, Second Edition. Even if you don’t end up using Haskell in “real work” (and you might!) it will teach you a remarkable number of things about how functional programming works.
Is Haskell the language that differentiates between pure and impure functions? I’ve never seen a single line of Haskell, but I watched a number of YouTube videos and I agree that experts explaining the language is eminently helpful to understand functional programming in general.
Haskell doesn’t have impure functions. What you’re calling impure functions (functions that produce values in the notorious I/O monad) are actually pure functions, that produce what you could think of as programs that run in an impure interpreter that’s outside of Haskell itself. Don’t worry about understanding that in detail until you’re deeper into learning Haskell, but at that point it will help demystify what the I/O monad (a traditional stumbling block) actually is.
The first few pages of learnyouahaskell.com will give you some sample code to show how clean the language can be.