by javajosh · 5y ago · 0 comments
I really like functional programming, but Haskell turns me off and without at least one major example of a beautiful, popular solution written in Haskell (and I don't think pandoc counts), I'm not going to make the effort to push through that barrier.
Other languages that occupy a similar space ("superior but tragically underused") have these examples. Erlang has...well a lot but Matrix and RabbitMQ come to mind. Clojure has...well it has datomic, but also Jepsen uses it, and heck I've used it and its fine.
The real question is, who's fingers itch to write haskell, and can you please pay them $400k to rewrite nginx in it?
Shellcheck has become a very important tool to many people writing shell scripts: https://github.com/koalaman/shellcheck
GitHub's semantic analysis is written in Haskell: https://github.com/github/semantic
I'm not sure why Pandoc doesn't count.
I think it is definitely the case that most examples of successful Haskell are technical programs of interest to hackers. I don't think that's much of a problem myself.
If you're writing some boring CRUD app, or a GUI program that makes a bunch of syscalls, Haskell sounds like a giant pain in the ass.
From that POV, I think that Haskell's relative lack of popularity is perfectly fine. Not every language has to be maximally general.
It seems to be a common view point that Haskell makes IO difficult. I actually personally found that it was more powerful because I was being more explicit about it. It also allowed for higher ordered functions to abstract common patterns in IO. The only difficulty in Haskell was not due to monads or type safety, but rather in getting my brain to understand lazy evaluation by default.
I found this blog post to be kind of interesting: https://blog.ploeh.dk/2017/02/02/dependency-rejection/
Skim that and then take a look at the back-and-forth in the comments.
Sometimes going out of your way to write mostly pure (or just non-IO) functions can make your code more difficult to reason about. In my experience, you're sometimes left with two choices: either do a bunch of IO upfront that you might end up throwing away (if there is an `if` statement in your pure function that determines whether you need the result of some IO op), or pull out logic into the naughty impure edge of your program.
If you do the former, you're wasting performance. If you do the latter, you're not actually fixing anything that pure functions are supposed to help you with, because you still have logic in impure functions.
In my experience there are these edge cases where finding the cutoff between "the edge where I'm allowed to do IO" and the "pure business logic" is not that clear or easy.
Also, as the old saying goes: monads don't compose well.
[1]: https://www.destroyallsoftware.com/screencasts/catalog/funct...
Most CRUD server handlers basically boil down to fetch and parse incoming HTTP request, decide to fetch some external resources (db/cache/service), prepare a response, and reply to the client. Fits the IO-on-the-outside model perfectly.
React and friends have shown that UI views are mostly pure functions. Some local state and external resource can be fetched in some runtime hook and passed into your pure renderer.
For the less simple apps, IO can be hidden behind interfaces for complex business logic. Here's an imaginary example:
def getPriceForShoppingCart(product: Product, user: User, getDiscount: (User) -> Percentage): Price {
if (user.isPremium) {
product.price * getDiscount(user)
} else {
product.price
}
}
How do we put the IO on the edges? Does this function just disappear and we have an `if` statement in our impure outer shell? That smells like business logic in the impure shell to me. Do we go ahead and call `getDiscount` in the outer shell and pass in the discount to the function? That also sucks because what if we made that trip to the database when we didn't need to (because the user is not a premium user)?I feel like every time I try to be religious about IO at the edges and not using impure dependency injection tricks, I end up running into a bunch of cases like this.
On the other hand, if I stand back and look at a function like this objectively... It's easy to understand, it's still quite easily testable. What's the problem?
Facebook also wrote parsers, analyzers, and linters in PHP, and those were deployed to production. PHP let you write these things, but also all of the cruddy stuff non-Hackers like to write.
I am by no means advocating the use of PHP (even modern post-fractal PHP), but where’s a boring application that Haskell is a success in? You know, a little game you could download and have fun with? Or a billing system?
Here's a "boring" internal management system: https://twitter.com/fegundersen/status/1325534608079941633
Disclaimer: Founder of digitally induced, the company that helps make boring things with IHP+Haskell :)
It's possible and even very probable that PHP devs... stolen plenty of ideas from Haskell just to write "utility" libraries with witch they could write those parsers/analyzers/linters you are talking about :)
However, I also can't see how PHP could be used to efficiently re implement that spam library Facebook developed.
There whole promise lies on separation of effort into two teams: * spam engineers write pure code that happily merges data from different sources * backend engineers write integrations with Facebook systems and optimization passes over code spam engineers wrote to make sure that most optimal use of costly I/O was made
PHP brings nothing, literally nothing to the table here. While Haskell have all the mechanisms already built in.
Your argument about PHP sadly boils down to "its all Turing complete anyway".
IHP has around 230 monthly active projects at the moment, and it's growing fast. It was released 8 months ago and now is already the second biggest haskell web framework :)
I think haskell has been previously tragically underused because it was missing good documentation and pragmatic solutions that help you to get things done. Atleast in the web dev space this has changed this year. Watch our IHP demo video and you'll get it: https://www.youtube.com/watch?v=UbDtS_mUMpI
Disclaimer: Founder of digitally induced, the company that makes IHP.
There are amazing claims about how Haskell (or Lisp or Erlang or ...) give you these amazing superpowers and allow you to write immensely more correct programs immensely faster. That could be true (and I personally do believe it’s true). But then where are all of these immensely-correct fast-written programs? I don’t buy the pg-inspired secret-weapon lurking-in-the-shadows argument unfortunately.
In C, C++, Java, and Python—even Pascal!—it’s not even funny how many examples there are. It’s nearly limitless. The superpower languages struggle to come up with just a handful of examples.
What I personally observe in the Lisp and Haskell world is that people like to write purportedly useful “reusable” libraries, and nobody likes to write applications. A very select few are successful at these libraries (where success = broad adoption), but most of these libraries are intellectual games and puzzles that benefit almost zero “working programmers”. Lisp has plenty of libraries to do pattern matching (great!) but basically zero for putting up a native GUI.
(As a self-deprecating anecdote, my first instinct writing Haskell many moons ago was to create a library of all of the major abstract algebraic structures found in pure math. You can imagine how many people that library would benefit.)
A lot of this also has to do with not the language, but the tribal nature of programmers and their acceptance of other tools in their chain. The Linux kernel will never accept a patch written in Common Lisp, and a lousy middle manager will never let you write your domain logic in Prolog. Nobody wants to figure out how to integrate GHC into their CI/CD. Most people have little patience to figure out how to write good C code that integrates with Erlang’s FFI.
I’m being a little flippant in my description of the state of affairs, but I think the spirit of it is correct.
I think the commenter is right. If any of these languages will be successful, there have to be many, many successful programs written in said language where the language’s benefits tangibly pay off. Having one or two Hail Mary projects doesn’t really mean anything.
But everyone still shits on "Rust Evangelists" when they bring it up. You just can't win! :D
Rust was sort of co-developed along with Servo with the intent to be used by Mozilla. For all the others using Rust, it solves immediate problems that people have been having for years. When you're going up the learning curve and fighting the borrow checker, you can rest assured that the pain is in exchange for eliminating entire classes of bugs. That is an unusual situation in the world of languages.
librsvg is one.
I think it was originally written in C, and it apparently approaching being fully Rust.
Rust claims very loudly, repeatedly, and apparently with honesty that "gotta go fast" and safety are language design goals and features. So I'd imagine even a developer who just wants to get their hands dirty with Rust would be willing to do battle with the borrow checker since there's a good chance they'll eventually hit those goals that they share in common with the language itself.
Does Haskell have "gotta go fast" as a central language feature? If not, that'd be a real gamble for an SVG renderer. After all, what's the use of a library that produces the output you'd expect, but also at a speed you'd expect for a kludgy, over-engineered, text-based vector image format?
> But everyone still shits on "Rust Evangelists" when they bring it up.
Yes, but the language forces them to shit on it for reasons other than "not being fast." :)
Edit: clarification
You can optionally choose to use a Rust-based HTTP stack.
Almost zero people writing lens libraries in C, almost no people are writing state-of-the-art asymptotically optimal Cool Tree data structures in C++.
Almost all users of these languages are writing an application that isn’t designed to serve the intellectual needs of the programmer themself.
Ah, the Fermi paradox of programming languages. I wonder what the appropriate terms should be for the Drake equation of language adoption? I definitely think there is a factor for users originally attracted to shiny new objects, who then discover shiny... Oooooh, Idris!
I do really honestly believe that Haskell needs a "paragon project" like Matrix or Jepsen that has proven itself useful to the world without respect to its Haskellness, and then show that this solution was much easier in Haskell.
I keep getting down-voted on this thread, and I expect it to continue. Friends thought I was nuts to give up on Lost after season 1, or The Hobbit after movie 1, or the GoT books after book 3. After years of hearing much talk and seeing no walk, I'm giving up on Haskell. More than that, I'm going to call out anyone talking it up to give specifics because literally everyone I've every spoken to about it gives it a very high regard, but have never, ever written a line of it.
It's fine to make silly hyperbolic statements in a language war, but when you are trying to present yourself as the voice of reason.
No, the best course of action is to solve problems that haven't been solved, not to do marginal reinventions of the wheel.
A killer solution is definitely a help in getting a language ecosystem to take off, but those are rarely simple reimplementation of an existing tool. Occasionally they are in a recognizable existing category, sometimes they are category-defining.
I've being thinking a lot about this, and I think this is better addressed by using the same standards as in other fields. Namely, a scientific study. I imagine an environment like repl.it, with just a simple text editor, and some problem description and a set of compressive tests that serve as a spec. Then we measure time to produce a solution and number times the solution makes the tests fail (bugs). With enough people doing this, and in enough languages, we might be able to reach some conclusions. Until then, we will be stuck in the dark.
[0]: https://www.cs.yale.edu/publications/techreports/tr1049.pdf