Accepted answer

The best known are OCaml and F# (which can be vaguely described as OCaml for .NET).

There are many other multi-paradigm languages, like Oz, but they have mostly pedagogical value. By contrast, OCaml is very practical. It's almost as fast as C and almost as beautiful as Haskell :)

The popular scripting languages like Python and Ruby let you program in functional style as well. However, they don't provide one of the strongest facilities that "classical" functional languages (as well as OCaml) have: pattern matching (don't mistake it for regexp).


Ruby! In Ruby, everything is an object (even literals), and it also has full functional programming support.


I'm wondering why you are looking for a language that specifically encourages mixing it up rather than just doing it anyway with a language that does functional programming and OO programming well? It could be easily brought into effect with Python, Ruby, Perl or similar interpreted languages. In addition C based OO languages tend to mix pure C with OO features, for example Objective C could easily be written in such a way should you choose.

EDIT: I have been made aware I'm incorrect, I've left this answer here incase someone can learn from my mistake - see comments.


in my experience, C# is very good for this purpose. in c# u can delegate Functions and even with the extension methods you can mimic OOP behavior but with FP in mind.

I usually build a class with behaviors that I needed, then build some functions to do my dirty works around it with FP practices and this works well, and as u mentioned Debug Heaven.

in my opinion, Pure FP and Pure OOP both bring some shortcomings that the others won't. OOP tends to complicate the code vs FP makes it harder for some businesses to code especially when the state is essential.


Python, javascript, common lisp, ruby, smalltalk, haskell, and ocaml, off the top of my head. It's not really an exotic combination.


As long as you don't insist on "purity", Common Lisp supports all your needs.


You're really asking the wrong question. Your question is premised on there being a distinction between "OO" and "functional" programming. This distinction isn't interesting or relevant. In fact, according to the "supports first-class function" criteria, even Java is functional.

But you hit the nail on the head with "purely functional". That's the interesting bit. What languages offer you referential transparency and purity like that? Well, most of them, if you're very careful. But not many of them actually guarantee that your functions are pure. I can only think of a couple of languages that offer you that.

One of them is Haskell. In Haskell, you write programs that are purely functional from beginning to end. Side-effects are delegated to a data structure called IO, and state is handled by passing it through pure functions or encapsulating it in monads. So you have your "debugging heaven" where only a small portion of your code interacts with global state and the rest of your program is pure, and purity is enforced by the language.


JavaScript, Python, and Ruby could be used that way, but Scala bumps up a notch by typing the function statically and working under JVM.


C#. It's imperative, which can be handy, but also has a lot of functional features. Lambdas, iterators, and LINQ are all functional.

It probably won't appeal much to purists, but it works for me.


OCaml and F# are the most popular languages that mix OOP and FP, as far as I know.

Most languages, like Ruby, mix functional programming in, but a lot of people don't even realize it. I find languages like that leave a lot to be desired on the syntax front and such.


Haskell: Pure functional ,pretty much no OO, but go ahead, take the dive. :D

Scala: Beautiful mix of OO and FP, could possibly overtake java as premier language on the JVM in a decade or 2. I like it because it brings functional programming to the java platform, something that's sorely need IMHO.

C#: Awesome support for OO, as well as getting more functional (first class functions already, we'll see what improvements .net 4 brings)

F#: .net language Built to be functional specifically, as opposed to C#, which was originally conceived for OO stuff.

Python: Great for OO, but not at all suited to FP

Javascript: Supports first-class functions, but not specifically designed for FP like Scala and F#. Still slightly better than python IMHO.

Why do you want to mix OO and FP? As a stepping stone?


Also, many scripting languages such as Python, Ruby, Lua, etc. have this capability, but lack many of the nice features of functional languages such as algebraic data types and pattern matching.


Javascript: OO and functional.

Related Query

More Query from same tag