
Ask HN: Which functional programming language is the popular enterprise choice? - _mc
If you use functional languages to build full or part of your application or you are aware of any such commercial applications please share!
======
_halgari
Clojure is pretty big in some places. The list here:
[http://clojure.org/Companies](http://clojure.org/Companies) includes Staples
Sparx, Walmart Labs, Groupon, and several other well known names.

------
DanielBMarkham
Jane Street is using OCAML. That or F# is my preferred choice.

Having said that, the tricky part is sticking to pure FP and coordinating data
structures. Not impossible, but it's a foreign area for many shops.

~~~
rjeli
Do you know why Jane Street chose OCaml over Haskell? They have similar
performance, right?

~~~
michaelochurch
Jane Street started using OCaml in the mid-2000s, when Haskell wasn't (or, at
least, wasn't perceived as being) up to snuff in terms of performance. Haskell
has come a long way in the past 10 years.

In 2015, Haskell is almost as fast as OCaml, albeit less predictable and
therefore possibly still less desirable in certain financial settings. Haskell
has a better concurrency story, though.

~~~
justincormack
There were some early papers by Simon Peyton-Jones on financial contract
modeling in Haskell too eg [http://research.microsoft.com/en-
us/um/people/simonpj/Papers...](http://research.microsoft.com/en-
us/um/people/simonpj/Papers/financial-contracts/contracts-icfp.pdf) but OCaml
had a much better performance story.

------
detaro
I'd guess Scala is the most popular choice, but for nearly every language
you'll find a company using it for at least parts of their products.

~~~
actsasbuffoon
I like Scala, but it's still got mutable state, for loops, and lots of other
imperative trappings. It's got some functional features, but I don't consider
it to be a functional language (IMHO). If Scala is functional, then so are
Ruby, JavaScript, and a host of other languages with higher order functions
and the ability to be immutable, so long as you make the effort to not mutate
anything (though anything is immutable by that logic). That doesn't make Scala
bad. I actually enjoy writing it most days, but I think it's not quite
accurate to call it a functional programming language.

For that matter, even Clojure has enough imperative parts that I don't
consider it to be functional. Maybe I'm just overly strict in my definitions.

Anyway, Elixir qualifies, but isn't heavily used. I hope that changes some
day, because it's a beautiful language. It manages to be principled about
being functional, while also having an easy learning curve, and rock solid
dependability. I want to see Elixir grow, because a language this good
deserves to be popular.

According to the Red Monk rankings, Haskell is close to Scala in usage. The
learning curve is much higher, but I love writing it. I love the clean, simple
code that Haskell pushes me towards, and it usually does the right thing the
first time I run it. It seems to be gaining traction lately, and Stack has me
excited about the possibility of things ramping up even further.

~~~
runT1ME
I'm not sure how familiar you are with scala if you are equating them in equal
'functional power' to Ruby and Javascript. Have you read Functional
Programming in Scala? The fact that the language supports immutable records
out of the box, type classes, monadic comprehension all make it much more
pleasant to deal with the realities of immutable data.

You _can_ write immutable java, but the language doesn't make it easy to at
all. Look at the hilariously bad builder pattern (which is as good as it gets
in Java) compared to the right way of doing things in Scala.

~~~
jbooth
What's Scala's superior alternative to builder patterns? You can have lots of
final members in a constructor in Java, too..

~~~
runT1ME
State monad and/or lenses when appropriate, which is made quite pleasant to
use with for comprehension's syntactic sugar.

~~~
jbooth
You mind pasting an example? I typically find higher kinded types, monads etc
to be more of a pain than the problems they're solving (builders &
constructors not really that painful IMO), but am really trying to keep an
open mind.

~~~
yummyfajitas
Sure, here's an example with lenses, taken from actual code I've written:

    
    
        (for {
          _ <- EventLenses.duid := UserDuid("12345")
          _ <- EventLenses.contexts := Seq(EventContext.NilContext)
          _ <- EventLenses.url := "http://news.ycombinator.com"
        } yield ()).run(originalEvent)
    

This code will take an event, set it's duid, contexts and url. If you squint
hard enough it almost looks like:

    
    
        originalEvent.duid = ...
        originalEvent.contexts = ...
        originalEvent.url = ...
    

