151 points · by lelf · 7y ago · 165 comments
- Jobmachine, an advanced job-scheduling system with dynamic dependency resolution[2]
- Vaultenv, a small open-source tool to get secrets from Hashicorp vault[3][4]
- alfred-margaret, a blazingly-fast Aho-Corasick implementation written in Haskell[5][6]
- Sharkmachine, our in-house replacement for Apache Spark[7]
[1]: https://tech.channable.com/
[2]: https://tech.channable.com/posts/2017-02-24-how-we-secretly-...
[3]: https://tech.channable.com/posts/2017-07-06-introducing-vaul...
[4]: https://github.com/channable/vaultenv
[5]: https://tech.channable.com/posts/2019-03-13-how-we-made-hask...
[6]: https://github.com/channable/alfred-margaret
[7]: https://tech.channable.com/posts/2019-10-04-why-we-decided-t...
We are currently in the process of building something similar and it would have been interesting to see your approach in more detail.
https://github.com/tweag/funflow - A library for running computational workflows
https://skillsmatter.com/skillscasts/14417-build-systems-a-l... - a recent Haskell eXchange talk about build systems (corresponding paper: https://www.microsoft.com/en-us/research/uploads/prod/2018/0...)
Pandoc is an amazing piece of software that can convert between all kinds of document formats.
I work for a small data science consulting company whose major components of a machine learning pipeline were written in haskell. The company got bought by a large corporate and shortly after, all the haskell developers left, leaving a handful of people (including myself) who didn't know how to use or maintain the major components of a multi million dollar acquisition. It is in the process of being scrapped and replaced with a more typical software stack.
Hilarious times.
To be fair, purportedly "easy" languages such as Java aren't actually easy. True, a lot of people can write (or copy paste from online articles) crappy Java code full of bugs and performance issues and nobody will notice since this low quality seems to be some kind of industry standard. But there aren't that many good Java developers either.
A similar argument used to be made about PHP: anyone can use it. To write poor software, that is.
As for Haskell: it's different enough to Java-like and C-like languages that it's difficult to wrap your mind about it if you come from those languages. But if you start fresh, it's not that hard. Some years ago someone here on HN posted pretty good results when teaching Haskell to kids. Young kids pick it up surprisingly fast. It's not inherently difficult, and in fact some of its concepts may be easier to grasp than traditional imperative languages. (And no, you don't need to understand category theory at all in order to program with Haskell).
Programming languages (at least in the context being discussed) are just a means to model a problem domain. Some people find it easier to model domains in strongly typed functional languages but at a much larger percentage do not. Let's for argument's sake say it's 1% of all programmers. That is still a huge number of people though.
"and a lot of programmers don’t want to learn it" - also opinion, but I'd be very curious to also know how the quality of those who do want to learn it compare to those who don't.
And it's a lot of thousands - don't merely count the cost of training. Count the salary they are being paid while they learn.
I know 1 company where this happened, but there Haskell developers left because management decided to move to python (without them even knowing its under consideration).
I think a core reason for our success is that we built our team from experienced developers that had built large applications in other languages. Then arrived at Haskell as a better solution.
I have heard some negative experiences that I would attribute to a few different factors.
1. Lack of Haskell experience in the early team. 2. Lack of experience building large real-world applications (too academic) 3. The startup/group didn't achieve product-market fit, and Haskell was scapegoated.
None of these problems are Haskell specific, just run of the mill team issues.
I’ve tried to find a way to use Haskell (lacking strong experience there, but with lots of large app experience), and I’ve not managed to find a situation where pulling the trigger makes sense because of the risk of getting “stuck” with a poor path out.
I would conjecture that it is more common than what you’d expect from random chance. In my case, I picked up Haskell only after building large systems in C++, Objective C, Lisp, and Python. The draw was that Haskell let me express the kind of system invariants that make it possible to reason about a large codebase.
Since then I’ve written production Haskell in three different companies, none of which appear on this list.
I'll add this problem is not at all Haskell specific. If you put an experienced Java developer to work architecting a large Python application where they have no prior Python experience you are going to experience similar problems. I'd say the problem is perhaps a bit more acute with Haskell as the paradigm is likely more different to the prior language. So if possible get at least one person on your team that has experience with a large Haskell app and pair them up with other devs.
Pretty much anything you do in NodeJS/Angular is run-of-the-mill stuff that your run-of-the-mill hires should be able to work on.
Haskell is hard to learn and hard to find developers for, but the trade off is incredible safety and a type system that promotes good design and easy refactoring of inevitable design flaws.
To achieve such a thing with other languages you need a highly disciplined team/culture and you need lots of time (meaning less hard deadlines and time crunches) and willingness to invest time into refactoring.
That said, anyone know of a writeup / "post-mortem" of such a failure?
I’d much rather, in general, get predictable and understandable semantics and have to struggle for performance than get predictable and understandable performance and struggle for semantics. Even more so, I’d rather use software that faced that profile of challenges. You can see when the program is slow at runtime, but you often can’t see when it’s wrong at runtime.
Not too many haskell bootcamps.
There is a need for haskell but it is not the next language to take over it is missing key features.
Which key features is Haskell missing?
Here's an example about Haskell. Go to https://tryhaskell.org and enter these:
3
div 6 2
3 + 1.0
(div 6 2) + 1.0
The first line returns 3, and so does the second line. The third line returns 4.0. The fourth line fails with this error: No instance for (Show a0)
arising from a use of ‘show_M552168474310802709512215’
The type variable ‘a0’ is ambiguous
Note: there are several potential instances:
instance Show a => Show (Const a b)
-- Defined in ‘Control.Applicative’
instance Show a => Show (ZipList a)
-- Defined in ‘Control.Applicative’
instance Show GeneralCategory -- Defined in ‘Data.Char’
...plus 106 others
In the expression:
show_M552168474310802709512215
(let e_16210 = (div 6 2) + 1.0 in e_16210)
In an equation for ‘e_155216847431080270951221555216847431080270951221516210621016210’:
e_155216847431080270951221555216847431080270951221516210621016210
= show_M552168474310802709512215
(let e_16210 = (div 6 2) + 1.0 in e_16210)
In the expression:
(let
e_155216847431080270951221555216847431080270951221516210621016210
= show_M552168474310802709512215 (let ... in e_16210)
in
e_155GHC is a little better.
GHCi, version 8.4.4: http://www.haskell.org/ghc/ :? for help
Prelude> (div 6 2) + 1.0
<interactive>:1:1: error:
• Ambiguous type variable ‘a0’ arising from a use of ‘print’
prevents the constraint ‘(Show a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Show Ordering -- Defined in ‘GHC.Show’
instance Show Integer -- Defined in ‘GHC.Show’
instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
...plus 22 others
...plus 18 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In a stmt of an interactive GHCi command: print itThe type of `3` gets inferred as `Num a => a` because there's nothing to constrain it further.
The type of `div 6 2` gets inferred as `Integral a => a` because the type of `div` is `Integral a => a -> a -> a`.
The type of `3 + 1.0` gets inferred as `Fractional a => a` because of the decimal point.
Then the same thing happens in the last statement so the type of the subexpression `(div 6 2)` (still) gets inferred to `Integral a => a` and the type of `1.0` (still) gets inferred to `Fractional a => a` because of the decimal point.
So at that point you have an expression that's trying to add something constrained to being a whole number to something constrained to being a fractional number and that is ill typed because there is no type you could choose for the overall expression that would meet both sets of constraints.
Edit: When I first replied there was text at the bottom of the message saying that no one could explain why this happens. My comment was addressing that portion of the original message. The behavior itself is not surprising for the same reasons.
Prelude> :t (div 6 2)
(div 6 2) :: Integral a => a
Prelude> :t 1.0
1.0 :: Fractional t => t
Bonus: there is a language extension which does you do this: https://www.schoolofhaskell.com/school/to-infinity-and-beyon...
If your point was that the error messages could be nicer, I agree.
Ambiguous type variable ‘a0’ arising from a use of ‘print’
prevents the constraint ‘(Show a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Show Ordering -- Defined in ‘GHC.Show’
instance Show Integer -- Defined in ‘GHC.Show’
instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
...plus 22 others
...plus 18 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
In a stmt of an interactive GHCi command: print itSolution:
(fromInteger (div 6 2)) + 1.0
I would argue that programming languages are subjective. There are many different equally viable ways to model the world and programmers should pick the one that aligns with how their brain works.
I'm not convinced it's possible to objectively rank programming languages from best to worse. They are not fundamental properties of the universe simply mental models devised by humans for humans.
Better for what, for whom? Every programming problem is basically a unique problem of its own -- else the solution would already exist as source-code. There's no need to re-program the wheel.
Therefore the generic question of "what programming language is objectively better" does not make much sense, unless we qualify the question with: better for what, better for whom.
I wouldn't advice against Haskell. But I would advice against having a business with more than one non-boring component. And usually that non-boring component should be the solution to the client problem, not the tech stack used to implement it.
If you start a business in a language stack none of the devs have done large scale production projects, you are basically begging for a world of trouble. If the devs are familiar with Haskell, I don't see any problem with choosing it, if it matches the problem domain. I wouldn't choose it for example for frontend development (although I suppose you can get it compiling there) or things where C, C++ or Fortran still have a strong legitimate foothold.
(I have no idea what would motivate a person to do such a thing, but people are weird.)
"What can be asserted without evidence can also be dismissed without evidence." (Christopher Hitchens)
This is one of the things that you may only learn the hard way, as your project grows in complexity. Nobody advertises how slow their compiler is.
So, my question is, how does GHC fare these days? How does it treat people that switched from a dynamic language, who are used to quick iteration?
It has been argued before, in a fascinating but admittedly flawed experiment for the Naval Surface Warfare Center (US Navy) [1], that Haskell is a great prototyping language. This experiment is flawed for multiple reasons which the authors readily admit (e.g. the results from all contestants were self-reported, the requirements were vague [2], no code was actually run by the panel of judges, etc), but it's still tremendously interesting. It's also amusing that the judges couldn't believe the Haskell program was a working and complete implementation of the system, and thought it was either pseudocode or "too clever" for its own good (because of the use of higher-order functions)!
[1] http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.368...
[2] though one could argue vague requirements are actually another point in favor of Haskell as a rapid prototyping language. It's often argued -- mistakenly -- that languages with static typing are not good for exploratory coding, which this experiment tends to show not to be true.
There have been work on making haskell to have deterministic build to speed up compile time, and compare to scala, I find it way faster (in my current company, we use scala). But note that if you start using stuff like template haskell, your compilation will slow down.
What is the turnaround time with these interpreters, then?
Come on. Why picking a girl specifically?
The effort of learning Scala vs Haskell as at a professional level would be more or less equal.
Learning Haskell (well) is a big investment. If you make that investment, of course you are going to argue that now we should reap the benefits of that investment.
It makes sense from the point of someone who has already made the investment of learning Haskell. But, choosing Haskell for a project means that other current and future programmers must make that same investment in leaning Haskell too, rather than learning something else perhaps. Or using what they already know well.
First, my CS background. I started programming in 1991, and have used dozens of languages major and minor over that time. At one time or another, I developed especially deep knowledge of the following: C, Perl, PostScript, Python, C++, and PHP. Functional languages always hovered at the edge of my interest, but never seemed practical enough to apply to the sorts of systems programming I love.
In 2017 I decided to spend some time broadening my understanding of language concepts, and made a list of languages to learn more about: OCaml, Julia, Clojure, Scala, Scheme, Haskell, Rust, Erlang, Go, Swift, and Kotlin. Learning OCaml ended up being such a transformative experience that I use it almost exclusively now. As an aside, I must say that it wasn't easy; it took the better part of a year to acquire the knowledge and experience necessary to feel productive.
Why is OCaml (and presumably Haskell) so good? The resulting programs feel like beautiful self-consistent crystalline structures rather than balls of mud. Furthermore, the powerful type system allows refactoring from one crystalline structure to another such that inconsistent hybrid crystals rarely occur. This is a much different experience from reshaping a ball of mud. The routine elegance and safety of these program representations aid in discovering the essences of solutions, and I have written programs I never would have discovered in other languages.
Killer features: - The powerful type system clarifies design, aids refactoring. - The module system (in combination with generics) enables truly modular design. - Effectless computation (pure functions, immutable data) simplifies reasoning about state.
I have some complaints about OCaml (and every other language I know), but it stands out as by far the most fulfilling to use. Going forward I will prefer to spend my programming time using languages more like OCaml, Haskell, Rust, etc. than those I used for the first 25 years.
Thus, even if it is the case that it requires major effort, but people love its power, your word of caution is not really undermining the argument that it is a useful/powerful/enjoyable tool.
I think people want programming in general to have that sort of simplicity, but data flow programming is already where focus can be on transforming data without the complexities of most real world programs.
I think there is a lot of desire to try to make Haskell work in all situations instead of what it is best at.
Surely it must also be because Haskell is a pleasure to work with?
You would think that to answer the question above you would need a really expressive language. Haskell is a language that is actually less expressive and more restrictive than mainstream programming languages. You can be much more expressive in JAVA, C, C++, python, javascript and python then you can in haskell. For one you can mutate variables and re-assign them in mainstream languages and you can also have Loops. These things don't exist in Haskell.
Sounds really bad right? In actuality this is what makes haskell so powerful. Haskell is restricting the programmer to only be able to create a program that is much, much closer to answering the question above. The best design and the best modularity sort of exist has nebulous and instinctive concepts in most programmers. With haskell this concept comes closer to concreteness because Haskell simply doesn't allow you to write certain programs that are poorly designed or incorrect.
My first experience writing a non trivial haskell program was astonishing. Normally I program a little and test a little, then continuously add complexity to my programs through this iterative process of coding a little and testing a little.
With haskell I coded the entire program. Once it compiled it worked. No testing needed. I asked myself what was it that allowed me to do this in haskell? The answer was that it was because haskell prevented me from writing more programs that were incorrect. Errors and mistakes you would normally have to test for in other language can't even be compiled in Haskell. Nothing can totally eliminate testing but with haskell you can eliminate a huge portion of testing. So much so that programmers in haskell spend more time trying to get a program to compile than trying to test.
This power extends to refactoring. Most projects out there have problem domains that aren't fully defined and thus require refactoring changes in the future to better fit the problem domain. It's an inevitability. It often happens that such refactorings require massive and dangerous changes to code that has already accumulated immense complexity.
A common problem like this becomes trivial in haskell. Haskell forces your code to be modular so that such changes happen easily. The type system also ensures that if you do a change that is incorrect the compiler will catch it.
From a less tangible standpoint haskell also feels right. When you design things in other programming languages you're not sure where to cut your modules and how to correctly divide responsibility of your code and of course your mistakes become apparent over time. Haskell doesn't feel this way. It feels like the right approach to design and building primitives that snap together like legos. Over time this feeling will coalesce into understanding. You will completely understand why haskell programs are better designed then programs written in other languages.
I never mentioned performance. Although Haskell is very performant, haskell isn't suppose to answer the question of performance AND design (that's more rust) haskell just addresses design and safety. Additionally, it's not just haskell that has these qualities. It's actually the whole family of functional ML languages that haskell comes from that utilize Algebraic Data types and functional programming. You can achieve sort of the same philosophy I describe here by using something like Ocaml or Elm.
Also don't let the fact that haskell isn't mainstream put you off. Although it's not as practical, learning it is like taking the red pill. You'll never be the same.