10 ms·
Functional Programming at Facebook
- rdtsc 11y agoWell 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 11y agoBecause there's functional as in only using pure functions (Haskell, ocaml) and functional as in access to higher order functions (JavaScript, erlang, clojure)
- krat0sprakhar 11y ago> 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.
- Scarbutt 11y agoleaving runtime asides, which do you enjoy more Ocaml or Clojure?
- ohnomrbill 11y agoI use both, for different things. Clojure is more easily concurrent, and I love ClojureScript, so I tend to use it for web applications. OCaml is extremely useful for native code (I write a lot of personal productivity tools in OCaml).
- krat0sprakhar 11y agoTo add to ohnomrbil's succinct reply, I absolutely enjoy being scolded by OCaml's compiler. The type inference is just marvelous and the code is almost as concise as Python etc. OTOH, the library ecosystem for OCaml is not even close to the stuff that's available for Clojure.
- catnaroek 11y agoI'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 11y agoPretty 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 11y agoHere 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 11y agoNo 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 11y agoClojure 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.
- raould42 11y agoi thought ocaml ain't pure like that?
- pauldirac137 11y agoYou thought right. Ocaml is an impure functional language.
- julian_1 11y agoThere are a couple of monadic IO systems for Ocaml - Lwt and Async which are pretty commonly used - and enable writing code using typed mutation/side effects.
- rdtsc 11y ago> Because there's functional as in only using pure functions (Haskell, ocaml) and functional as in access to higher order functions (JavaScript, erlang, clojure) Or functional as having proper closures. Or tail call elimination. Or using immutable data, or immutable variables. Or minimizing mutable state. Or being decalrative. etc... ;-)
- catnaroek 11y ago> Or functional as having proper closures. Closures are an implementation detail. > Or tail cail elimination. Tail call elimination is just the right way to implement tail calls in a strict language. > Or using immutable data, or immutable variables. Variables don't “mutate”, they are substituted with other expressions. What imperative languages have is “assignables”. > Or minimizing mutable state. Functional programs have plenty of state - which changes over time. You can't have computation without traversing a state space - over time. > Or being declarative. What (technical!) definition “declarative” are you using?
- julian_1 11y agoArguing about terminology and the correct definitions/properties of functional languages only demonstrates the point - that the properties of a functional language are context-sensitive and subjective.
- catnaroek 11y agoIt is not context-sensitive: https://news.ycombinator.com/item?id=11179695 https://news.ycombinator.com/item?id=11179695
- rdtsc 11y ago> Closures are an implementation detail. Except when they are not there done properly (cough cough Python), it not so fun doing functional programming. > Tail call elimination is just the right way to implement tail calls in a strict language. Well Erlang is not strict and has tail call elimination. Because of lack immutability, recursion is used. Without tail call elimination recursion will blow the stack. > Variables don't “mutate”, they are substituted with other expressions. What imperative languages have is “assignables”. Yes they do. X=X+1 -- Variable mutated. Like it or not that is the bread and butter of programming. Unless someone did strictly functional programming and math. Then I can see how they'd be very confused by that statement. There is also immutable vs mutable data. For example both Erlang and Elixir have immutable data. But Elixir has mutable variable, while Erlang doesn't. As for assignables, I've never heard that word. I went to the standard 4 year CS program. Seemingly did a regular curriculum. Is that a translation from another langauge or a functional programming terminology? > Functional programs have plenty of state - which changes over time. Some have more, some less. Minimizing means making it explicit, passing it around, using immutable data. As opposed to say sticking it in a large object instance in a global singleton and then everything calls 100 something methods to mutate it. > What (technical!) definition “declarative” are you using? The point I think is, it is just as technical as "functional" is. It has a bit of a "No True Scotsman" thing going for it. But as a heuristic think maybe about when you'd use patern matching to destructure something vs say a nested set of if and elses.
- meridional 11y agoIn part, this is due to Haskell et al. are statically typed, which provides a higher safety guarantee than dynamically typed languages like erlang.
- krat0sprakhar 11y agoAlthough this reason sounds plausible, it is quite surprising since one of the first functional languages - Lisp was dynamically typed.
- nilved 11y agoLisp isn't a functional language.
- vitno 11y agoThis person is getting downvoted... but it isn't. Lisp, especially in it's early implementations is highly imperative. This is why when people talk about Clojure they always talk about Immutability, it's part of what forces a functional style on the language.
- incepted 11y agoYou're both right and wrong, it's just that "functional" has a lot of different definitions and nobody can agree on which one is correct. As a result, "functional" has become pretty much meaningless when describing a programming language.
- Everhusk 11y agoThe feature set of Facebook is much more complicated than WhatsApp. Most of WhatsApps features come out of the box with ejabberd too (which is what they used in the beginning). Is it really a fair comparison?
- rdtsc 11y ago> The feature set of Facebook is much more complicated than WhatsApp But the feature set of Facebook is not all implemented in Haskell or OCaml either. There is lots of PHP etc.
- incepted 11y ago> Even though it is probably the most practically used functional language. Would love to get some evidence to back up Erlang being the most practically used functionally used language, because for all I know, it's hardly used at all these days.
- kyllo 11y agoPracticality is subjective, though. Unless you conduct an opinion poll, you will not find data objectively demonstrating that one language is more "practical" than another.
- incepted 11y agoSure, but I interpreted OP's statement as saying "used in practice" as in "used in the real world". Pretty sure that Erlang would barely register as a blip on such a chart.
- abiox 11y agoRabbitMQ and CouchDB are written Erlang; Much of Ericsson's telephony infrastructure runs it; various companies in their industry like TMobile and Motorola use it.
- deleted 11y ago[deleted]
- im_down_w_otp 11y agoAlmost all the successful non-Google ad networks and exchanges are written in Erlang, Goldman Sachs HFT platform is written in Erlang, several massive scale game platform backends are written in Erlang, several international "national net" banking switches are written in Erlang, a huge chunk of the global land-line and mobile telco switching infrastructure is written in Erlang, Heroku's control plane is written in Erlang, GitHub's RPC backplane is written in Erlang, Amazon SimpleDB is written in Erlang, Bet365's high-scale betting platform is written in Erlang, Pinterest is migrating services to Elixir (rooted in Erlang). There's a ton of stuff written in Erlang out there. A lot of really core infrastructure services that have to just run and run and run. It's not particularly trendy, but it gets shit done, and it does so with a quiet dignity. :-)
- lxcid 11y agoIn the comparison between Flow & TypeScript, he mentioned Flow gets non-nullability right. Anyone have any example to illustrate this?
- lebek 11y agoIn Flow, `var a: string = null` would not typecheck. In Typescript it would.
- kozikow 11y ago> 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.
- music 11y agoI find it very interesting that Scheme beat out extremely fashionable languages like Rust and Go, not to mention Clojure didn't even make the first 50. I would expect Lisp and Prolog at the tail end of any such list.
- pmarreck 11y agohttps://en.wikipedia.org/wiki/Argumentum_ad_populum https://en.wikipedia.org/wiki/Argumentum_ad_populum Has no relevance to actual language quality, potential or value. If this wasn't the case, then no language would ever pass, or fall behind, another language in popularity. Popularity is a reflection of already-realized value. That's all.
- runT1ME 11y agoYes, but it is #14 Redmonk's rankings: https://redmonk.com/sogrady/2015/07/01/language-rankings-6-15/ https://redmonk.com/sogrady/2015/07/01/language-rankings-6-1...
- ChemicalWarfare 11y ago
- ForHackernews 11y agoThis from the people who brought us the 18,000 class iOS app?
- draw_down 11y agoI feel like linking someone to a slide deck is akin to telling them to go fuck themselves.
- stefans 11y agoOP 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?