156 points · by azhenley · 6y ago · 264 comments
It's not that haskell doesn't have merits. However I feel like they are oversold. While you can build programs that lack certain error classes, they are not bug free and at the same time debugging often was a lot harder than in other languages. The laziness is especially problematic in that regard.
Another problem is cultural. Haskell and Scala community have been the most hostile communities I have experienced. And the friendliness of communities is a sure predictor for growth.
Another important problem is the docs. For some reasons they hardly contain examples. You don't get adoption that way. Even if the maintainers feel that the type signatures are documentation enough.
And as a last remark, the combinatoric complexity of compiler flags is a problem and needs to be fixed. But the ecosystem is in a deadlock there that no compromise could be found on what should be in the language and what shouldn't be. And it kind of indicates a deeper problem in the haskell design process.
My biggest complaints are 1) the lack of good libraries, and 2) the apalling state of documentation for the few that exist. Too many Haskell projects read like "I figured out this neat family of types for thinking about X - at last URL parsing is provably safe - now you figure out the rest".
Let's take a practical example: HTTP requests. If I'm a budding JavaScript developer, or Kotlin developer, or Python developer, I can read through copious search results and tutorials on Axios / OkHttp / Requests / delete as appropriate. These tutorials not only walk me through the common use cases but also show me their APIs in the context of the new and alien syntax of the language I'm grappling with. They give me enough template code that I can use an incomplete understanding of whatever language it is I'm learning to figure out the rest without recourse to a textbook.
What does Haskell have? It has Req (and a bunch of other also rans), and the docs for Req are atrocious, spanning a staggering 1 (one) example and then a meandering essay on the deficiency of other Haskell HTTP clients. It's not good enough.
And that's my assessment of Haskell as a whole - not the language individually, which is expressive and powerful and inspired - but the whole ecosystem around Haskell that feels like a set of beta projects and hobby repositories generally developed by interested individuals rather than commercial endeavours.
Or look at the paltry state of IDE support. It's 2020 and the best option we have is VSCode with HIE, which rapidly spirals out of control allocating memory, randomly crashes and on Windows just refuses to even start half the time. Without this tooling a lot of the theoretical benefit of the type system is being lost. This is low hanging fruit but there's been no incentive to pick it.
And so I've made the difficult decision to leave Haskell behind. If you need typed functional programming, your options are OCaml, Scala, F# or even subsets of Rust and TypeScript. Haskell is a great learning experience but totally unproductive right now.
I learned Rust in 2016, and have kept up with it since. It was a painful first entry point, and then another rather painful experience when I first used it for a big hobby project, but now it is my go-to language because it's exactly as hard as it needs to be, has amazing community and documentation and libraries, and gives me the option to have really good performance while also using very nice ML-family linguistic constructs.
Well begin is half done, and Python and Ruby made it so easy to program that without reading multiple of books and spending a year or two, programmers can write decent code. This is the reason why Go and Swift the other two system programming language is far ahead of Rust despite being GC language. Indeed even the latest OS Fuschia is written in C++ (zircon kernel), with Rust SDK to write high level programs same as the one written with Dart and flutter.
It is. The way you usually resolve that problem if your language is going to become a big mainstream success is to have a particular focus, one key selling point where it is uniquely capable or at least so far ahead of the opposition that using it is a compelling advantage. JavaScript was the language for writing front-end code. C was the language for low-level programming. Java was the language for getting code monkey class programmers to be reasonably productive in enterprise environments. There are now other languages in each category, and there are now other uses for each of these languages, but the important point remains: those languages dominated those niches at the time they took off and that was why they took off.
Unfortunately for Haskell, a sophisticated type system and compiler capable of supporting experimental language design research is a niche that about 0.0001% of developers and people who pay developers care about. Haskell has indeed been very successful in that small niche, and it remains so. But I had a look into it the other day from the point of view of implementing the back-end for a new web project, and its support for writing web servers is still probably a decade behind the state of the art. I swallowed my pride and today that back end runs on Node. Would I prefer Haskell's safety and power over JS? Of course. But I'd prefer a language where any server I wrote can speak modern web protocols and support the functionality I need, and of those two languages, only one clears that bar.
So for example, just use http-client instead of req. Use postgres-simple or persistent instead of beam, etc...
For HTTP request library, most would recommend Wreq. Being most popular, the documentation is really good I might say with most used API have their own example [1]. You can also easily find great tutorial on the net, like http://www.serpentine.com/wreq/tutorial.html for example. Honestly I never use Req myself and looking at the documentation myself, even though I don't it's lacking, I think it's not really geared toward Haskell beginners so maybe you have a point there.
As a novice Haskell programer who only use it for side projects, I don't think the documentation is that bad and it's only getting better. Most popular libraries like database clients and web frameworks have intensive documentation and tutorial nowadays.
I agree with you for the state of IDE support, it leaves something to be desired. But people are still working on it[2]. For now I mostly use vim with help of linter and formatter. The great thing about good type system is, you can still do much even without great IDE support. Haskell already have working and great REPL support that make development a breeze so it helped. I'll still take Haskell over OCaml or Scala anyday. Rust is great and I love it so much that it's my go to language for something system programming or networking related, but I don't think it's a good match if you want to learn functional programming.
[1] https://hackage.haskell.org/package/wreq-0.5.3.2/docs/Networ...
And don't forget D. It's surprisingly well-suited for FP as its effects system has explicit support for pure functions and specifying a function is guaranteed not to throw, in addition to support for true (transitive) immutability. Not to mention full first-class function support, with lexical closures.
There's at least https://plugins.jetbrains.com/plugin/8258-intellij-haskell that is as simple for newcomers to setup as it can be.
Maybe my needs are limited but I rarely need something more than the GET and POST json examples there.
To elaborate further, some of the most upsetting conversations I’ve had with Haskellers revolved around simple things like exceptions and logging. Issues would consistently turn into a matter of personal intelligence, and proving oneself correct. It is insane. We are just trying to build things here. These are very boring implementation issues that just need to get done.
It read like a series of math equations, with frequent single letter variable names.
It was concise and elegant in it's own way, but hard to follow in some cases due the lack of readable variable names.
I like the language but this cultural aspect made it harder to get up to speed and contribute.
> We are just trying to build things here.
Some languages are built to do engineering first-and-foremost. Languages like Haskell are built to do mathematics in first-and-foremost. This doesn't mean that such languages aren't also well-engineered, or that they aren't also tuned to do engineering in; but the engineering concerns must be subordinated to not breaking the model that mathematicians rely upon to do math in the language. So you can't just e.g. change whether a particular kind of function can emit IO or not; or change what values exist as part of the lattice of a type; or any number of other things visible within the language's abstraction; because those very properties/constraints are also syllogisms which are relied upon in mathematics done in the language.
And before you say "why not just break the runtime model", by e.g. having special debug functions that can do IO while presenting to the runtime as pure functions—well, it's not impossible, in theory, but it's a Hard Problem, because those properties that a function presents to the runtime are also used by the compiler to optimize (or memoize, or fuse, or eliminate) code. You can't really declare something as a pure function without the runtime thinking it can do all sorts of things that result in the function being called less.
In theory, Haskell could have something like a "volatile" qualifier for functions, sort of like C's volatile qualifier for data, to tell the runtime that while the function has type X, all optimization opportunities that would normally apply to type X are off the table. Then you could have special debug functions of type X. It's just that getting this working would require a lot of re-work throughout the compiler, since the compiler mostly deduces optimization opportunities from the type (and marks something as having more optimization opportunities by proving that it has an extra applicable type), rather than just tracking some separate metadata that can be arbitrarily written to.
> And before you say "why not just break the runtime model", by e.g. having special debug functions that can do IO while presenting to the runtime as pure functions—well, it's not impossible, in theory, but it's a Hard Problem.
import Debug.Trace
square x =
trace "I'm a Hard Problem" (x * x)
main =
print (square 3)It's hard for me to find a reasonable interpretation of this sentence that is true. I'm not sure much serious mathematics is done is Haskell, beyond the usual arithmetic operations present in most programs, especially relative to other programming languages. It hasn't taken off in the numerical computating market, for example.
Historically, it also seems like Haskell was built as a research language.
foo :: IO X
Haskell already has that, it just shoves the compiler re-work off on the programmer.This is not the first time I have seen this claim, but it's so much in contrast with my experience that I don't know what to think.
There seems to be some cliques of Haskell developers on mostly non-communicating communities. I would imagine they self-select but I have actually only encountered any hostility on Stack Overflow, and the Haskell part of it, besides being business as usual for the site, also is a mostly useless knowledge base (to the point that I remove the site from searches to decrease the noise).
O yeah, I totally forgot that. There is a very senior guy on SO who literally helped to fix all our non-trivial problems. I still need to investigate if we could move from Elm to Elmish (or more like SAFE).
Although there have been heated public disagreements, I haven't seen the people trying to destroy one another. They just have very strong disagreements. That doesn't bother me directly since I'm not in those discussions. The most I can say is that the lack of unity means there is a shortage of "best practice" of how to do certain things and lower community focus in advancing the ecosystem.
A common workflow for Haskellers is to specify type signatures and interactively edit until the compiler is satisfied. Often, the code gives you correct results on the first try.
This means the type signatures aren't simply documentation, they also strongly direct your implementation. The problem from a marketing and adoption standpoint is that this isn't visible until you've hopped into a REPL or IDE and tried it yourself.
This is a common counter-argument. It is a true statement. And, in the nicest possible way, it is also completely missing the point.
When you're playing with cute mathematical code and almost everything is written in terms of totally generic types, it's cute that you get free theorems and automatic derivations of some basic functions and all that stuff.
However, in the real world, 99% of the time we work with concrete types to get concrete work done, and there are going to be many possible implementations of a function of type Int -> Int, or MyDataStructure -> MyDataStructure -> MyDataStructure, or SomeWrapper SomeType -> (SomeType -> SomeOtherType) -> (SomeType -> SomeOtherType) -> SomeWrapper SomeOtherType. This remains true notwithstanding the possibility that some of that cute generic code was used to implement various small parts of the function you actually care about if you dig down far enough.
This means the type signatures aren't simply documentation, they also strongly direct your implementation. The problem from a marketing and adoption standpoint is that this isn't visible until you've hopped into a REPL or IDE and tried it yourself.
I would argue that the problem from a marketing and adoption standpoint is that it still isn't visible even if you do do those things, unless you're interested in writing heavily mathematical generic code rather than completing the job your boss told you to do within a reasonable timeframe.
Yes, kind of.
> When you're playing with cute mathematical code and almost everything is written in terms of totally generic types, it's cute that you get free theorems and automatic derivations of some basic functions and all that stuff.
It's not only "cute" as you so reductively put it. There are real world benefits.
> However, in the real world, 99% of the time we work with concrete types to get concrete work done, and there are going to be many possible implementations of a function of type Int -> Int, or MyDataStructure -> MyDataStructure -> MyDataStructure, or SomeWrapper SomeType -> (SomeType -> SomeOtherType) -> (SomeType -> SomeOtherType) -> SomeWrapper SomeOtherType. This remains true notwithstanding the possibility that some of that cute generic code was used to implement various small parts of the function you actually care about if you dig down far enough.
That presumes an arguably wrong method of developing software that needlessly eschews understanding and correctness confused for superior economic choices, finally resulting in "real world programming".
But, on the gripping hand, using types unspecific enough that that is the case is often a sign of underusing the type system. E.g., very few domains actually deal with bare numbers as domain values, and when you express concrete types specific enough, there may be more than one possible correct function, Bru very often the one actually correct function will be much more obvious, and the mistakes possible by omitting a step when using less-robust sets of types become impossible because you effectively have statically verified dimensional analysis.
That does not square with the constant complaints about insufficient documentation.
It also does not matter if there's only one or two valid ways to call a function if the programmer can't figure out how to do it.
None of what you wrote contradicts that examples could be given in the docs.
But defending the lack of documentation kind of shows why haskell will not see much adoption.
Also, rust for example is much more rich when it comes to examples in docs and rust people could also argue to not provide docs because of type signatures. They just decide to provide documentation and succeed in attracting people.
In terms of reducing development time or cost, reducing defects, improving design, or really improving any business outcomes whatsoever, Haskell showed no success, only failure.
How could that be in contrast to “ugly” and “complex” languages like Java and C++, or free for all languages like Python and Node js?
The reason is simple:
1. imperative structure is actually clearer and easier to understand, easily amenable to all the upsides of function-oriented programming with far fewer downsides.
2. removing whole categories of bugs through compilation and type system patterns is a hugely overrated waste of time. Lightweight unit tests get you 99% of the way there with far less rigid design commitment
3. safety and correctness are resources just like memory or runtime complexity, not absolutes. Being able to tradeoff safety against other concerns, at a moment’s notice, deep in the guts of a large system, is one of the most critical requirements of business software
4. Premature abstraction costs you way more in pure functional languages than most other imperative or OO situations.
Are you referring to language extensions? This is sooooo off-base if so.
I don't see how people can bemoan Haskell's complexity but love a language like Kotlin which has its hodgepodge of function call semantics. Talk about complexity without any sane ground. It's so hacked together. At least with Haskell everything is very simple in isolation and composes for the most part.
--
Also re:examples.. I'd say Haskell libraries have better examples than the average Go library for instance. Many have entire modules whose entire existence is for putting examples & tutorials in the haddocks themselves.
One of a few possible explanations: they are mobile app devs who simply want to get things done, instead of hacking the toolchain (including myself).
Sure I'd love be able to write Android apps in Haskell. What's the easiest way to do it?
With Kotlin, it's already nicely packaged in Android Studio. Very convenient.
* https://github.com/ElvishJerricco/reflex-project-skeleton
* https://github.com/reflex-frp/reflex-platform/blob/develop/d...
I do appreciate the tooling around Kotlin. Definitely wish we had more time and money available in Haskell to match it.
Still doesn't explain enterprise use of Kotlin on the backend lol.
From my limited experience I agree that debugging a bug that passes compilation is more difficult than on other platforms.
How come I never seem to have this problem. I mean one scala dick (who wasn't actually so bad after a while) but that's it.
> Thus, instead of our discourse being about semantics, engineering quality, and implementation, we instead discuss our tools in terms of social factors and emotions (i.e. it “feels readable”, “feels usable”, “feels fast”).
Thinking about readability or usability as emotions and social factors, rather than as first level concerns, is a non starter to me, and I find it extremely off putting that the author seems to pile up those qualities in the marketing "group", as if they were not real properties of a language.
You can design a drill in a way that makes it the most scientifically correct at using the power it's supplied efficiently, but if the design hurts the users hands and requires months of training to operate, any worker will throw it in the trash, because they can drill things just fine with a regular tool.
(I'm not necessarily saying that Haskell is that drill, just saying that usability should never be treated with condescension when you're designing tools).
Many of us found imperative (and other non-mathy) programming styles immediately easier to understand, regardless. Me, I have to translate mathematical statements into "programmy" style to have a hope of understanding it ("OK so what does this term/operation 'do' in isolation?") and keep a crib sheet handy for WTF all the single-character bits (so, usually all of it) mean.
[EDIT] my point being, that preference doesn't seem especially "emotional" to me.
Sure and some people like it some hate it (according to western popular culture most people hate it). Also even if someone loves doing school algebra if no one tells them that you can write code that way they'll never know. If you only expose them to imperative Hello World code then of course they'll relate to that. Conditioning, familiarity and experience matter a lot.
> Many of us found imperative ... programming styles immediately easier
Immediately as-in you've been shown an imperative and a declarative Hello World and related to the former? Or you've only been shown the former? See my earlier point.
> I have to translate mathematical statements into "programmy" style
Same point as above. I did that as well for ages in the past, now I have to do the opposite.
> my point being, that preference doesn't seem especially "emotional" to me.
Maybe emotional is indeed the wrong word. But it's definitely not logical either and I'd also say it's not inherent, ie. people can change (I know I did) but at that point we'll dive into nature vs. nurture and that never ends :)
So it isn't that those things aren't important; just that they are subjective
What those features are, rather than subjective, it's contextual, and I feel that behind the author's phrase might lie the usual complain by functional programmers that non-functional languages just feel foreign because people are usually taught other styles during their learning process.
As an explanation, that might be partly true, but it being true doesn't really save you from the fact that if you want people to use your tool, you have to make it easily usable, and usable for real world people rather than for spherical cows.
Do we have any objective metrics? The only thing I can think of is all the (inconclusive) studies about error density. Unfortunately error density is a very far cry from measuring the overall quality of a software product, or the mental effort that was required to produce it, or the mental effort required to maintain it.
> there are thousands of people whose job is precisely optimising usability for many products
Yeah but programming languages are more abstract; they're tools of thought (just like mathematical objects), and optimizing their use is nothing like observing a user press the buttons on a machine to get themselves a cup of coffee.
Controlled studies are very difficult to run, for obvious reasons. (Unlike for the coffee machine)
I'd contend that the immutability of containers and why Docker is such a win might be getting Haskell to its moment.
For me, the hardest unlearning piece isn't the syntax.
Rather, the impact of the purity on the execution model is the stumbling block.
Monads seem arcane because laziness + purity = statelessness, which never really had tangible meaning until the idea that a Docker image is also stateless came along.
Maybe some cruder, crayon-level examples can be devised to help us slow folk get there.
+ a win for cloud when combined with kube to understand exactly what's being exposed
haskell isn't simple or understandable
it's flexible but I have no idea what's happening where
effects are getting folded in from all over the codebase
all the type abstractions are for injecting code from somewhere else
1) https://www.reddit.com/r/ocaml/comments/3ifwe9/what_are_ocam... 2) https://www.reddit.com/r/ocaml/comments/e7g4nb/haskell_vs_oc...
Yes, the Haskell community hates that guy and considers him a troll. But he does functional programming professionally as part of a private consultancy and wrote a book on OCaml. If anyone's equipped to understand what's wrong with Haskell, it's him.
Haskell has had 30 years to get its act together. Any benefits it has are drowned out by a sea of buggy tooling and accidental complexity (monads, etc.).
Ask yourself this: if there are literally billions of dollars in industry riding on writing efficient and correct software, and Haskell is such an obvious productivity win, why does it have a market share that rounds to zero?
Time to move on.
The young economist looks down and sees a $20 bill on the street and says, “Hey, look a twenty-dollar bill!”
Without even looking, his older and wiser colleague replies, “Nonsense. If there had been a twenty-dollar lying on the street, someone would have already picked it up by now.”
Industry makes collective bad engineering decisions all the time, usually driven by secondary factors like institutional momentum or hiring constraints. Did you read the article? It talked about a bunch of things like that.
If you equate market cap with quality, then Java is probably the best language of all time.
> wrote a book on OCaml
I find it hard to believe that anyone who’s really used both prefers OCaml over Haskell. OCaml is nice compared to most crap, but as someone who’s spent years working with both, Haskell wins almost every time.
It’s interesting, actually - I don’t know anyone who’s used Haskell and doesn’t like it. Almost everyone who vocally complains about it hasn’t really used it.
Reading that guy’s reddit posts, I have to conclude he’s some kind of troll - most of the things he criticizes Haskell for are way worse in OCaml, or just completely disconnected from reality.
I've actually used Haskell, Ocaml and Purescript for several years and a lot of locs, and I actually like Ocaml better. Reasons:
- The module system -- a very intuitive way to structure code
- Poly variants
- Strictness -- predictable performance and easy debugging
- Allowing side effects
- Private types -- better than newtypes imo since you can upcast to it's structural counterpart
- Really good type inference -- you never have to write type signatures. Haskell and Purescript type inference is ok-ish and sometimes craps out, which is part of why type signatures for each function is recommended.
- Stupidly fast compiler -- yes it matters, try contributing to the Idris codebase. It's like trying to contribute to the linux kernel, you'll wait 30+ minutes for it to compile.
- Very fast programs
- An actual package manager (stack uninstall?)
It is an overall better experience for me. And the language features that are coming down the pipeline are looking great:
- Modular implicits - a more sound ad hoc polymorphism system than typeclasses. Typeclasses can't handle simple things like if half of the Haskell ecosystem uses one Filterable typeclass and the other half uses a different Filterable.
- Algebraic effects - a strongly typed system for writing effects that will be part of multicore -- delimited continuations / conditions and restarts
These days I'm more interested in Erlang/Elixir though. I just don't think static typing is all that after having spent so much time with Haskell/Purescript/Idris/Ocaml. There are really nice benefits you get with dynamic typing that you don't with static, and there are better ways to deal with those problems that won't be noticeably worse in most business applications with just a little bit of coding discipline, such as good testing habits and having good fault tolerance built into the language.
I do like Haskell though, it's definitely really fun to program in. It's just not something I'd use for anything. If I really needed something with strong static typing I'd either go with Ocaml or Idris.
- The module system -- a very intuitive way to structure code
I see the module system used two ways in production - one is for trivial code-sharing, like to generate Map submodules. The other is for completely incomprehensible nonsense that makes it nearly impossible to find the actual definition of the thing you want. I find typeclasses easier and more ergonomic to use for both the trivial cases (like maps) and complex cases (like json codec generation, for which OCaml still uses the rough equivalent of the basically-deprecated Template Haskell).
- Poly variants
I agree, this is nice.
- Strictness -- predictable performance and easy debugging
I’ve always found this complaint overrated. Sure, it’s slightly annoying sometimes, but surely worth the language-wide discipline that comes with it.
- Allowing side effects
This substantially lowers the quality of production OCaml code compared to Haskell. Tons more spaghetti code, tons of global variables, etc etc.
Obviously purity is kind of a religious argument at this point, but in practice I have observed that it’s a liability.
- Private types -- better than newtypes imo since you can upcast to it's structural counterpart
I’ve never seen this in production. I had to look it up. Indeed, the first article is a blog post along the lines of “why is this useful”?
Haskell also supports casting newtypes via Coercible.
- Really good type inference -- you never have to write type signatures. Haskell and Purescript type inference is ok-ish and sometimes craps out, which is part of why type signatures for each function is recommended.
Haskell type declarations are usually only required with extensions. All OCaml style guides recommend writing type declarations in mli files anyway. The OCaml type system can occasionally infer things more easily because it’s so much weaker - cf the value restriction, no HKTs, etc.
- Stupidly fast compiler -- yes it matters, try contributing to the Idris codebase. It's like trying to contribute to the linux kernel, you'll wait 30+ minutes for it to compile.
Based on my coworkers who do performance optimization on OCaml code, it’s probably because the compiler isn’t optimizing much. But I don’t know much about that first hand. Also, have you tried GHCID or similar? Makes Haskell compilation very fast while developing.
- Very fast programs
Not an advantage over Haskell. They fare similarly in contrived competitions, and I have some suspicions that it’s easier to make Haskell code faster in practice. Some of the shit we do for speed in OCaml is very ugly. OCaml also suffers from very poor GC latencies compared to Haskell. I’ve seen multiple-minute(!) GC pauses in OCaml programs with a few dozen gigs of allocated memory. Never seen anything even close to that with Haskell.
- An actual package manager (stack uninstall?)
I guess I don’t appreciate the benefit of this over the stack model of tightly versioned automatic dependency resolution. Can you expand on some benefits?
- Modular implicits - a more sound ad hoc polymorphism system than typeclasses. Typeclasses can't handle simple things like if half of the Haskell ecosystem uses one Filterable typeclass and the other half uses a different Filterable.
That is by design and seems good to me. Why the hell would I want there to be two different Filterable typeclasses?
The ergonomics of MI remain to be seen but I suspect they will still be more annoying than compiler-resolved typeclasses.
- Algebraic effects - a strongly typed system for writing effects that will be part of multicore -- delimited continuations / conditions and restarts
This is basically vaporware at the moment. I agree it sounds nice, but I have no reason to believe we’ll see it in production in the next decade, and if we do it will probably look a lot more constrained than the idealized model people talk about.
Haskell proponents vastly underestimate the importance of stability to industrial users. Java provides some very strict promises about backwards compatibility that make it very attractive if you’re going to write a service and maintain it for decades.
Also, unlike Haskell, I can hire a huge number of Java devs, at a reasonable rate. My company alone would probably double industrial Haskell usage if we were to use it, making hiring a serious challenge.
So yes, for metrics that businesses care about, Java might be the best language around.
Well, one reason we might get stuck on a “suboptimal” language is network effects outside of the criteria we use to compare languages: what language does an organization already have experience with, does the (only) current compiler support the target hardware and system, it’s to late now to write the Linux kernel in Haskell, etc.
However, I agree with you. Despite the time I’ve invested in learning Haskell, I’ve personally decided to spend my time developing in other languages. If Haskell is the magic wand right there in front of us that will give us programs without flaws, how come almost nobody has picked it up and shown us working programs that took less development effort and fewer flaws.
We could compare John Wiegley’s ledger (C++) to the similar hledger (Haskell), but hledger isn’t the same program as ledger it has different features, I have no idea how long it took to write, how many flaws it has versus the original, how different the developer skills were, how much time and defects were saved by it being a redesign, etc. And these are small single developer efforts (now with numerous contributors). From everything I can gather, they are both excellent. So in this case there is no compelling advantage demonstrated for Haskell, and this supports your point.
Are there any theoretical barriers to writing algorithms in a pure and lazy language with the same space/time complexity as a side-effectful and strict language? I suppose quicksort (also mentioned) is an obvious candidate for study in this regard.
Sometimes when I complain about jargon and bad writing in scientific papers, people argue back that the author has to be precise. This paper makes it clear that these are orthogonal issues. Writing is a skill, too.
The author is being extremely technical and rigorous, but she is also CLEAR.
Quite the badass.
Also, there really is very little substance behind the actual language criticism. It's hard to make a blanket statement that typeclasses are "overkill"; they seem to be showing up all over the place in new languages. Similarly, type annotations are incredibly useful and are also showing up all over the place these days outside of Haskell-land. The point on non-strict evaluation is by far the strongest and most legitimate.
After spending nearly a decade thinking about haskell, everything here rings very true.
It's a language whose sales pitch begins by assuming you are using the language: here are all these solutions to problems you now have.
Laziness is the wrong default; it's a catastrophe for writing programs. It requires the whole category-theoretic infrastructure of haskell to solve, and then, imparts insurmountable complexity on writing anything real world.
That is the most succinct explanation I've ever seen of Haskell.
Some schools have a bifurcated curriculum, like Indiana University which has a program in Informatics for those planning to go into a career the requires programming and software engineering skills and a program in CS for those perhaps planning on going into grad school. There, learning Haskell might make sense in the CS program, but does it make sense for other students that want to get out and get a job?
My own daughter studied at a school where her first CS class was taught in Scheme (Racket). It, to me, looked like an excellent introduction to programming for someone majoring in CS. They used a book I approved of, How to Design Programs/2ed by Felleisen, et. al. Would Haskell have been better? Maybe, but I predict that more kids would have serious problems with a language like Haskell that is burdened with more challenging concepts and ecosystem. Perhaps Lisp/Scheme is a gentler introduction to applicative programming than Haskell. However most schools start with Python or Java.
I understand the arguments for a strongly typed functional programming language like Haskell (my own university research was in program verification many years ago).
Early on in CS programs students usually take one or two classes on data structures and algorithms. Data structures in my opinion needs to be taught in C. Haskell, Lisp/Scheme, Python, Java, and even modern C++ are so high level that teaching data structures in these languages ends up with students not learning the proper use of these languages' standard libraries.
At some point undergraduates should have an introduction to systems programming, the best text in this area is Computer Systems: A Programmer's Perspective/2ed by Randal E. Bryant and David R. O'Hallaron. This is a great book for undergraduate CS majors. This book requires C programming. So to me, it makes sense to teach data structures in C since students will need to understand it for their first exposure to systems programming.
Where should Python fit in the curriculum? It's arguably the most versatile programming language. What about Javascript? When should CS majors be exposed to it. Modern Java is a big language so one semester of use isn't going to be enough and it's too important to ignore. What about C++? It takes years of working with it to become a good but not expert programmer in C++. Should it be a part of the curriculum?
So my own recommendations for an undergrad CS program's language choices would be:
* Python -- for intro to programming, a course on algorithms, and a machine learning course
* C -- for an early class on data structures and a later class on systems programming
* Java -- software engineering, and a compiler course
* Lisp -- programming languages smorgasbord course, and an AI course
* Assembly -- hardware architecture/digital design course
* Javascript -- taught as part of a web-applications class
* Haskell or OCaml (or maybe Rust) -- intro to functional programming and program verification
What do HN readers think about this list? I'm glad I don't have to make the real decisions there are just too many languages that students need to learn in just a few years.
As far are my own background I have spent a great deal of time pursuing three different degrees from three different universities in CS. I've been the instructor for university courses for CS majors twice and taught perhaps 40 week long classes to professional programmers within a Fortune 500 company. I've also interviewed and hired many senior developers for my own company.
I am a lawyer. I didn’t learn Westlaw or Lexis in law school. I mean yes, I did use them and was trained in them. But they were just tools. But no one would say “what computer research system should we teach our students?” And good thing—the ones I used in law school are now obsolete!
Even as a lawyer I can teach myself programming languages. Man I’d be disappointed if I went into a university CS course and they’re debating something as low level as what language to teach me, rather than teaching me how to learn any language and how to design new ones.
As a practical example, in my graduate program, there were some courses where the professors handled a lot of those baseline details, and courses where the professors gave a lot of leeway to the students. My observation was that the latter courses couldn't go nearly as deep into the official topic of the course. Students would spend so much time managing their programming environments that it became a serious distraction.
Also, in reference to your question, "Isn't the language just a tool?" - no, it isn't just a tool. It's also a language. For a professional software engineer, the programming language isn't just a way of telling a computer what to do; it's also the primary, and most authoritative, medium by which you communicate complex technical information to your colleagues. It's perhaps comparable to the divide between informal language and legal language - one is useful, especially for communicating to people with limited expertise in the field, but the other is where the rubber actually meets the road.
I am a software engineer. I didn’t learn RequireJS or CommonJS in school. I mean yes, I did use them and was trained in them. But they were just tools. But no one would say ‘what JS module system should we teach our students?’ And good thing—the ones I used in school are now obsolete!
Even as a software engineer I can read court opinions. Man I’d be disappointed if I went into a law school and they’re debating something as low level as what jurisdiction’s laws and court decisions to teach me, rather than teaching me how to interpret any law or legal argument and how to design new ones.”
I hear what you’re saying, software engineer, but avoiding any particular set of case law would leave these lawyers extremely unprepared for professional practice—not just because they will likely work in one of those legal codes otherwise covered by the school, but because those codes and the arguments that shaped them constitute an immense base of empirical knowledge about legal rhetoric, logic, and concepts that simply cannot be replicated in a vacuum. Accordingly, those excellent judges and legislators who do the novel work of lawmaking and legal argument are _not_ reduced to technicians by their knowledge of case law. In fact, I’d say it’s the opposite: it is impossible to have a good grasp of the theoretical underpinnings without also having extreme facility in one legal code or another as a ‘native tongue’.
Yes. But to learn the data structures and algorithms you have to practice coding them. What language do you code them in to teach them? After awhile most code looks the same.
https://www.cs.utexas.edu/users/EWD/transcriptions/OtherDocs...
It's really a disservice to students. Developing competence in a variety of programming paradigms is a career-expanding experience. It makes picking up a new language - and, by extension, a new technology stack - a quick and easy thing to do, because there will be very few ways of doing things that you haven't seen before. Which, in turn, makes it a lot more feasible to pivot your career or act quickly when an opportunity arrives.
A bunch of students who know only Java, on the other hand, is exactly what big corporate employers want. For employers, it maximizes the interchangeability of employees. For employees, it minimizes the interchangeability of employers.
Where would that be? Why is everyone here avoiding being specific? If you are not specific, why should we believe in what you say?
If your first program is an object, the whole world becomes an object.
There are always 2 ways to skin a cat with a computer. The more practical computer user could be satisfied with only using their first.
No source specified - ignore.
> if society could quantum tunnel
Oh dear.
Erlang got a big boost when it came out WhatsApp scaled it up with a billion users, with tiny team and only a few servers.
React/React Native got boosted by Instagram adopting it to build their production mobile app.
Rails had 37signals/Basecamp and Github/Shopify/early Twitter/etc.
Haskell needs some more famous commercial "killer-app" examples for real businesses and real teams. And yes I'm very familiar with the current selection of popular Haskell examples.
Currently I only ever hear Haskell (and Ocaml for that matter) being used by engineers for backend engineery things (parsing programming languages, fighting spam, tooling) mostly for OSS tools.
On a positive note, PureScript is trying to position itself as a practical Haskell and making a bit of success. One helpful reason is they have a nice app/company leading the way as a production app with Lumi [1], with their founder playing a key role on the language/ecosystem dev side as well: https://www.lumi.dev/blog/purescript-and-haskell-at-lumi
This is what Haskell needs more of - and critical a company promoting/blogging about their progress using Haskell as well as contributing back into the community.
Another big one is simply a sort of 'starter kit' which guides you with best practices on how to architect a serious Haskell app (ie, using STM, free, etc). React has plenty of starter kits. For Rust CLI apps there is a great starter kit https://github.com/iqlusioninc/abscissa
I'd love to see a similar starting point micro-framework for starting a new Haskell app that makes a bunch of importation decisions for you and guides the structure of the project.
I found one blog post mentioning Haskell but without much technical details:
https://hasura.io/blog/from-zero-to-hipster-haskell-in-produ...
I hope they write more..
https://reasonml.github.io/blog/2017/09/08/messenger-50-reas...
I’ve personally found starting adoption by converting pure domain code first to be the best approach, since it does not have to interact with legacy code.
It also has a really small and simple syntax and wonderful pattern matching heavy approach to code, which is something I've took with me to other languages (and a feature sorely missing in most major languages).
OTP is a bit of a beast and feels overwhelming at first, for example when you download an HTTP server to run your app you actually "run" the supervisor which spawns a bunch of processes. And this is all within your own application which is a group of isolated processes.
I'd personally use Erlang/Elixir for everything if it had strong typing. And I still might anyway for my next project.
edit: It's unfortunate that people are downvoting me for offering my experience, especially on a post that wants to make Haskell more attractive to being used in the industry.
The most recent instance is probably Juspay: https://github.com/juspay
Maybe my memory is fuzzy... But if not can you give an example where that wasn't the case?
Which company are we talking about? I don't see mention of a specific company in your original post.
But... most people who look into Haskell lose steam as soon as they realize they actually must understand and be able to reason about functors, applicative functors, monoids, monads, and (god forbid) lens-things like prisms, traversals, isos, etc. to do anything useful. It's a shame.
If we're talking about the software engineering equivalent of bridges, I think it would be much more valuable add TLA+ or similar to the curriculum.
One can make a point in that senior developers could use different tools than juniors. That happens on other industries, and development avoids it like the plague, with clearly bad consequences. But the industry will never standardize on high-knowledge tools.
I sincerely hope that software as a field matures to the point where maybe 50 years from now, hiring most of us working in it with our knowledge today would be like hiring a mathematician who never learned calculus.
Why? Why does everyone think that you have to understand the mathematical underpinnings of Haskell to program in it, but not that you have to understand the assembler to which C compiles to program in it, or the internals of your car's engine to drive it?
Of course, in each of these cases, someone who has that knowledge will probably have some power available that will be denied to those who don't; but that doesn't mean you can't use it. The great thing about this mathematical knowledge is that it can be filled in on demand, and, unlike a lot of knowledge that you don't even know you don't have, when you realise you want to understand what these objects are, you've already got the terminology to look it up in research papers.
Agreed, but you also don't have to understand anything about the mechanics of the steering wheels and pedals to drive a car, only about when to use which. Monads and other scary-sounding terminology are the same. People really do know these patterns from other programming languages, and attaching a name might be scary, but it doesn't make them intrinsically harder. On the contrary, it makes it easier for people who want to peer into the theoretical internals to do so—though no one has to do it.
This is a very MBA-like lens through which to examine software development. It's not wrong, but it's also a recipe for mediocrity, which is a great way to damage your culture and sit around wondering why you can never get ahead of your competition.
The deeper question is why is software quality only loosely correlated, if at all, with business outcomes?
The pessimists will point to Equifax et. al. and tell you that the market simply doesn't care, that businesses can go through downtime after leak after catastrophic failure and their stock will never take a hit. And there's some truth to that. The end consumer actually doesn't really care about the bad news. There's not much that any company in the business can do about that.
But the optimist understands that great engineering will leapfrog competitors and leave them in the dust. The value of correctness isn't in the two months after you begin, it's in the two months after your latest release five years from now. It requires vision, patience, already-available human capital, and leadership to realize the benefits.
> If the talent pool is illiquid or geographically locked, that’s a non-starter. If there isn’t a large corporate vendor to go to to sign up for a support contract, then that’s a non-starter. If there isn’t a party to sue as an insurance policy against failure, then that’s a non-starter.
If you give your talent the opportunity to work on a Haskell project and they're walking out the door when it's difficult to find Haskell work to begin with, then you, the manager, failed in deciding which talent to hire. If you're looking for a support contract to hedge against the loss of in-house talent, then you've already failed. If you think that legal solutions will protect you against market failure, then you've already failed. Haskell isn't trying to market to these people in the first place, why should it start?
This is framed as a downside, but to be mediocre it can't be so bad it doesn't work at all. Most software that is great from a technical standpoint is made by a relatively small team, which translates into a relatively large risk for the business since it compresses all the volatility into retaining that team or not. With average tenure in tech around two years, you can see how that is not an attractive proposition for most companies. If all the competition is also (at best) mediocre, you can simply try to compete on other (nontechnical) fields like marketing or customer support.
There is a secondary level of incentives that is present in most larger companies: delivering a fantastic product will make the owners rich and the people involved will maybe get a raise. Delivering a spectacularly failed project ends your chances of career advancement. This really diminishes the appetite for taking technical risk amongst decision makers. Mediocre is often good enough.
Aren't ~90% of the software projects failures?
Mediocre software is failure. There is no upside to avoiding all risks.
> The deeper question is why is software quality only loosely correlated, if at all, with business outcomes?
Because quality is on a spectrum and context specific: commercial domains need quality levels—you have to set magnitude or quantify in some way. The software profession such as it is, tends to come at this a binary matter (cite pretty much any debate about speed vs quality). That gets, I think, amplified in technical communities where correctness is deemed more important or simply more attainable in terms of claims.
> But the optimist understands that great engineering will leapfrog competitors and leave them in the dust.
I agree with the sentiment; I actually do think we're in a phase where engineering leverage is underestimated, but would qualify it and say this is different to correctness. What great engineering can do is offer a short term technical advantage (eg "secret sauce") and/or a sustainable one (eg "organisational speed"). It's not clear correctness provides that kind of benefit, unless we want to frame as increasing precision/accuracy/reproducibility of results.
codebase organization was nonintuitive and I blame type-level programming
compilation was so slow and bad that other programs on my laptop started to die
the feature I was adding was something that would be library-provided in a normal web language
none of the operators have names and are very hard to google; I had to search for things like 'haskell tilde asterisk arrow'. Impossible to know what's from libs vs core language. Lots of explanatory docs online were like 'oh we don't pronounce this one'.
Core abstractions have no definition ('to explain that I would have to explain monads but you won't understand monads so GFY'). Monads are just sub rosa dependency injection .
lang doesn't protect you from runtime crashes but does apparently protect you from knowing where the program crashed
One thing I really like about Haskell is Hoogle. The ability to search by function signature is great. I often wish I could do that in other languages.
(->-) :: Bind m => (a -> m b) -> (b -> m c) -> a -> m c
semigroupoids Data.Functor.Bind
Just search for it the same as you'd search for it in Java or Scala.
Can you share a sample?
square x = crash * x
crash = undefined
main = print (square 3)
Cause for me, this results in: foo: Prelude.undefined
CallStack (from HasCallStack):
error, called at libraries/base/GHC/Err.hs:78:14 in base:GHC.Err
undefined, called at foo.hs:3:9 in main:Main
Maybe your mileage varied.I liked the linked author's points about the pre-requisites for marketing a solution:
It is memorable
It includes a key benefit
It differentiates
It imparts positivity
When I think about the most popular languages, they do have all of these:
Rust:Memorable: very. It's basically everywhere you look Has a key benefit: going C++ fast without the C++ footguns, memory-safe, WASM integration Differentiates: Using Rust is definitely choosing a particular set of technical tradeoffs Imparts positivity: the community is known to be welcoming, feels cool, cute crab. People re-write existing software in Rust just because it feels good!
Yet Haskell has almost none of these:
Memorable: I mean, yeah, but it's not being shown to people, and I can't point to a bunch of software. Tools I know of include PostgREST, Hasura, Nix, hledger, which is better than nothing. Key benefit: Hand waving about "being more correct", unlike Rust which has reams of "Microsoft claims 60% of its bugs are memory-errors" articles, and in any case TFA's point is that this needs to be a different message because correctness isn't gonna sell it. Differentiates: This is definitely true, almost too much Imparts positivity: Not really feeling this one with Haskell. People feel good when they figure out a monad is a container & a lens is a path through a data structure, but attempts to explain to others these things feel condescending. Does Haskell even have an animal mascot? (serious question.) Also "stumps" a lot of people and people feel bad about it. There's no "import antigravity" equivalent feeling with Haskell.
This sounds pretty sombre for Haskell, though it's been an academic language a long time, and could probably stay alive that way.
One positioning possibility is maybe with the Frontend dev world becoming more and more functional and pure-oriented, positioning itself like reasonML, as a way to write and reason about declarative pure UIs. But I don't think the existing Haskell community cares too much about that world.
Idk, I'm going to just keep writing Rust and JS, the already most loved and popular languages.
There are certainly pieces of haskell that would make all our lives easier, and I can't wait for them to make their way into mainstream industry work one way or another.
"To contact me via email run one of the following scripts to generate my contact information. I find this is an effective filter against the deluge of emails from recruiters."
The "scripts" are offered in Haskell, x86-64 Assembly and Python. Solution is pretty obvious though, no need to run them actually.
I would applaud any recruiter who went through all that trouble just to contact a person, regardless of my interest in their offer.
No. Technical excellence matters a lot when used appropriately, but competing with javascript and python is not where haskell is going to win.
There IS a language with HUGE success that is: declarative, strongly typed with type inference, lazy, and no side effects. It's called SQL[1].
That's where Haskell could shine -- compared with SQL. Imagine Maybe rather than NULLs, a sane language, multiple returns, a much better type system, etc. Python and Java can't touch SQL, but haskell could.
[1] http://thoughts.davisjeff.com/2011/09/25/sql-the-successful-...
It also sometimes has side effects, although that's more dialect specific than present in the standard I think (when it comes to DML).
And type inference also plays a role with CASE statements, UNION, etc. Again may depend on SQL implementation.
And people care about correctness in a way that they don't with python or javascript. Haskell really has something to offer.
Second, the problem with the message of "code written in Haskell is more correct than code written in other [more popular] languages," isn't that the industry doesn't care about correctness. Correctness translates to cost (to a degree), and the ability to write software as correct as it needs to be more cheaply is actually quite compelling. Rather, the problem with it is that it's simply not true (or, rather, hasn't been shown to be true), certainly not to any degree big enough to matter. That, in and of itself, does not make it a terrible message; after all it's just harmless hype, right? What makes it a terrible message is that it is very clearly not (shown to be) true and yet some Haskellers seem to actually believe it, drunk on their own kool-aid, which makes you think of them as out of touch with reality. At best, it's an emotion (it "feels" more correct), which you've mocked, rather than any sort of "critical thinking," that you present as the desirable standard.
Third, the mistake in the perception of the economics of software is not the importance of correctness — that can have an easily measurable impact. It's in the importance of code. Programmers in general, but Haskellers in particular, are obsessed with code. As a result, they grossly overestimate its importance to software. Ask yourself how long it takes you to produce, say, 1000 lines of code of sufficient quality, and then look at a software produced at your company and divide the size of the codebase by the number you came up with. You'll find that the true cost is several times that. The "pure" cost of producing code is not where most of the cost of developing software is. Maybe it's in what you mockingly call "emotions", but it certainly isn't in programming-language semantics. Also, before presenting managers' priorities, it's better to actually speak to actual managers; they just might have some useful insight here, plus, it's what a culture of technical excellence demands, no?
All of that means that unless your language has some clear and direct effect on the bottom line — which, these days, usually means it has good performance and/or observability, a good ecosystem, or a monopoly of sorts on some distribution platform -- there is no "message" that can make it popular, other than "it's easy and it's fun." While perhaps not a sufficient requirement for success, this can create a supply of qualified developers that at least won't put your language at a disadvantage.
And here's another tip: if your retrospective introspection isn't painful, doesn't discuss any serious and conspicuous flaws with the product, and still paints you as being somehow right after all and everyone else as being somehow wrong — it's probably not true. Worse, it seems untrue. And not calling your own practice one of "engineering excellence" and others' as "throwing enough bodies" can't hurt, either. In other words, I don't know what a good marketing message for Haskell would be, but this post is a good example of a bad one.
I think this approaches the heart of the problem. Whatever the advantages of haskell may be, the disadvantages run extremely deep. Haskell is notoriously difficult to debug and optimize (both memory and cpu usage). It is interesting and influential, but trying to abstract away the order of operations as a core of the language just didn't pan out. All of that is before issues of IDEs, libraries, compilation times etc. It has been around for 30 years, at some point it needs to be called a worthwhile experiment so people can move on from clenching their fists that no one else is as clever as they are.
The more I think about it, my ideal language would be the exact opposite. Something extremely clear and straight forward with minimal complexity and maximum infrastructure.
I completely agree. That's why I like Java for high-level (but large-scale) programming, and interested in Zig for low-level.
Maybe it's because the bugs are generally less common and easier to fix, but when I look at Haskell codebases it seems like it's quite difficult to achieve the same level of "separation" one would in (say) Java - i.e. an average Haskell file seems to purely consist of many loose free functions (often with very short names!).
I might be missing the point but the aforementioned always pushed me away from Haskell - great language, but seems to have legibility as an afterthought (as opposed to python, which is an awful language, does manage to enforce some sort of legible coding style)
For this reason, I find code style to not affect me in Haskell. I've seen a bunch of different styles and I'm never taken aback. The code is all simple & mechanical to reason about.
I've been able to refactor other people's "bad code" without much effort too. This is after others have said the code is bad and unfixable. It just takes a good attitude and the same mechanical approach as always.
At the end of the day, I think a lot more about the business problem in Haskell than other languages. I hate having to think about code & simulate a computer in my head. But if you wish to use other languages and pay me to think like a computer, feel free! It's your money.
You can think of modules as Java classes and get the same sort of code separation fwiw.
Oddly now I find it really legible compared to other languages, you can still make things obtuse if you really want to, but the flow seems so much clearer.
I would say compared to Java (as you mentioned it) there's much less separation because things invariably gravitate towards big balls of mud containing lots of state. But in Haskell the function you're looking at is only tied to the functions and data types it uses, no more, no less.
Good Haskell code is not organized the same way as good OO code. While in OO you will have separated instances that take complete care of different business concerns, in Haskell you will abstract the care into different parts, and integrate the business concerns into a few instances that take complete care of them.
I’ve personally switch code to functional style and it has simplified and reduced code for me. Granted if you don’t know how monads work it could be very confusing.
The superficial things are things that are not really part of the language, but more of its standard library, part of the 'prelude', or things the community has agreed upon:
- the I/O monad (and others) can throw errors
- prelude is full of bad practice like use of strings and linked lists
- there's something wrong with how function names can't be namespaced
There's more than this, and they're not just things I came up with, they've been fought over in the community at length. Other preludes exist, I/O libraries that don't throw errors, even whole different systems for doing I/O exist. It's not that solutions are hard or impossible, they're there, it's just that the way the language is managed it's not likely that they'd ever be applied in a way the entire community, and especially those drawn to it by any marketing would experience them.Maybe I'm making a fool of myself and things changed in the past couple of years, things were really developing at a rapid pace when I left, but it seemed all the improvements happened around haskell, not to the language itself. When Stack and LTS-Haskell emerged it was the most amazing thing that I saw happening to Haskell in like 10 years, but given the lackluster response Snoyman received from the core team it seemed like they didn't even realize it even though the entire community had like an upheaval.
In my opinion, Haskell's marketing is fine. It's being marketed to every college student anywhere that goes to a good enough university that it teaches functional programming. In addition to that there's raving fans (myself included) that extoll its virtues to anyone who would hear. What it needs is a better retention rate. It needs that people who learn it, immediately realise it's fit for production use, that it's not just a fun experiment and a educative way of looking at things. For that we need something like a Haskell 2.0, designed by the community to incorporate everything we learned about Haskell's flaws and make it an absolute powerhouse of productivity. Maybe Haskell should be split into two flavors, one the teaching language with the linked lists, strings and funny pattern matching, and one that's got a prelude that will set you up with the perfect base to build the next compiler, database, service or web application.
If all those smart people who learn Haskell and tinker with for a bit, actually stayed around and used it to build awesome stuff, Haskell would truly have an enormous foot print on the world.
(not really relevant but the fundamental thing is that Haskell's performance is really hard to predict, this is true for many garbage collected languages, but for Haskell it seems to be extra bad because of the way its paradigm just doesn't map 1:1 to how computers are built)
How about PureScript?
I mean, try if you want to. It's no skin off my back. But it doesn't seem like it'll work.
Using different names for the same language didn't change anything fundamental. It was built into the browser, so if you wanted to write code in the browser you didn't have a choice.
https://stackoverflow.com/questions/2018731/why-is-javascrip...
Even JavaScript's first name Mocha is a reference to chocolate coffee and the Java language.