80 points · by jamesdco · 4y ago · 128 comments
My former mentor worked at a startup called Takt that billed itself as Haskell-only. It attracted all the top minds - Runar Bjarnason, who wrote a famous Scala book, worked there - and everyone was very eager to write Haskell code for a living.
The engineering team quickly went all-in on functional everything. Nix for package managers, a Haskell-to-JS transpiler for writing frontend code, immutable databases, the works. Because they eschewed all the boring technology that had been proven reliable over the years and only played with the bleeding edge in Haskell, they quickly ran into limitations of the ecosystem: performance degradations as they hit corner cases, missing functionality that needed to be patched upstream, corner cases that no tooling had existed to support it, etc. Before long, they were single-handedly supporting the broader Haskell ecosystem rather than spending cycles delivering on the business contracts they had.
This was all very fine with engineering - why not contribute upstream? Why not drive Haskell to broader adoption, which was in line with the company's values? - but management balked. They began to raise the possibility of maybe ditching their bespoke tooling and moving to something more standard. This didn't go down well - it caused a schism, where half the engineering team felt the right way forward was to double-down on the existing nascent Haskell technology and offer more support and training, and the others who just wanted to get stuff done.
Anyway, the startup failed. Turns out, when you hire for people who really believe in a programming language, you can occasionally attract zealots.
We have
- "beautiful" code by zealots (who left) that has terrible performance. I've done two refactorings that bring > 100x performance increase.
- code by latecomers that misses the points of FP semantics and is subtly wrong.
- horrible compilation speed, therefore time-to-test, from heavy use of advanced features that add little value. The long feedback loop hurts not only productivity, also morale.
And since the interview process is imprecise the point of being broken, it's very useful to attract the right people in the first place.
> From a business perspective, any language is arbitrary.
Counterpoint: And then when the company starts growing quickly and has to hire 10 Haskell devs in 12 months, they realize its pretty much impossible to do without shelling out $200k/person.
Functional languages do appear to attract smart people, but I see far more people with an interest in the language than actual jobs out there. They seem more geared towards compute science (more theoretical) over software engineering (solving real world problems).
https://hitchhikers.fandom.com/wiki/Golgafrinchan_Ark_Fleet_...
TBH if you are building something boring you should just use Spring w/Java or Kotlin. This will attract pragmatists that ship code that works in ways that anyone else that works with these tools will instantly understand also. In a way it attracts mediocrity but in the good way where you get nice standard code that can be maintained cheaply for a long time and it's easy to hire for the skillset.
If you are prototyping extremely quickly then maybe Ruby on Rails might be the right tool for the job (and thus attract the right kind of people).
Go attracts mediocrity and not in a good way, it also actively repels the "right " people if you want to hire for highest intellectual horsepower for a given budget.
In the same category as Haskell you also have OCaml, the Lisps (Clojure in particular) and Erlang all of which will yield you lots of the "right" people. None of these people will be cheap but none of the good people that write the other languages are cheap either, however there is a strong correlation between interest and proficiency in these languages and high intellectual horsepower - hence "right" in this context.
I worked on a Scala team for a couple years, had a lot of devs that were “smart”, problem was they wrote really fancy code no one could understand.
I then switched to a Go team and it was night and day. I was wildly more productive and the people in the community were not lacking intelligence.
Go prioritizes community, it believes that “us” is more impactful than “me”. This is its biggest strength, and is often lost on people looking in from the outside.
Yes, if you choose Haskell, a Lisp, or something like Erlang, you can get smarter/better devs. But the flip side of that is that the types of people who tend to gravitate toward those languages are often more interested in programming for it's own sake and not the domain they're working in. So you get things like people burning hours writing their own libraries and endless tinkering with programming minutiae instead of getting sh* done.
On the other hand, a mediocre programmer who taught themselves Python, may not be winning any programming competitions, but will often have significant domain expertise and a bias toward getting things done.
You need to ask yourself whether or not the stuff you're working on really demands the absolute best programmers (it very rarely does). If it does, go with the Erlang/Haskell/Lisp crew, otherwise go with the Python/JS/Go crew.
Except, you know, in the browser...
This is painting with a pretty broad brush. I like Haskell (and first learned it before it was cool, in the early 2000s), but I also enjoy coding in Go. Not everyone is strongly driven by choice of programming language in their job search. If you do hire someone who desperately wants to write Haskell code, you might find that they spend more time tinkering with advanced Haskell features than they do adding business value.
I am puzzled by this because my early experience of Ruby On Rails (and I mean early -- 2005) is that every Rails developer I encountered knew much less than they were letting on.
> Go attracts mediocrity and not in a good way, it also actively repels the "right " people if you want to hire for highest intellectual horsepower for a given budget.
I really think this needs backing up with at the very least a juicy horror story! I'm not convinced by this at all.
edit: ps: Big fan of OCaml, but have since moved on to Go and Python for getting things done in the real world.
JS is one of the most successful programming languages in history. Millions of JS programmers solve real world problems every single day. It might not be the right tool for you of course but that has nothing to do with JS itself.
If Spring basically "fixed" java development...
Why hasn't it been ported to Go? Wouldn't it fix the same problems there?
Spring boot is garbage to be
I’ll come out and say it though: Haskell is a cult. It’s best to smile and nod when you’re around the believers. They’re harmless. Ditto for rust.
It is truly astonishing how much code a determined team of haskellers can produce. I’ve been porting a codebase, line by line, to python. I’m up to 15 thousand lines.
Had to do it without being able to run the program too.
There are lots of benefits. (Ditto for being in a cult.) It’s worth knowing what they are, since they are powerful. But (hello cult) there are plenty of negatives; monads are the Aristotle philosophy equivalent of programming. Take care not to study them too closely.
Monads is just a pattern for composing functions that can’t be composed using “normal” function composition (because of incompatible types). That’s all it is. I never understood the fetishisation/worship of monads in the Haskell community.
What does the lines of code have to do with Haskell? Specifically, why did you feel this was important information? What you wrote is almost a non sequitur. That Haskell programmers are efficient and the fact that your port of a Haskell code base to python has reached 15KLOC are two completely orthogonal pieces of information.
You probably didn't have to do it without running the program.
Breaking down the benefits of each:
- Expressive: you can model things with greater fidelity
- Pure: you know when your code performs side effects, so you're in for fewer surprises
- Statically typed: you learn about things at compile time, not in production. You also need to write fewer tests.
- Large pkg registry: fewer things to implement yourself (compared to, say, Idris)
- Large community: fewer problems you'll be the first one to discover/solve
- Optimized enough compiler: compile times can be _acceptable_
- Optimized enough runtime: your app will be fast enough without you having to care much about it
Now one point that isn't obvious from all this and that is a big selling point for my company is how much of a breeze refactoring is. Types give you more guarantees around how your code behaves, so there's classes of mistakes you can't make, and won't have to rely on a super strict test suite to prevent you from making.
Newhire submitting a PR changing 25 files all over the codebase? Business as usual.
Take a vector package, for example. It provides you with unboxed vectors that are structure-of-arrays by default with the interface of array-of-structures. That means you can have fast slicing operations in both dimensions - slice by field and/or by indices. Of course you can have unboxed array-of-structure arrays, if you need them, they are there too. But their use is transparent to you as user, however your choice is.
Same is for other interesting structures.
Say you wrote your parsing library. You can provide a rule to compiler such that code "(pchar c `pthen` p1) <|> (pchar c `pthen` p2)" is equivalent to "pchar c `pthen` (p1 <|> p2)" and you get left factorization for all your grammars supported by compiler.
Parallelization is often as far away as adding a par/pseq annotation.
Haskell can remove intermediate lists and fuse mapping over complex structures such as red-black trees - it is done for all of your code so when you do "fmap f (fmap g) rbTree" you will get "fmap (f . g) rbTree" and compiler will try to get you that code by transforming your code where "fmap f" can be pretty far away from "fmap g rbTree".
The pattern matching checks are awesome - compiler will warn you if you wrote more general check before more specific one. The absence of this in C++ made my life a little bit more interesting than is comfortable for me.
In short, most of the time you can write code however you want or need and compiler will support you. As if you are "team programming" with a bunch of smart people - the compiler's authors.
Functional programming allows a great deal of confidence in your code,
Sorry for being off topic: the new M1 Macs seem to take some of the pain out of large runtimes for compile/build in languages like Haskell and Swift. I don’t have any benchmarks, this is just very noticeable when I am coding.
If not, can you share a link? Thanks!
How "far "off" is it, in terms of correctness, compared to other, more conventional statically typed languages like C++ or Java or Rust?
As long as take advantage of the type system, the compiler tends to permit far fewer programs that compile, but do the wrong thing, than is the case in C++/Java. You will notice you spend more time editing code to make it compile, and less time debugging code that does compile.
Rust should not be grouped with C++ or Java, as its type system is essentially that of Haskell with the addition of lifetimes. The developer experience is similar in that you tend to spend more time getting code to compile, and less time debugging.
I chose Haskell to develop sumi.news because I enjoy programming in it, and because I don't want to worry about type errors and crashes at runtime.
> Does it offer any actual practical benefits over other languages?
Haskell offers a more expressive type system than other languages.
There were some practical reasons for this, but at the end of the day: if you're going to spend thousands of hours developing something, you might as well choose a language that you find beautiful and enjoy working in.
* embedded DSL for describing things with minimal syntax * types to enforce my invariants * immutable data + STM to protect my shared data structures * multithreaded/async code is easy to work with * deterministic outputs given inputs
but it was headaches in a lot of ways:
* exceptions - still not sure I’ve handled all exceptions gracefully * culture - most teammates are intimidated by Haskell (and types) * ecosystem is behind (Rust has exponential usb acceleration vs Haskell’s constant pace)
While I’m proud of the outcome I would have chosen differently now that I’ve seen the other side and have the project done. The inertia I was fighting required far too much energy
Actually ImplicitCAD is written in Haskell which implements CSG (very tricky to efficiently implement)
Haskell is fast, compiled, type safe, memory optimized, allows concurrency and parallelism. The use cases where you'll see using Haskell will generally be companies like financial sector where very fast and error free execution directly translates to making more money, e.g. dark pool front running trading algorithms. Generally you don't hear it extolled because of who is using it and the secrecy around what it's being used for, e.g. competitive advantage.
Outside of that you'll probably only see it in academia because of a lot of the reasons listed in the replies. In my opinion its a harder language to learn because it really is just lambda calculus translated to a programming language.
It offers less and less practical benefits over other languages because other languages evolve to where Haskell has been.
Haskell is correct, and it forces you to be correct and enforces a kind of clarity of thought that is seldom required from other languages. I think it's something you have to discover for yourself. If you don't see Typescript as strictly better than Javascript, you're probably not going to see the benefits of Haskell over any other language.
All that said, we have to ask ourselves which areas of computing Haskell can be profitably used in to gain the kind of critical mass that other languages have:
- Early programming, analysis, data science, etc -> Python is a better fit because it's easier to pick up, easier to understand, even though it's less correct. People discover libraries about checking types at runtime before they discover then can check them at compile time. Python has long since started it's evolution w/ the typing module.
- Web -> JS, because it's basically the only option. Projects like Elm and Purescript have made small dents, but the most successful cultural descendant of Haskell (if you can call it that) is Typescript.
- Startups -> Ruby/Rails, Django, NestJS, etc. win over Haskell here because you don't need to be right to have a successful startup, you need to find customers and after that product-market fit. Your startup could be airflow+google sheets with all-manual validation and still succeed over the most carefully crafted and bullet proof Haskell code.
- Safety critical systems -> Often are required to be realtime and it's easier to get to the safety requirements in other low level languages with strict procedure/process/standards and guaranteed realtime-capable OSes and tooling rather than using Haskell.
I've written about Haskell in the past (excuse the title):
Binary size is small..
And very important to me they could be executed even years after they were first uploaded to Rosetta code.
A very good study and the researches gave an entertaining talk on it, that I can't find now.
It sure does. Perhaps you should try it?
The tone of the original question reads to me as though the asker is asking to be convinced by evangelists to give the technology a chance. Ultimately though, just listing technical benefits of the language is unlikely to be as effective as one might rationally expect, given that humans — which certainly includes programmers — are less rational than they would like to admit.