14 ms·
Why no one uses functional languages (1998) [pdf]
- wiineeth 7y agoJane street is a very successful company that uses Ocaml for everything. Any other companies like that?
- ccortes 7y agoBrazilian nubank, they mainly use clojure
- mercer 7y agoAnd they recently acquired Plataformatec, the company behind Elixir.
- johanvts 7y agoSimCorp uses Ocaml as well.
- runeks 7y agoAnd APL. As I understand it, they have quite a bit of APL code, and only a little bit of OCaml and F# (and a crapload of C#).
- pjmlp 7y agoSyscog is a Portuguese company heavily focused on Lisp.
- dang 7y agoSee also from 2014: https://news.ycombinator.com/item?id=8082728 https://news.ycombinator.com/item?id=8082728
- lifeisstillgood 7y agoWe have had these discussions for many years (even pg wrote about Blub IIRC), but the real reason (IMO) is that language choice matters far less than we like to think. What business we choose to build with the language will outweighs the impact of language choice a hundredfold. Our decisions on CI/CD, our discipline on building clean architecture with whatever language we like matters more. In short, the things that make development a productive and enjoyable experience are linked less to the language than to the skill and professionalism of the development team - and "weird" languages tend to have more skilled and professional developers working in them, so the causality / correlation tends to get mixed up. The upshot is, worry less about learning Lisp at work, and more about fighting your corner on why we should rewrite that 3,000 line monster engine module that we all call each day but making changes to it is a nightmare.
- Toine 7y agoAmen. Or as Jobs said, "You've got to start with the customer experience first and work backwards to the technology. You can't start with the technology and try to figure out how you're gonna sell it" https://youtu.be/FF-tKLISfPE https://youtu.be/FF-tKLISfPE
- SiVal 7y agoAnd yet, iPad.
- yibg 7y agoWhat about it? Are you claiming the iPad started from the user experience or technology?
- qubex 7y agoWhat do you mean by that? I’ve been using iPads as my main computing devices for the past five years (and almost exclusively for the past three). It depends on your workflows.
- SiVal 7y agoI'm responding to "You can't start with the technology and try to figure out how you're gonna sell it", not saying iPad is bad. I was referring to the remarkable history of iPad, which was designed to have certain features, not designed for a particular use. Jobs started on it before iPhone, attempting to combine his and Ive's favorite features: simple, multitouch, thinner!, no keyboard, no mouse, no stylus, no buttons, lightweight, handheld (not used plugged it), great screen, etc. It was not designed as a "solution" but as a great...thing...that would turn out to be great for...something. It was his baby, and he insisted that they keep working on it until they found a use, which they did: they turned it into an iPhone. That was smaller (screen size) than Jobs had planned, so he made them keep going on bigger versions. They would be so wonderful, they would be great at...something. When they released the first one in 2010, they were intentionally vague about its target market. They presented it as maybe a substitute for laptops for productivity apps, they presented it as sort of a better Kindle for reading, as an artist's tool (for artists who fingerpaint), etc., with the hope that with such a great collection of features, it would be like the original LaserWriter and turn out to be perfect for some market. Regardless of what that market would end up being, it did in fact start with the technology that two passionate designers wanted to exist for its own sake without knowing in advance what it would end up being used for.
- femto113 7y agoInterestingly written 3 years after the introduction of a functional language that eventually went on to become the most popular language there is.
- SCdF 7y agoJS has some properties that are typically associated with functional languages but is missing others. But then again, so does Java if you're willing to ignore the lack of syntactic sugar for them, so what do definitions even mean anymore.
- eru 7y agoJava only got some functional trappings fairly late in its life. JavaScript was a relative transparent reskin of a (rushed) Lisp from the start.
- LockAndLol 7y agoWhich language are you talking about?
- motogpjimbo 7y agoThe one that controls the web application you're currently using.
- SCdF 7y agoControls the comment collapsing, everything else doesn't require JS.
- tobyhede 7y agoJS?
- _hardwaregeek 7y agoTooling is such a huge factor. I'd love a functional language that had build tools as nice as rustup and cargo. Indeed I'd place Rust as an example of a language that got it right. Sure, Rust isn't functional, but it's confusing on first usage, so close enough :D In all seriousness, the big issue that functional languages have to get over is that most programmers are not great mathematicians, so declarative programming feels very weird and confusing. With Rust the big issue is all the rules about memory. How did Rust solve it? For one, they made the language as familiar as possible. Rust's syntax is extremely close to C/C++, even if the semantics aren't. As much as PL people claim syntax doesn't matter, it does. ReasonML is a project with a similar philosophy. Next, they put a lot of work into documentation and explanations, especially at the compiler level. Rust's compiler messages are fantastic and often anticipate beginner mistakes. I'd love a functional language that detects when the code looks kinda imperative and gently guides you towards the functional option. And finally, they had a killer app like Wadler mentions. Performant memory safety is pretty hard to argue against. Even a manager could see the potential upsides. I wonder what sort of killer app one could create for functional languages? Reason with ReasonReact could have robust UI as one, but that's still not as good of a sell as performant memory safety.
- gridlockd 7y agoPerformant memory safety is not that big of a feature. GCs are fast enough unless you have real time constraints. If have real time constraints, you probably do not care about memory safety that much, unless your system is safety critical. If your system is safety critical, you are using lots of tooling for validation beyond memory safety - and probably some form of model based code generation. That tooling just does not exist for newcomer languages.
- eru 7y agoWhere do you have real time constraints but don't care about things blowing up? I guess there's lots of places that have soft real time constraints like in games and other entertainment? But hard real time usually means you do care about not blowing up.
- csours 7y ago> 'Much of the attractiveness of Java has little to do with the language itself, but with the associated libraries ... (Much of the unattractiveness is due to the same libraries)'
- dotemacs 7y agoHere is a list of companies using using Clojure & ClojureScript: https://clojure.org/community/companies https://clojure.org/community/companies
- random32840 7y agoLists like this strike me as somewhat meaningless. Those companies probably also use bash scripts, hardly represents a significant chunk of the product. How much of their codebase is in Clojure?
- dloss 7y ago"[...] this allows Haskell to be used as a scripting language for Microsoft's Internet Explorer web browser". Interesting. Never heard of that. https://www.microsoft.com/en-us/research/publication/scripting-com-components-haskell/ https://www.microsoft.com/en-us/research/publication/scripti... EDIT: Add link
- LockAndLol 7y agoIf WASM had access to the DOM, I imagine we'd start seeing a replacement of JS and a democratization of web languages. I however dread the day I get to read a full-stack C/C++ webpage.
- gridlockd 7y agoYou can give WASM access to the DOM. What you describe is already possible, but most language runtimes are too big to be served for a website.
- rowanG077 7y agoAre there efforts to cache runtimes? I imagine most programs would be rather small if you don't have to ship the runtime.
- gridlockd 7y agoThere isn't really a good workflow regarding dynamic linking and libraries in WASM right now, but things are moving. Even then, what are the odds that your new user already has the particular version of your runtime cached already? If you really have a non-trivial application, then downloading the runtime isn't that big a deal I guess. If you just have a website, it wouldn't be warranted. Having said that, if you're careful, you can use Rust[1] or C/C++[2] with minimal overhead. I doubt that's going to become popular though. [1] https://www.hellorust.com/demos/add/index.html https://www.hellorust.com/demos/add/index.html [2] https://floooh.github.io/sokol-html5/index.html https://floooh.github.io/sokol-html5/index.html
- asp_net 7y agoA more recent view: "Who Cares About Functional Programming?" https://thomasbandt.com/who-cares-about-functional-programming https://thomasbandt.com/who-cares-about-functional-programmi...
- noelwelsh 7y agoFP is going mainstream. In the same way that mainstream OO wasn't pure OO in the manner of Smalltalk but instead hybrid languages like C++ and Java (and more recently Python), mainstream FP isn't Haskell but languages like JS (w/ Typescript), Scala, Kotlin, Rust, Swift, and friends taking core ideas from academic FP and presenting them in way that works better for industry.
- giantDinosaur 7y agoSomething like Elm is also perfectly learnable in mainstream contexts. Haskell gets too much attention.
- noelwelsh 7y agoAgreed, Elm does seem very nice from my very limited experience. I'm not sure it's going to go mainstream, though, but we'll see!
- ilaksh 7y agoI think Ocaml is the O.G. impure functional language. I am having fun getting familiar with it again. You also didn't mention F# or ReasonML. Or are those too much like FP for your point?
- noelwelsh 7y agoYes, Reason, O'Caml, and F# are in the mix as well, though I think adoption is much lower than some of the other languages I mentioned. (I think Scheme and ML both have a claim to be O.G. strict impure FP, as both were developed at about the same time in the 1970s. O'Caml is more recent IIRC.)
- deleted 7y ago[deleted]
- suls 7y agoThe pessimist in me thinks that going mainstream means it will be less useful for screening applicants/keyword searching job postings. Sort of repeating what agile has brought us.
- anonytrary 7y agoPrograms are incentivized by need, and businesses and users are the primary consumers of programs. If FP and OOP both satisfy those needs nearly indistinguishably, but one of them is easier for the vast majority of programmers, then guess which one everyone is going to use? Working for a company has taught me that people will try to get away with doing as little as possible when it comes to satisfying a business need.
- rumanator 7y ago> Working for a company has taught me that people will try to get away with doing as little as possible when it comes to satisfying a business need. Aka productivity.
- tluyben2 7y agoSure but skipping all best practices in favor of fast delivery might bite you later on.
- eru 7y agoFunctional programming is mostly touted as being able to keep productivity up in the long term. (And detractors mostly complain that it takes too long to get started, not that the long term is unmaintainable.)
- anonytrary 7y agoNot really. Sometimes the more productive thing to do is to step back and rewrite everything. The up-front cost gets amortized over the long term benefits. The asymptotics become important for a business that intends to exist far into the future.
- andi999 7y agoMaybe another reason is: there is two kinds of software, one is programms which process input data and transform them to output data. And then there is software which operates hardware, like steering of the stepper motors of a robot, or the firmware of a washing machine. Functional languages are (rightfully) immediately dismissed for these kinds of problems. Then there is a grey zone: GUI programming, this is almost hardware progamming and FP have been trying but not doing well in this domain (might be wrong though). Hardware programming doesnt come up often IT departments, so maybe this is a blind spot, but basically you are loosing a big share of the market. Ps: something special might be with the erlang telco system, but i have no idea about it
- skohan 7y agoOne could argue that all software is operating hardware. In many cases the hardware you're operating is a CPU, GPU, memory and storage. Most of the time it doesn't feel like that if you're doing something like web programming. But for something like computer graphics, where you're thinking carefully about how to lay out memory so that a multi-core CPU can traverse it in the most efficient way, functional programming feels similarly lacking as you're describing in the robotics case. In my experience after "looking behind the curtain" for this kind of task where performance and low-level control is absolutely necessary, it's difficult to ignore all the inefficiencies which must exist in a more abstract system. But I'm not sure that's entirely justified.
- didibus 7y agoThis is true, but it depends which language we're talking about. There are two definitions to FP. The stricter one is about having immutable data and pure functions. In that one, it's fundamentally only a computing language, not a programming language, in that by definition it cannot tell the computer to perform any action, as purity implies no side effects. That means you always need an additional layer which then drives the side effect. For a lot of programs, that adds some complexity to the program. The programmer has to model their side effects with this layer in mind. The layer means the programmer loses control over the fine grained details of the side effect as well, which might hurt performance, or make certain things more difficult. That said, there are impure FP languages. Where you can program the machine to do whatever you want, and also make computation functionally with immutable data and pure functions. Clojure is such a language. I'm very biased towards it FYI, as it's the language I enjoy most as of now. But I think it's important to bring it up. Defaulting to immutable and pure computations, but letting you perform all kinds of controlled mutation and side effect really seems like a good future to me. Rust in a sense is pretty similar. While it doesn't use a strict functional sense of immutability and purity of data and functions. The borrow checker tracks all changes to data and assigns ownership of access, which is kind of similar to immutability and purity. Yet it lets you do unsafe things when required, often for interopping with peripherals and the machine itself. Erlang like you mentioned is another example of this. I think those languages might have a better future, and are slowly starting to pick up on popularity. Even in JS for example, lots of people are adopting this style. So if not a programming language, at least the paradigm seems to become more and more popular. As an aside, for example, there is a Clojure dialect called ferret https://ferret-lang.org/ https://ferret-lang.org/ which is designed for use on microcontrollers. It has immutable data structures and support all the functional aspects of Clojure, yet targets real time control applications.
- pritambarhate 7y agoI think languages by themselves rarely become popular. There is some killer feature that a language offers which makes a certain class of problems very easy to solve. For example, Rails did it for Ruby, Go's stdlib makes it very easy to write performant network services, Java's promise of platform-independent code, huge stdlib and a free compiler and (later) free IDEs when almost all other compilers and IDEs were paid, C# - Microsoft's deeply integrated ecosystem, Rust's memory safety and the promise of fearless concurrency. Functional languages are lacking such killer features which makes them 10x more productive for widely faced problems. I am learning Clojure to learn more about the functional paradigm, but I don't see any particular type of software that I could do with it which I couldn't achieve with Java, Go, JS or Python all of which I already know well enough.
- nilkn 7y agoI think you could argue that type-safe STM is such a feature for Haskell. It's something that I really miss when using threads or async essentially anywhere else. I would probably jump for Haskell over Rust as a result for heavily concurrent or multithreaded programs. Rust is memory safe, but it can't express purity and it can't enforce that STM transactions should be safely retryable. I would also argue that Elm offers close to a 10x factor for certain types of front-end web applications. It's a very closed system, which is a matter of great controversy, but in areas where you can exist within that system it is a dramatic leap forward compared to anything else in my experience. If you consider Erlang/Elixir functional languages, I would argue that BEAM can offer close to a 10x factor for certain types of distributed or concurrent applications as well. You mentioned Clojure, though, and I don't know what the killer 10x feature would be there.
- dnautics 7y agoI suggest trying elixir instead of clojure. Webdev is extremely productive in it. There's also a new reactive web framework called Phoenix liveview that's eye-poppingly powerful. (Yes you can do similar things with blazor but I promise you when something goes wrong with your blazor code you will have either a security regression or a hair tearing out session because it's relatively hard to grok what c# is doing under to hood to transform your code)
- deleted 7y ago
- jierenchen 7y agoWe should draw a distinction between FP as religion and FP as tool kit. FP as religion has failed to gain acceptance because it imposes too much cost on the user. I have to rethink my whole stack in terms of category theory AND deal with your terrible ecosystem? Hard pass. FP as toolkit, on the other hand, has been a smashing success. Most of the core ideas of FP are mainstream now and some of the latest advances in non-FP ecosystems (React, for example) are based on FP ideas.
- eru 7y agoFP ideas have been seeping into the mainstream for quite some time now. The oldest: GC was originally invented for Lisp. It's common now. Type inference was big in FP before it made the jump to language like Java or C++ much more recently. Generics were a natural idea in a typed FP context. Mainstream languages got them, now. I'm looking forward to algebraic data types becoming really common. (The simplest explanation is that they are C-style unions with tags to tell you which case you are in. The compiler enforces that the tags correspond to how you use them.) Some mainstream languages are starting to add them.
- jierenchen 7y ago> The oldest: GC was originally invented for Lisp. It's common now. LISP was so ahead of its time, its parents still haven't met yet. Not very FP, but another gem from SBCL: saving and restoring program state for later use. Now there's the CRIU [0] project for doing this with Linux and Docker containers. > I'm looking forward to algebraic data types becoming really common. I'm not too familiar with the full scope of algebraic data types. Wondering: does Typescript have this or is it still missing a few key components? Really like how it has Union types, which I wish Scala would have. [0] https://www.youtube.com/watch?v=LrHW7Vvbie4 https://www.youtube.com/watch?v=LrHW7Vvbie4
- eru 7y agoAlgebraic data structures mostly just means union types. (That's the + in the algebra. The * comes from bundling multiple values together, like in a tuple or in a C-style record, virtually all languages already have that.) There's also Generalized Algebraic Datatypes (GADT). They are a bit more complicated. So I don't expect mainstream languages to pick them up anytime soon. About GC: you _can_ do pure functional programming without a GC. But it requires lots of big guns from more advanced theory. (Mostly stuff like linear typing.) However imperative programming without a GC is comparatively simple. So it's no wonder that historically, GC was invented for FP first, and GC-free FP was only discovered later. (And for general CRUD or web programming, or basically anything outside of low level systems programming, GC is more productive in terms of programmer time than other approaches. At least given currently known techniques.)
- fulafel 7y agoI think in the current crop of languages, the "functional language" concept has shifted its purpouse: 1 GP languages have adopted FP enabling features, so we can do FP just fine in many mainstream languages, and it is infact very common (see eg React, Ramda popularity on frontend and many recent FP features in Kotlin, Java, C++, etc). 2 At the same time FP leaning languages are more popular than ever, to the point it would be ridiculous to claim "nobody uses functional languages" given the visible positions of Clojure, Erlang/Elixir, ReasonML/Ocaml, F#, Scala, etc on the scene. I think adding 1+2 together tells us that FP is on a real streak. People choose use FP langauges, not because of their capabilities, but because of the mindsets, ecosystems and culture they promote, along with promising to consistently pave the way for FP problem solving instead of often falling back to imperative.
- thu2111 7y ago(1) keeps cropping up but these new languages are hardly "FP" or even using "FP" features. I think we give FP research way too much credit. Pure functions? No, none of those languages can even express the concept except maybe C++ with the const keyword (which is as old as Haskell itself). Immutable data structures? Even very modern languages like Kotlin don't really have them. You can define a data structure where the fields are immutable after construction but it's not transitive. There are read only collections but not immutable collections, without doing extra work. Maybe immutable collections will turn up at some point, there's a proposal to add them, but it'll just be a library not a language feature. Type inference? New languages don't use full blown Hindley-Milner TI, they do much more limited TI that's designed to strike a balance between readable error messages, documented APIs, IDE performance and so on. Meanwhile the concept of TI is obvious and required no inspiration from anywhere - anyone who ever looked at source code will be struck by the repetition required. Generics? C++ templates started being discussed in 1985, and it's again a pretty obvious concept that would occur to anyone who wanted to offer type safe collections. I honestly can't see the huge impact FP supposedly had on mainstream programming. All the ideas its advocates try to claim for their own are either not used, or are obvious but usually not implemented the same way. My guess is if Haskell had never existed modern languages would look exactly the same.
- 7y ago
- threatofrain 7y agoI like framing FP and OO as technologies, and technology takes money and time to improve. The technological aspect comes from the ability of language and IDE teams to translate your programming style into an efficient program.
- RcouF1uZ4gsC 7y agoI think there is a fundamental reason. The computer is inherently mutable. As a result, the basic abstractions of operating systems are mutable. Thus, except for nicely contained problems such a text transformation (see Pandoc for an awesume use of Haskel), interfacing with the computer and the rest of the world becomes an impedence mismatch. Yes, monads are awesome, but you shouldn't need a math PhD, to print "Hello World" to the screen and understand what it is doing. The other issue is performance. Yes, performance is generally good enough, except when it is not, and when it is not, it is not obvious why you are having issues or what you can do to fix them. This once again comes to the abstraction mismatch between the mutable computer and the pure functional language.
- eru 7y agoModern CPUs re-order your instructions based on data dependencies. If you want to argue from the bare metal, that should count for something, or not? In any case, compilers are pretty good at making you not have to care too much at what goes on in the lowest level. (Unless you care eg about absolute speed. But then, an imperative-only understanding is not going to cut it either.)
- alipang 7y agoMonads are among the simplest abstractions you can find in computing. Compared to almost anything you need to understand in software development (how the hell do I make webpack do the thing I need?) they're ridiculously easy. The fact that so many devs are scared of monads and believe outrageously silly things like you need a math phd to understand them seems to be similar to being afraid of drinking dihydrogen monoxide. Even though it's only water, it has a complicated sounding scary name, so it must be bad.
- saagarjha 7y agoThere’s also a huge number of people who are fairly bad at explaining what exactly it is. I don’t think I should fault them, per se, it’s sort of trying to explain why water is wet.
- StreamBright 7y ago
- thdrdt 7y agoMy experience so far with functional languages (as an OOP-er): * After a whole evening studying I am able to subtract 1 from 5. * After spending hours checking what is wrong it just does not compile. * After the hello world part there are no libraries that can be used for web development. * Lack of good documentation. * Lack of good tutorials. But lately I discovered Elixir and I believe this could be a language that would change my mind about functional programming. Phoenix looks great and LiveView matches .NET Blazor (which I use a lot). But then there is still the question: why even bother using a functional language? Because I have little experience in functional languages this is hard to answer for me. Edit: "After a whole evening studying I am able to subtract 1 from 5." I should have formulated this different. What I meant was: sometimes you follow a very long tutorial about a functional language. You will learn a lot about the syntax but in the end when you try to use it, you will only get to the basics of writing a function that subtracts x from y.
- eru 7y agoWhich language did you try to come to terms with, and what material did you use? How much are you exaggerating?
- smabie 7y agoI dunno man, I don't think I believe you. After a whole evening of studying you can subtract 1 from 5?
- StreamBright 7y agoFunnily enough 5 - 1 works almost in every language the same way. Maybe with a different syntax but I cannot think about any FP language where I cannot do it.
- smabie 7y agoI mean Lisp. But It's pretty debatable whether Lisps are functional languages. Imo, static typing is a requirement, at least culturally.
- 7y ago
- randomsearch 7y agoConjecture: programming will become split between “just build my app” and an elite set of programmers who do the most demanding work, eg cloud infrastructure for Amazon, Google etc. The latter will mostly use FP, the former will use JS et al. I think the reason most coders (and I include myself) don’t use FP is that we don’t have enough training in it, we often don’t have a strong mathematical background, and we have an imperative mindset. It’s harder to learn those things, it’s a different way of thinking than we use in our day to day lives - much like mathematics is difficult for most people to grasp, because it doesn’t come naturally to them. Humans are not theorem provers. As competition for jobs soars and wages plummet (hello, remote work revolution!), more of the top X% of coders will be forced to learn FP to maintain their competitive advantage, and you’ll end up with a lot more people using it. Some of that will trickle down, but most of us will be writing JS rather than Haskell for the rest of our lives.
- pritambarhate 7y ago>> an elite set of programmers who do the most demanding work, eg cloud infrastructure for Amazon, Google etc. The latter will mostly use FP, the former will use JS et al. I don't think this is true. In fact Go seems to be at the front and center of most of the Cloud Native infrastructure projects such as Kubernetes, Docker, Prometheus, and many others.
- randomsearch 6y agoWasn't a comment on the status quo, but rather the future. I think the Go trend confirms my point: an isolated group of programmers have been able to adopt Go for that kind of infrastructure, but outside of those shops most people are quite determined never to use Go and rant about it a lot. In the same way, Go will be replaced by FP and app developers will not go near it.
- mrobot 7y agoJust a couple gripes, they seem like non-problems today: Training -- Schools should be covering the training problem in this PDF, and i think that would help a lot. Availability -- GHC is no longer an 'adventure' to install Packagability -- Can't you just build standalone programs with most FLs? Popularity -- Aren't they getting more popular? "They don't get it" -- I don't think the example given of "i need some documentation and stability" applies anymore.
- gerikson 7y ago> Training -- Schools should be covering the training problem in this PDF, and i think that would help a lot. This just raises a chicken-and-egg problem: why should schools (primary, secondary or tertiary) teach a language that is not "mainstream"? Is there a language that is more "functional" than Python or Lua that's designed to be a teaching language?
- carapace 7y agoFWIW if you're not using algebra to write your software you're not quite doing FP just yet. Doing math on software to make new software is the overlooked part of FP in my opinion. You hear about "first-class functions" and "referential transparency" a lot but not as much about "equational reasoning".