
Functional Programming at Facebook - stefans
http://www.scs.stanford.edu/16wi-cs240h/slides/fb-slides.html#(1)
======
rdtsc
Well also WhatsApp handling 1B+ users with Erlang, and with (what used to be?)
only a handful of engineers.

But somehow the Haskell, OCaml and Scala users never want to include Erlang
when talking about "functional". Even though it is probably the most
practically used functional language.

~~~
dreamdu5t
Because there's functional as in only using pure functions (Haskell, ocaml)
and functional as in access to higher order functions (JavaScript, erlang,
clojure)

~~~
krat0sprakhar
> Because there's functional as in only using pure functions (Haskell, ocaml)

This is not true. Having written a good amount of OCaml I would argue that
programming with side-effects in OCaml is extremely approachable - almost as
much as Clojure. There are mutable data structures in the stdlib (Array,
Hashtbl) and IO etc. is straightforward. Like Clojure, there exists a ref type
which can be easily mutated. It's one of the reasons why OCaml strikes as an
extremely pragmatic language to me.

~~~
catnaroek
I'd distinguish between (at least) three degrees of “purity”:

(0) Absolutely anything goes. Examples: Racket (in the REPL), Lisp, Clojure,
Scala, Erlang, etc.

(1) Values are immutable, but any computation might have any effect. Examples:
Standard ML, OCaml (mostly), Racket (mostly).

(2) Values are immutable, and computations are type-annotated with their
possible effects. Examples: Haskell, Idris, Ur/Web.

~~~
i_s
Pretty strange that you put Clojure in the "anything goes" category when it
has been the clear leader when it comes to immutability. Lots of those
languages you put in the other categories don't even have persistent data
structures in their standard library.

~~~
catnaroek
Here is why: [http://pastebin.com/t3Q3CW4j](http://pastebin.com/t3Q3CW4j)

This is particularly infuriating because the proper way to handle bound
variables is already known:
[https://en.wikipedia.org/wiki/De_Bruijn_index](https://en.wikipedia.org/wiki/De_Bruijn_index)
.

~~~
i_s
No one is maintaining state by constantly clobbering namespace level variables
in Clojure, though. What actually comes into play are ways the language and
standard library encourages passing data around and manipulating it, which in
Clojure is as immutable as you'll find in any language.

~~~
catnaroek
Clojure encourages me to program in the REPL, because _there is no other way
to know what is going on in such a semantically crazy language, other than
trial and error_.

And the state of the Clojure REPL is as mutable and imperative as it gets, as
my paste showed.

~~~
greydius
You can rebind variables in ghci, too. I certainly wouldn't say this is
evidence that Haskell promotes mutable data.

~~~
catnaroek
> You can rebind variables in ghci

No, you can't: [http://pastebin.com/SdbKM7V7](http://pastebin.com/SdbKM7V7)

In ML and Haskell, a new variable might _shadow_ an old one (if they have the
same name), but they are still different variables.

Shadowing is slightly harder to implement than rebinding, but it provides a
useful guarantee for the user: the meaning of existing definitions remains
stable even if new definitions are introduced into the environment.

~~~
greydius
You are correct. I failed to consider the implications of the different
mechanics in the repl. I'm inclined to think the clojure repl is more
conducive to experimenting. That is, you can change any part of your program
to see what happens. I guess one programmer's sandbox is another programmer's
hellish nightmare of mutability. For what it's worth, I would never redefine a
var actual code, but I can't say it hasn't been done by others.

~~~
catnaroek
> I'm inclined to think the clojure repl is more conducive to experimenting.

I'm inclined to think the Clojure REPL is more conducive to _flailing around_.
Now, this might sound like derision, but it isn't intended that way: Flailing
around can be a very time-efficient way to familiarize oneself with an unknown
domain, especially if the cost of making wrong design decisions is small.

But at some point one has to _consolidate_ what one already has, and, in my
experience, Clojure makes this very difficult.

> I guess one programmer's sandbox is another programmer's hellish nightmare
> of mutability.

If you absolutely want mutable definitions, you can have them in Haskell (with
some noise) and ML (with no noise) too:
[http://pastebin.com/00ScnFxC](http://pastebin.com/00ScnFxC) . So a Haskell or
ML programmer always has at their disposal whatever they think is the best
tool for the job.

Can I have it the other way around in Clojure?

~~~
greydius
> Flailing around

Haha, yes. This is how I feel about Matlab, actually. But I suppose Clojure is
no different in this respect.

I much prefer the Haskell approach: make dangerous things hard to do.
Unfortunately, a majority of programmers consider that to be "unpractical".

------
lxcid
In the comparison between Flow & TypeScript, he mentioned Flow gets non-
nullability right. Anyone have any example to illustrate this?

~~~
lebek
In Flow, `var a: string = null` would not typecheck. In Typescript it would.

------
draw_down
I feel like linking someone to a slide deck is akin to telling them to go fuck
themselves.

~~~
stefans
OP here: Would you prefer to have an indication that the link target is a
slidedeck or do you think slidedecks should not be linked to at all?

------
kozikow
> Even though it is probably the most practically used functional language.
> Scala have 30th place on Tiobe index, while Erlang have 42th:
> [http://www.tiobe.com/index.php/tiobe_index](http://www.tiobe.com/index.php/tiobe_index).

~~~
runT1ME
Yes, but it is #14 Redmonk's rankings:

[https://redmonk.com/sogrady/2015/07/01/language-
rankings-6-1...](https://redmonk.com/sogrady/2015/07/01/language-
rankings-6-15/)

~~~
ChemicalWarfare
I'd venture to guess that once you start scanning github and to a lesser
degree stackoverflow, the scale gets tipped away from the "enterprise
applications" where Java reigns supreme.

------
ForHackernews
This from the people who brought us the 18,000 class iOS app?