The thing that's cool about lenses is that they compose nicely. E.g., the
contexts lens is defined as:

    
    
        val contexts: Lens[Event, Seq[EventContext]] = query >=> getterMLens("cx") >=> Lens.lensu(...)
    

This means that first we take the query lens, compose it with a lens that gets
the "cx" parameter, then do the actual work of decoding the "cx" param.

~~~
jbooth
Hey, thanks for filling in. So basically a facade over the original object
only masking some fields.. yeah, not really my cup of tea personally, I'm fine
with approx the same amount of code for a boring builder and/or constructor
call to duplicate an object, or, if appropriate, a mutable object. But it's
definitely nifty.

------
tsm
Clojure is gaining popularity. Staples uses it (their "SparX" group), and much
more notably a Clojure service is used to process every single transaction in
Walmart stores.

~~~
aaron-lebo
Can you or is there anything more to say about that Clojure service/Walmart?
That sounds fascinating.

~~~
tsm
It was mentioned in passing at Clojure/West a few months ago. I wish I
remembered more...this video might have more details:
[https://www.youtube.com/watch?v=av9Xi6CNqq4&list=PLZdCLR02gr...](https://www.youtube.com/watch?v=av9Xi6CNqq4&list=PLZdCLR02grLrKAOj8FJ1GGmNM5l7Okz0a&index=29)

------
paulblei
Scala is getting big in the enterprise. This list [http://www.quora.com/What-
startups-or-tech-companies-are-usi...](http://www.quora.com/What-startups-or-
tech-companies-are-using-Scala) gives a small overview

~~~
willtim
Scala is not a functional programming language, it is OO first and foremost.
It has better support for functional programming than Java 8, Python or
Smalltalk. And that in itself is great.

~~~
jbooth
Java 8 has lambdas and lots of streaming functional comprehensions like map,
filter, fold etc.

That sounds like all the functional stuff Scala has, right? What's it missing?
Also, since when does 'functional' mean 'algebraic types'? Aren't those
completely different things? Are common LISP and Scheme 'not as functional as
scala'?

~~~
willtim
Yes Java 8 does have a lot of new functional goodness. But it's still missing
a lot even compared to Scala. For example I cannot even do a basic case
analysis without involving statements, you have the ternary operator for
working with expressions and that's about it. Static type systems, type
inference and algebraic datatypes, which I believe to be hugely beneficial, do
not define "functional programming" in most peoples minds.

------
masida
Haskell usage by enterprises can be found here:
[https://wiki.haskell.org/Haskell_in_industry](https://wiki.haskell.org/Haskell_in_industry)

------
yummyfajitas
Scala and F# are probably the most popular enterprise choices. Both connect
well to existing infrastructures (JVM, .NET), are relatively easy to train new
developers on, and have largish companies backing them.

Scala is probably the larger of the two options - big users notably include
Twitter, Linkedin, Morgan Stanley, JP Morgan, Walmart and Reuters.

The use cases for F# tend to be smaller scale and more UI-oriented - internal
reporting tools at a hedge fund, for example. That's not to say they are
simple CRUD apps, merely that F# apps are not usually massive distributed
systems.

~~~
jarcane
_merely that F# apps are not usually massive distributed systems._

That's not really true, there's quite a lot of F# use for "big data"/"data
science" stuff going on, and one of the other big sells is use for financial
analysis (hell, even one of the official tutorials centers around processing
raw stock price data).

I would also say that it does appear Clojure is getting some strong uptake in
web dev on the JVM, thanks largely to the quality of some of the APIs and
libraries for both Clojure and Clojurescript. It's quite possible and even
easy to develop your entire web stack in Clojure (I'm currently doing just
that at work right now). Heck, if you want to shell out for it, you can even
use Datomic and have a database that's built in it ...

------
ryan_richt
Not a secret -- at Monsanto (Fortune 200) we use Scala heavily now, starting
from one project in 2010 and now a dozen teams use it for many many production
projects internally and in AWS. Certainly some in the almost 200k LOC range.
Scala is replacing Java at Monsanto (and yes we're always hiring!)

NB: Our Climate Corporation teams are running Clojure.

"What is functional?" is a difficult question my partner and I ponder often.
As someone else here said, simply having functions as first class values seems
insufficient as that would include Perl, JavaScript, C (fxn pointers) and
other langs as "functional." Saying supporting any mutability at all removes
your status as "functional" means Lisps aren't functional, which seems to
ignore the history of FP. Erlang doesn't have monadic IO but is highly
regarded by many as functional. If our definition essentially includes only
Haskell as "functional" then the term seems useless. So we define as
functional any lang that supports functions as first class values AND
significant enforced immutability.

Scala's first class functions, default immutable data structures and "val"s
compile-time enforcing immutability without too much ceremony put Scala in the
FP category for us, along with the Lisps, MLs, F# and Erlang.

------
quasiresearcher
Scala is gaining popularity because of Spark
[https://spark.apache.org/](https://spark.apache.org/)

------
vegancap
Clojure's all the rage at the moment.

------
glifchits
Walmart Labs is using Scala for their data science work, according to Julia
Greissl, whose talk I saw in Seattle a few days ago.

------
gclaramunt
If you consider Scala functional, I think it wins the popularity contest: used
by startups and established companies (Linkedin, Twitter, Meetup, Verizon,
Morgan Stanley, Autodesk, HuffPo, etc, etc...) and is not "we use it in a dark
corner where nobody cares" and more like "betting the whole farm on it".

~~~
michaelochurch
I would "bet the whole farm" on Haskell before Scala.

That's not to make a dig at Scala. It's way better than Java. It's also really
complicated, and the need for JVM compatibility is a big part of that. Then
you have the compile speed issues, the problematic tool chain, and the fact
that average Java programmers, given Scala, will create unmaintainable
nightmares.

I'd use Scala over Haskell when I wanted JVM interoperability, or if I needed
to train people up quickly. For a "bet the whole farm" play, existing
programmer familiarity actually matters a bit less-- "the whole farm" is
rarely bet on a one-month project-- and I'd pick Haskell first.

~~~
justthistime_
> Then you have the compile speed issues, the problematic tool chain [...]

Did you ever use Haskell? Those issues are far worse in Haskell than in Scala.

You just hear more people complaining about Scala, because it is used, while
Haskell projects are usually not developed and maintained anymore after the
author finishes his PhD.

~~~
codygman
> Did you ever use Haskell? Those issues are far worse in Haskell than in
> Scala.

I've used both, if anything Haskell is a little faster.

> You just hear more people complaining about Scala, because it is used, while
> Haskell projects are usually not developed and maintained anymore after the
> author finishes his PhD.

FUD. This is simply not true.

~~~
michaelochurch
Thank you for attacking that misconception. Haskell is, at this point, a
_very_ practical language, and becoming increasingly that way over time as it
proves to have the best enforcement model for the functional style among the
options out there. For good and bad, we're not in the 1990s anymore.

~~~
justthistime_
That gave me a good chuckle.

------
vosper
At my company (publicly traded; >200 engineers) I know that Scala has begun to
be picked up by the Java people. We're also rolling out Storm (Clojure) but I
don't know if there's anyone actually writing Clojure code.

------
danwakefield
Elixir might pick up some mind share, similar to ruby but still keeps its
erlang roots.

~~~
yellowapple
I don't think it's _quite_ there, yet. Everything's in place, and Elixir is a
wonderful language, but it hasn't been _quite_ battle tested yet.

On the other hand, Erlang is pretty ubiquitous behind-the-scenes, and I
wouldn't be surprised if some enterprises do develop their internal software
in it.

On the third hand, since Elixir uses Erlang's runtime, it'll be subject to
less required battletesting for the same reasons that JVM-based languages
(like Clojure, Groovy, Scala, and JRuby) are quickly gaining popularity in
enterprise environments that already use Java.

~~~
vorg
> JVM-based languages (like Clojure, Groovy, Scala, and JRuby) are quickly
> gaining popularity in enterprise environments that already use Java

They are. Though of the 4 examples you gave, only Scala's really being used to
build systems, though Clojure's being used by some who don't mind forgoing
static typing. Groovy's a scripting language used for short test and build
files, and for Grails. I don't think JRuby ever got used much in production.

~~~
yellowapple
You might be right about Groovy. I've seen JRuby used pretty heavily in
enterprise environments, though (usually to integrate Rails with an existing
Java-based system).

------
vertis
For context I work for publicly traded multinational real estate portal with
about 1000 employees.

The flow of dominant programming languages has been something like:

Perl -> Java,Ruby(Rails+Gems+APIs) -> Java,Scala,Javascript,Ruby

Not that those are the only ones floating around at our company, but Scala
definitely has a leg up.

------
yellowapple
Scala, Clojure, and Erlang come to mind. F# is another possibility, since
.NET/CLR is becoming increasingly popular in the enterprise (particularly in
Windows-heavy datacenters), though I don't know of a whole lot of enterprise
F# deployments off the top of my head.

Erlang's a bit of a special case; while you probably won't see many
enterprises _consciously_ using it (unless they use Jabber/XMPP via ejabberd,
of course), it's rather abundant behind-the-scenes with communication
infrastructure, and multiple large telecom providers and OEMs (including -
obviously - Ericsson) use it for their equipment and infrastructure.

------
crimsonalucard
Why hasn't haskell become popular?

~~~
willtim
The language is more restrictive and sometimes it's harder to get something
working. Of course the payoff is immense, you end up with much more
maintainable and composable code. However I'm not convinced that many
enterprises care much about these properties, as they are often more of a long
term win. People also have an emotional attachment to their existing tools and
paradigms.

~~~
sheepmullet
"Of course the payoff is immense, you end up with much more maintainable and
composable code. However I'm not convinced that many enterprises care much
about these properties, as they are often more of a long term win"

Actually, you have it backwards. Enterprises care a great deal about long term
maintenance and have large codebases. However, they are also very conservative
and prefer the tried and tested approach.

Startups don't typically care about maintenance because, for the most part,
they are going for a binary win/lose outcome where in a win they have so many
resources that 5x higher maintenance costs are ok, and in the lose they close
up shop/pivot and throw the code out. And startups are usually more open to
taking a chance on new/different tech.

If there were 3-4 large enterprise companies with 200kloc+ Haskell projects in
use I feel Haskell could see long term 20-30% uptake in the enterprise. But
few enterprises will take the risk of being one of the first.

~~~
tome
> If there were 3-4 large enterprise companies with 200kloc+ Haskell projects
> in use I feel Haskell could see long term 20-30% uptake in the enterprise

I would be _very_ surprised if there were not tens of companies with 200kloc+
Haskell codebases. I know that one of them is an enormous enterprise (but the
others that I know of are not).

~~~
crimsonalucard
What company? I would like to know.

~~~
tome
Standard Chartered.

------
lambdaelite
If you consider it functional, Common Lisp is still used by some very large
and established companies: the Lisp HUG mailing list (LispWorks) will
frequently have email signatures from some of them. There is some truth to the
notion that CL is a competitive advantage and so its use tends not to be
discussed in the open.

------
dreamdu5t
None, or possibly Haskell.

Scala, Clojure, F#, JavaScript aren't functional languages. Functional
programming is programming with pure functions. It is not "first-class"
functions. It is not closures. It is not static typing.

------
boothead
The critical distinction here is popular with the people who have to use it or
most widespread? :-)

------
axle_512
Many have already said it, but Clojure seems to be gaining in popularity.

------
mikerichards
Surprisingly, I think Clojure has much more traction than Scala.

~~~
arms
Can you please elaborate?

------
ExpiredLink
None.

------
AlbozZ
AlbozZ

------
mlitchard
I guess you'd need to define what you mean by functional language. That term
gets thrown around a lot, to the point of meaninglessness. If you mean
referentially transparent then neither Scala nor F# are referentially
transparent.

~~~
willtim
I've often seen the term "functional first" used, which would describe F# but
not Scala.

------
frik
Javascript / Nodejs

it's multi-paradigm: scripting, object-oriented (prototype-based), imperative,
_functional_ ( source:
[https://en.wikipedia.org/wiki/JavaScript](https://en.wikipedia.org/wiki/JavaScript)
)

Many languages known as functional (Scala, F#, Lisp, Scheme, OCaml) are multi-
paradigm languages (check out Wikipedia!), purely functional programming
language like Haskell are the exception
([https://en.wikipedia.org/wiki/Purely_functional](https://en.wikipedia.org/wiki/Purely_functional)
). And the IO part is hardly functional.

@Down voter: care to explain?

~~~
devbug
All I can think is... Poe's Law.

[https://www.youtube.com/watch?v=ztVMib1T4T4](https://www.youtube.com/watch?v=ztVMib1T4T4)

~~~
Yadi
I was like wait what...Then I saw your comment.

Yup Pretty much same reaction to that suggestion.

