Haskell for a New Decade [pdf]
dev.stephendiehl.com
dev.stephendiehl.com
Haskell is about programming language researchers and enthusiasts having a excellent example language to try out ideas. Over the years it has turned into a production ready platform.
As the PDF shows there are many languages spun off Haskell and it doesn't even mention them all. Then there are language features in C# and Java, Typescript etc. that are coming across from Haskell.
I think the problem with Haskell as a language as a mainstream thing is that it requires a lot of upfront investment to get used to. C# -> Ruby is 10 hours to be productive, 100 hours to be reasonable. C# -> Haskell is ten times that.
A lot of stuff to get your head around. There are complex topics from category theory to metaprograming. Sure you can ignore it - until you want to use a web framework that uses those concepts, then it's on you.
Instead of Haskell we should be thinking of programming language research and how to get the best ideas into our mainstream languages. How do we make immutability easy and ergonomic and get rid of nulls in C#? Can we have guarantees in our program. There are even features not in Haskell proper like Liquid Haskell that would be interesting to have in C# or Typescript.
This is what is needed if we want the Haskell ideas to be popular. That might not be what other people want.
I see a lot of this happening in Kotlin and Rust (not too mainstream, but clearly more mainstream than Haskell). Also FB putting it weight behind Reason/OCaml clearly shows the movement. To be fair: sdiehl did mention in the preso that copying these concept over to other languages takes 10-20 years.
> How do we make immutability easy and ergonomic and get rid of nulls in C#?
The problem here is: you dont. To some extend you have to get these things right from the start. The father of null, Tony Hoare, now considers it his $1B mistake. Why? Because this is hard to fix.
> Can we have guarantees in our program.
Sure you can. C# gives you some typing guarantees. Now pattern matching switch statements (with exhaustivity checking) combined with sum types are coming: this will help! But the guarantees that Haskell (and Idris/Elm/PureScript) bring are next level, and impossible to replicate in a language that does not encode purity in the type system nor has type classes.
But only at the most superficial level. It was heartbreaking to hear Kotlin ignore decades of Haskell and Scala experience when it couldn't be condensed into a 10-line example. They've adopted a fundamentally broken approach to representing absence and they'll regret it in 10 years, but it's already too late to fix it. Heck, look at Go ignoring Java's experience with not having generics.
Also, it's very common to have option-style code and as your code evolves you need to refactor it to either/result-style code (that includes a reason why something was not present) - indeed I'd say this almost always happens in code that lives long enough. In kotlin this is unnecessarily difficult because it's impossible to write code that works with both nullable types and an either/result-like type, and since null has special language-level support you can't even use the same syntax.
Recent JVM libraries have (rightly) moved away from null. Using e.g. JDK8 streams from Kotlin is very cumbersome (noticeably more cumbersome than using them from Scala). The special treatment of interop also creates a bunch of special cases in the language that break your usual assumptions: extracting a common method call won't always work, adding explicit types can change behaviour. It's one of those things that looks like a good idea in the small but creates more problems in the large.
> And with some annotations, Kotlin's nullability support can be applied to those existing libraries.
Again this is a case of Kotlin refusing to learn from history. Look at what happened with the JSR308 checker and adding nullness annotations to existing libraries. Someone adds the annotations and everything seems great, then other people make changes to the library and don't maintain the annotations and they become lies.
> As for zero overhead, an Option or Optional is another object, and the overhead of that object can't be completely optimized away by the JIT.
People who care about zero overhead wouldn't be using Kotlin in the first place. The raison d'etre of the JVM is safer programming with fewer crashes, even if that means a little performance overhead some of the time. (For the record you're wrong: in the cases where the JVM stack-allocates an option or optional the memory pattern is exactly the same as if you'd used a nullable value instead. But that's not the point).
Depends on the target platform. When developing for Android, one can't entirely escape the JVM (or rather, ART), and developing entirely in a JVM language eliminates JNI overhead. And I'm guessing ART doesn't have all the advanced optimizations of HotSpot.
What language features in Java came from Haskell?
Can you name any design characteristics in Java's stream API that came from Haskell, rather than were already common in many languages when Haskell itself was designed? I can't.
It does conventional inlining and combining loop bodies, which can in some trivial cases achieve the same effect, but these are techniques you'd find in any compiler or even an 80s text book - they didn't come from Haskell.
Here's the limitation of Java's 'fusion' - you'll notice there's no pass to do this in Hotspot - it just happens due to the inlining and GCM passes.
https://github.com/openjdk/jdk/blob/883a4f65b9b1533c8a51d156...
And here's a paper on trying to add actual Fusion to Java, which they wouldn't be doing if Java had it already.
https://dl.acm.org/doi/pdf/10.1145/3355378.3355386?download=...
Once in reference to something that they didn't do (algebraic types), and once in reference to that both Haskell and their work were being inspired by an earlier common idea (System F) from the early 1970s.
I hear you though. I was mostly a lisp person and only really got into Haskell in the last couple of years. Even still I would have said that the FP zeitgeist had Haskell as it’s central example of FP.
For example, this ya the earliest reference to clojure I could find on hn. Notice the text of the announcement and how it focuses on parallelism https://groups.google.com/forum/m/#!topic/comp.lang.lisp/xvK...
The problem is while you can adapt and bolt on some functional programming techniques to existing languages like C# - to bring the power of the type system to an existing language is all but impossible. There are a few areas it has started to sneak in, like nullable types. But from my naive perspective you just can't bolt on an expessive type system like that, let alone a dependently typed one.
To the grandparent, assuming the trouble was as I understand it, the idea is to split your state and advance one new state down the lazy list while the rest of the computation uses the other new state.
Eliding constraints for brevity, if you have:
split :: g -> (g, g)
random :: g -> (a, g)
then you can say lazyRandomList :: g -> ([a], g)
lazyRandomList oldState =
let (listState, newState) = split oldState
in (makeList listState, newState)
where
makeList inState =
let (value, nextState) = random inState
in value : makeList nextState
When you match on the outer tuple, the split gets forced, but `makeList listState` is still a thunk. You can go ahead and use `newState` all you want without forcing it.Once you force it, you have a cons, with two thunks that can be forced independently. The tail evaluates to a similar cons produced from a different state. A lazy list.
It's true that it's infinite, but you can fix that (if you want to) by taking the head (perhaps a random number of elements); it's easier to control the distribution of length that way than with some fixed chance you produce nil at each step, although that approach works too.
It's not difficult to create a stateful computation in a non-strict runtime environment. Laziness is compatible with (local) state. Haskell's random package is designed around explicitly threading the PRNG state through the computation:
import System.Random (Random, RandomGen, random)
import Data.List (unfoldr)
randomList ∷ (Random a, RandomGen g) ⇒ g → [a]
randomList = unfoldr (Just ∘ random)
Since the function passed to `unfoldr` always returns a `Just` value, the resulting lazy list never ends. If you're not familiar with `unfoldr`, it's essentially the opposite of `foldr`: instead of applying a reduction function to a list it produces a list by iteratively applying a generator function to a seed—in this case the PRNG state.As it happens, this function already exists as `System.Random.randoms`. You use it like this:
main = do
(xs :: [Int]) ← randoms <$> newStdGen
mapM_ print xs
There are related functions `randomR` and `randomRs` which take a lower and upper bound in addition to the state.If you were trying to achieve this effect with `randomIO` or `randomRIO`—perhaps to avoid explicitly threading the state—then you will run into difficulties. Not because of laziness; rather the contrary. The problem is that IO actions are strict by default, so you can't easily combine them to create a lazy list. You would need to use something like `System.IO.Unsafe.unsafeInterleaveIO` to defer the generation of the random values until they were actually demanded, but then you're mutating the shared, global PRNG state each time an item is evaluated from the list and the result would not be deterministic or repeatable even if you started with a known seed.
Of course in a strict language with a decent type system like Scala you eventually find you want to use that style anyway. But you can come to it in your own time and see the benefits for yourself rather than having it forced on you.
Basic Haskell is lovely though. It's why I liked Elm initially although it does take it a bit too far in the basic direction.
The problem with Haskell is it's purity and thirst for abstraction means more and more complex type definitions and ideas - monad transformers (yes I know they are supposed to be 'easy') - and GADTs for example. And if you want to use libraries, you need to get these concepts to merely be able to read the example code. It's table stakes like known what "npm i" means when looking at a node module doco.
Javascript on the other hand, for all it's warts, allows you to cheat by wrangling directly with the data. This has a lot of issues but it is a lot easier to grok - to the point where non programmers use it as a scripting language. Sometimes people do some weird shit with proxies/promises - and you'll get that type of code in any Turing-Complete and useful language, but on the whole most libraries do keep it simple and scrutable.
> The problem with Haskell is it's purity and thirst for abstraction means more and more complex type definitions and ideas [...]
If that's the case something goed wrong. Proper abstraction means having complex definition with simple types!
Maybe I'm missing something?
I was in a Haskell team at Google, and have trained groups at various companies professionally. From that experience, for a normal developer with working experience in Java, Python, or C++:
* It takes 2-3 weeks of full-time onboarding (half with a coach, half self-study) to work on a typical industrial Haskell project.
* It takes around 3 months of full-time participation in such a project to know a wide array of libraries and feel ready to tackle almost anything.
The companies involved were happy to make this time investment for increased productivity over the time they expected their employees to stay with them.
On an individual level, it makes sense that if you're just getting into programming, and you have the choice between investing 2 weeks into Python to be productive, or 3 months for Haskell, you pick Python. It's rational. But after you've been in it for a few years, and you realise you want to do it for another 40 years, investing 3 months for life-long increased productivity (even if it's just a few percentage points; most feel the effect is larger) suddenly becomes a great deal.
Counter point on "complex topics":
After 6 years of industrial Haskell, I know nothing about category theory. It has not prevented me from using web frameworks.
with rust, by contrast, which is ostensibly much less general purpose and hasn't been around as long there's already quite a collection and it's easy to see why it was chosen for those things.
Haskell jobs do exist, I have one of them. The big problem is that there are more people who want to do those jobs than there are jobs, so they seem very scarce.
But anyway there are also a number of investment banks I have heard that use Haskell as their “secret weapon” and do not advertise it, in fact those who could speak to details are all under NDA.
Personally I am hoping to help with this issue by building cool open source things in Haskell (and purescript)
I was skeptical for years for all the reasons you said, but I finally decided to set my skepticism aside and see for myself, and oh boy is Haskell great. It has a lot of problems, but I consider myself at least 2x more productive in Haskell.
Both Standard Chartered and Barclays loudly advertise that they use Haskell.
A quick web search turns up their job offers on Reddit, and both also send people to conferences such as Haskell eXchange, to talk about their team tasks, structure, and size. Example: [1]
Their code bases were discussed on HN before, e.g. [2].
Standard Chartered also funded the development of GHCs low-latency, non-stop-the-world, incremental GC, for 2 years until it was recently released [3].
[1] https://skillsmatter.com/skillscasts/9098-haskell-in-the-lar...
[2] https://news.ycombinator.com/item?id=13073605
[3] https://www.well-typed.com/blog/2019/10/nonmoving-gc-merge/
For stuff that doesn't require that runtime (as convenient as it is) they just use familiar old lazy GHC. My understanding is that they are progressively moving more and more to GHC, although my knowledge is five years out of date.
A genuine one. I remember a presentation by a bank about their use of Haskell, and wasn't sure if it was Standard Chartered. I remember they had the subset, and mentioned they basically had to a lot from scratch to interface with various systems.
And now that I have the name, I found a link to someone's copy: https://dshevchenko.biz/hs-research/Haskell-in-the-Large.pdf (used to be available at code.haskell.org). My recollection of the paper isn't perfect :)
> My understanding is that they are progressively moving more and more to GHC, although my knowledge is five years out of date.
Ah, thank you!
I remember hearing this said about Perl back in the day! Language X is so awesome businesses use it in secret because they don't want their competitors to discover the secret to their success.
Not saying it couldn't happen, but you can say it about any language and it can't really be disproven.
This is why we need more publicity-visible Haskell success stories.
Really the thing that convinced me to really dig into haskell was that there were so many things that I wanted to learn but so much of the extra information had roots in haskell topics. So i basically said "to achieve my goals I need to know haskell even if i never use it for anything practical".
Slowly, as I learned more, I realized it is great. I wish I had chosen to learn haskell 10 years ago instead of like two years ago.
Everything you said is from the perspective on being not only in a Haskell job but in a Haskell team. Your 3 months is 5 years for someone trying to learn on their own in their spare time. And then they need this to get a Haskell job due to the competition for such job and the queue of super smart people lining up for a Haskell job. And the pay cuts are brutal. Now you are an outlier, working on a Haskell team for Google, the rare triad of using Haskell at work, presumably being well paid, and having that mentorship from other team members.
> After 6 years of industrial Haskell, I know nothing about category theory. It has not prevented me from using web frameworks.
As someone in as Haskell team, maybe this is possible. You don't have to try and pick apart the online knowledge. For example a lot of libraries use Lens. I want to understand Lens? It is not simple: check out the diagram on https://hackage.haskell.org/package/lens. "Yeah but it's just X Y Z". Great - I've been to many FP meetups, and seen a lot of stuff online and there is no simple help for this stuff.
You're making it seem harder that it really is. Yes, it's hard if the package documentation is all you have, but that's the hard way to learn. There are other online unofficial documentation and tutorials (of diverse quality). There's also a book (https://leanpub.com/optics-by-example) that I find adequate for a reasonable learning experience (I think I would have saved much time if I had started learning lens using this book.). And, you don't need to know the entire lens package to use it. The most commonly used part of lens (Lens proper, not Prisms, Isos, etc) is only a small fraction of the whole thing.
You can skip the theory and go straight to usage: https://www.youtube.com/watch?v=QZy4Yml3LTY
I learned the key parts of Haskell in 3 months of my spare time from university (where I had much less spare time than I have now in industry). And that was at a time where learning Haskell was much harder than it is now; today there are a lot of really detailed books, tutorials, and videos available, tooling works out of the box with few surprises, and error messsages are way better.
Of course learning in your spare time does not give you as much practical experience and feedback as you get on a job, but it gets you enough to get into such a job.
> You don't have to try and pick apart the online knowledge.
Not any more.
* Step 1, buy a beginner book and work through it.
* Step 2, work through FP Complete's [1] Applied Haskell Syllabus (https://www.fpcomplete.com/haskell/syllabus/). This will make you comfortable with most day-to-day data structures, techniques, testing, benchmarking and so on.
* Step 3, practice building some small applications that you think companies will actually need. Web servers, input validation, streaming data processing, and so on. It doesn't have to be fancy or use "cool" techniques, it just has to be /useful/.
* Optional Step 4, for extra hireability: Become better-than-average in a specific topic. This could be testing, performance, developer tooling, documentation, web stuff, anything that gets your juices flowing. Do a bit of open-source work in that area. Go to some meetups or conferences to see who's hiring, what they are doing, and what might be useful for them
> I want to understand Lens?
Again, you don't need to do that to get a job. I've conducted ~ 40 technical interviews for filling Haskell positions for various companies, and none required this. What is required is that you can do normal /useful/ things, with the high amount of correctness, clarity, refactorability, and reliability that Haskell provides.
Haskell, like mathematics, knitting, and C++, offers near infinite avenues of special topics that you can deep-dive into if you want. People talk about those at meetups because they excite them. But you don't have to do that to build useful software or get a job.
[1] This is the consulting company as part of which I gave most of aforementioned training. It makes most of the training material publicly available.
I think it is quite common, even for people who want to understand things at a fundamental level, to just use stuff without said understanding.
(If you don’t want to go into how plastics are made, &c — but that stretches the metaphor way too far)
Compare that to Erlang's half a day to a day for onboarding, and one to two weeks before pushing stuff to prod.
I can't imagine any company that could afford three full-time weeks of onboarding.
> investing 3 months for life-long increased productivity (even if it's just a few percentage points; most feel the effect is larger)
The tales of increased productivity are purely anecdotal. Especially if you're talking about a few percentage points.
Oh yes. Months even. Routinely.
Erlang's a half day for onboarding if you're onboarding a Haskell programmer, not because Haskell programmers are that awesome but because they've already had to learn the hard things involved in Erlang to work with Haskell [1]. Otherwise, that's ludicrous nonsense. Most programmers will need several hours just to figure out how to write the equivalent of lists:map in the new Erlang, immutable world, more hours to figure out how to write things non-trivially with it, and a good couple of weeks at a bare minimum to figure out how to structure applications in an OTP world, then some more time to figure out how to debug it.
It's not especially harder than learning SQL or the latest Javascript framework or other things that aren't Algol-descended languages, but it's nowhere near that easy.
[1] I went the other way. I found Erlang an excellent introduction to Haskell; you get to absorb some of the challenges like working in pervasive immutability in an environment where you're not also swallowing a complicated type system or strict effects separation.
There are plenty of cases where a broken notebook is about as good as a spreadsheet, and languages suited/typical to that use have a psychological victory that results in apples to oranges comparisons.
I think the difficulty of Haskell is overrated. It's just different. The crowd who complain about Haskell being hard despite x years experience are the same people who speak English and think Mandarin is hard.
And yet 1.7+ billion people speak Mandarin, and most linguists agree that English is actually the harder language owing to its more branched roots.
Haskell is what happens when you go full lambda calculus, and the dedication to referential transparency really forces you down some interesting paths/abstractions. It's also worth noting that other functional languages like OCaml and lisp do not force purity so the idioms are not as extreme.
The impedance mismatch essentially boils down to Turing Machine vs Lambda Calculus and as such you don't find many familiar friends when switching camp (to begin with, at least!) The Haskell idioms are very different and the consequences of referential transparency ripple throughout the way you need to think about computation.
It's also worth noting that Haskell is a language laid bare - much of the features and abstractions are plain-old functions which means you can "just" duck into them, implement them for yourself or read them as libraries. But what we often forget is all the abstractions we needed to learn when grokking "programming" (which was probably imperative style programming) the first time round. Most people have moved on from the time when trying to conceptualise what an object is or how methods work or even working with mutable state. When you get to design patterns - some of the implementations are quite complex the first time round. Eg the visitor pattern/double dispatch is not particularly simple when you sit down and manually expand the execution of those calls and yet when you use it, it's quite simple.
When we program with objects, most of us don't stop to think about vtables anymore* we just use the object to solve our immediate problem.
The more I see of Haskell, the more confident I am that it just uses a very different set of abstractions that you can just use and forget about except you get the benefit of a HM type system and referentially transparent code. It's also nice that that itself somewhat forces you towards a more functional-core imperative style architecture where your business logic is pure and mostly happy path code and your boundary is a bunch of monad imperative glue.
I think at the end of the day FP makes the hard things easy and the easy things hard. But as the Turing Machine and Lambda Calculus are equivalent then being adept at both schools is like having twice the arsenal for dealing with a given problem.
*naturally when performance becomes a problem you start to unravel abstractions.
Clojure does, in some degree.
But clojure is very strictly imperative. Atoms are easily accessible in the stdlib and side effects can be called inline and hidden within functions. This masks IO from a perceived return type.
Haskell differs here because it forces you down the path of "everything explicit" and "everything referentially transparent". Essentially monads emerge as a result of this, but their use definitely feels unergonomic in clojure
F# pretty much plays this role within the .NET ecosystem. Almost all of the important advancements in C# over the last few years originated in F# (and FP in general).
I'm convinced this is just FUD. Every language's main web framework has a bunch of complex concepts to learn - if you want to use Rails you're going to have to learn about ActiveRecord, metaclasses, whatever it is that rails uses for routing. By the time you've got productive in an enterprise-scale codebase, you've learnt just as much as if you were using Haskell - the only difference is that the knowledge is less transferable.
This is because reality is not intuitive, too.
Take natural numbers. They are utterly intuitive. Three-year-olds can grasp them. But as you try to calculate more and more complex things in the real world, you discover the need in counter-intuitive concepts like zero, negative numbers, fractions, even the aptly named irrational numbers. If you try to calculate √3 using the intuitive natural numbers, your solution will be rather approximate.
Same thing with many "intuitive" languages, from Basic-80 to ES6. You can solve a number of problems with them, but many solutions end up inexact and full of holes. In a lot of cases, this is acceptable, or seen as acceptable.
But when you need tools for a precise solution, you have to study some "advanced concepts" (another word for math) and take a language like Haskell which support them. Sometimes you end up with something as unwieldy as your average three-story analytic formula, but this is often not a shortcoming of the language but the nature of your problem domain, described correctly.
I feel like that's what the Scala people are doing. Yet the end result is that this kind of Scala code is just as slow to compile as Haskell, and just as hard to learn for newcomers as Haskell.
The difficulty lies in the concepts enabled by the language, not the language itself. Go read the GHC user guide, especially the part about language extensions, and you'll finish in an afternoon. Yet people are always coming up with new ideas and abstractions that use these language features in new ways. Haskell is an especially rich platform for new ideas and abstractions to foster. Lens is somewhat difficult to learn, yet in its simplest form it can even be used without any language extensions. (You won't be able to name the Lens or Traversal type itself without RankNTypes, but you just need to expand the synonyms; in other words it's just sugar.)
I started learning Haskell last week. I have a small rest service I need to write and I want to try something new. Why Haskell?
Because I miss seeing excellence/purity in computer languages. Nearly 10 years ago I jumped out of the Smalltalk balloon. It was one of the only languages where Object Oriented felt like a paradigm shift (CLOS and Self were also purist and paradigmy). It was sadly headed for the pile of lost languages.
I have spent the last many years polyglotting, learning and plying Python, Ruby, Objective C, some C++, Kotlin, Swift, Dart (both 1 and 2), Lua, Go, and even a smattering of JavaScript (plus coffee script). It's been a journey through language populism. Language features pulled from multiple disciplines and mashed together with no real rhyme or reason other than what crowd or favorite feature the steering committees cater to at any given point. Consistency and guiding principles seem to be a thing of the past.
I'm too new/naive on the Haskell journey to know what lies ahead. I've discerned that it seems to be one of the golden standards of "pure functional" paradigm. And at 49, I may be too old to be enlightened by another paradigm shift.
But what I yearn for is computer languages that feel like the design elements all work together so that the whole is greater than the sum of the parts, instead of languages with a checklist of "good ideas" that thrown together create a whole that is lesser than the sums of their features.
Will Haskell take me there? Time will tell. Wish me luck.
i don't mean to suggest Haskell is without flaws. but i do think you'll experience the paradigm shift as something concrete. there are almost no languages like it, after all.
For more information about the language, there was a great PDF published about the history of the language recently: https://download.clojure.org/papers/clojure-hopl-iv-final.pd...
Are you absolutely sure these language extensions are as bad as you think they are?
Lets look at what they asked for:
> But what I yearn for is computer languages that feel like the design elements all work together so that the whole is greater than the sum of the parts, instead of languages with a checklist of "good ideas" that thrown together create a whole that is lesser than the sums of their features.
- computer languages that feel like the design elements all work together so that the whole is greater than the sum of the parts
+ check
- instead of languages with a checklist of "good ideas" that thrown together create a whole that is lesser than the sums of their features
+ the key here is making sure that you have "a whole that is lesser than the sums of their features". Haskell's Language Extensions do not prevent composability that the language offers, so this is not as big a problem as you make out here
that said, I think it does require a bit of a 'paradigm shift' to learn haskell well, and if you're not up do it, clojure might be a better fit. But i don't think that would be motivated for the OP by the language extensions, but more from learning about laziness and lambda calculus.
I just mean that Haskell doesn't feel like a coherent, commercial language to me. It is basically a bunch of PhD thesis's strung together on top of a research language - with some of these being very interesting and incredibly useful. This is perfectly fine for what it is - but it also means the overall language and standard library have not been designed with a "batteries included" mentality that let people get going easily and quickly in a commercial setting.
I suggested CL/Clojure because those are both interesting, lambda-calculus based languages similar to Haskell (without the typing, unfortunately), with great, mature libraries for building any commercial project possible.
That said, a lot new of languages tend to opt for a minimal base footprint e.g. rust, so that has also been the trend lately.
I believe Scala is already such a language.
> There are even features not in Haskell proper like Liquid Haskell that would be interesting to have in C# or Typescript.
There are many advanced type system feature are very hard or mathematically impossible to implement in main stream languages. The reason Haskell can maintain its novelty is due to purist and minimalist approach on many aspect of the language.
For example, Hindley-Milner languages cannot add sub-typing. But it can easily infer the type of parameters and the return type of the recursive function, while Scala cannot despite the fact it's very advanced.
> C# -> Ruby is 10 hours to be productive, 100 hours to be reasonable. C# -> Haskell is ten times that. > would be interesting to have in C# or TypeScript
While I tend to agree, there are also many teams are also burnt by these languages because multiple paradigm actually makes things even harder. It's easy to be productive, but as people climbing the tower of advanced type, the code diverse, the idioms people speak diverse, too. It's not as easy as we thought to be reasonable. There are also many people in Scala community eventually found out it's better to just use the functional part only rather than mix everything.
Subtyping? Haskell has ADTs.
Will any of that be enough to bring the refactoring powers of Haskell? I bet not, you need the entire type system for that, and if you bring the entire type system, your language will become as hard to learn as Haskell.
Without the refactoring powers, you are stuck again into the old school "design it well or you'll suffer" development cycle.
Haskell needs to replace the standard prelude and burn the old documentation.
I have used dozens of languages and never really had any problems.
But the simplest of tasks in Haskell immediately put up roadblocks.
I’m sure if I had sufficient reason I could get passed these problems, but when easy things are not easy one loses interest fast.
It was a while since I was involved in that space, but at the time, you had things like the Text library to properly handle human text, ByteString to handle plain 8-bit arrays, Conduit and Pipes as two libraries to do streaming I/O (both network and file) with resource usage guarantees.
I'd love to help you with the roadblocks, but I need more specifics to do that.
Could you share a bit about your experience with sockets in haskell? I had the chance to use sockets in haskell on multiple occasions and they worked as expected.
> I discovered sockets were both broken and deprecated.
Just in case anyone gets the wrong end of the stick, "Haskell sockets" are both working and supported (quotation marks because there is no single blessed implementation: sockets are just a (few) library(ies)). When people want help choosing a library, I point them to https://haskelliseasy.readthedocs.io/en/latest/, which is an opinionated, curated list.
Post some code!
That said I've taken my focus off working in it professionally. It's such a chore to have to constantly justify it to newly-externally-hired management and inevitably get a top-down directive to rewrite. I'm done relying on managers and corporations to drive Haskell.
My focus now is freedom & independence. I've got plenty of hugs and impactful personal projects & Haskell advancements I'd like to undertake in the next 5-15 years, and nothing even sniffs Haskell as a tool for me building without thinking or exerting energy. Maybe my issue is I love Haskell but I am abjectly not a community member.
Compilers and interpreters. They don't have to be CLIs though. You can create languages to configure said cloud software :)
If you have a problem where intermediate performance (on the level of Java and .Net, better than Python or JS) is ok and people won't notice 100ms extra here and there, Haskell is viable. If it's not focused on low level IO, and deals with complicated stuff, odds are it's your best option right now.
I do not have real-world experience with Haskell, aside from little toy projects, but I have a lot of experience with other functional languages in the ML family and Scheme.
Idris 2 looks appealing, but they should have also mentioned other approaches like Fstar, Lean and Z3. I quite like Fstar since they are delivering a big verified code base, as implied by the name of the effort: Project Everest [1].
While theorem proving is the most general approach to verification, manual proofs are tedious and full automation might never be completely possible in the short term.
I would love to see someone pushing for a different approach. A toolkit where you can create DSLs with limited expressiveness, which in turn make it easy to build and verify things. The equivalent to Alan Kay's Viewpoints Research Institute efforts to build a minimal computation system, but with some verification guarantees.
This is a common approach in the Coq ecosystem, writing DSls for building things, and custom automation for them. See for instance papers by Adam Chlipala.
I wonder if increasing bloat is a permanent thing? Will software ever transition to a cycle of simplification? Has it ever gone through a simplification cycle in the past?
Physical engineering has some limits that push back on complexity. You can only cram so many gears into a Swiss watch. An item can only have so many parts before manfacturing becomes a nightmare.
What will push back on the complexity of software? Will it ever "break" in a way that we just do things differently?
And it would be strange to think that something like haskell could save us, when the compiler itself is such a beast. If something saves us, it will probably look more like FORTH or lisp or Prolog.
Yes; whenever smaller, but less powerful hardware replaced larger, entire bloated old platforms were discarded or ignored by a generation of new users.
Mainframe to micro to mini.
Desktop Windows to Android.
Not as a whole, but there have been some significant attempts. Maybe the most radical one I can think of is Chuck Moore's Forth systems. Every new version is simpler than the previous one. Arthur Whitney has done something similar with APL, A+ and k, constantly trying to remove non-essential features. A more mainstream example is Unix and Plan 9, the 7th version of Unix was simpler than previous ones, and Plan 9 was much simpler than Unix. There are also initiatives like suckless, which try to write simpler software.
I am sure there are many more similar examples. Trying to remove bloat and complexity is a very important goal for many developers. Unfortunately, the real world usually gets in the way (colorForth has quite limited hardware support, Plan 9 never included a full-featured web browser, suckless software is not too friendly for novice users...).
In my education as a programmer Haskell has a special place and the way I use filter, map and reduce in production JS code is a small reflection of that.
Ideas of Haskell have cross fertilized into many other languages, e.g. you can clearly see it in Rust.
A decade ago a friend paid a local company to build him a many-core compute server. I was fairly certain they'd under-spec'd the power supply. My favorite stress test was to build 32 copies of GHC at once, daisy-chaining each new copy to build another. Keep it running.
His computer started billowing smoke.
https://www.meetup.com/Berlin-Functional-Programming-Group/e...
Reminds me of this satirical post:
Could not agree more. I've put in a couple merge requests to the ghc Haskell compiler, and it's very difficult to even figure out what's going on, nevermind make a meaningful contribution.
For Haskell to succeed, it has to move away from rigid commitment to various pure functional paradigms and move to eager execution by default. But Stephen does not help this, just preferring to instead dig in more on expecting the reality of the rest of the world to change itself to accommodate the strictures under false pretense that the strictures are parochially better.
Haskell’s real failure to launch is not because of complex tooling issues between cabal & stack, not because of a big mess of compiler pragmas to get basic String functionality, not due to complexity of understanding monads or type classes.
The problem is that the stated benefits of pure functional programming are not actually benefits at least not when writing business software.
The slides (rather arrogantly) say we’re at the blood-letting and leeches stage of software. Well claiming Haskell is a solution is like inventing epicycles to explain orbits or elevate alchemy to a science. It wastes everyone’s time with artificial complexity substituted for advanced capability.
This to me, is the only reply thus far that addresses what I also perceive to be the fundamental problem with Haskell - it doesn't provide any new convenient tools to solve real world problems, while requiring one learns a bunch of useless abstractions that aren't used anywhere else in industry as a default (monads, laziness, immutability)
Should not be controversial at this point.
However the problem with the parent post of that it presumes Haskell isn't useful because of X, when clearly it's useful for many and changing X would make it not Haskell. That sort of comment isn't useful.
I think for as long as I have known Haskell (1992-) there has been interest in and a desire for a strict variant of Haskell. In 2020 it seems there are a lot more options for that, which is great, but they aren't Haskell.
this seems like some version of a No True Scotsman argument.
But more importantly, immutability is used everywhere in the industry.
How far do you want to take the eager execution thing?
Should we get rid of boolean short-circuiting?
Should if-statements evaluate both the true and false paths before choosing one?
Should compilers no longer remove dead code?
1. Talk about it in isolation: we enjoy Haskell, here's where we think it should go.
2. Place it in the context of the wider software ecosystem, as in these are the pros and cons, barriers to adoption etc.
What isn't effective is doing #2 while not trying to really engage with reality. If you just assume, contrary to evidence, that Haskell is the right way and the reason it's not adopted more is that everyone insists on doing things the wrong way, you will not convince anyone who doesn't believe this fairy tale already, and worse, you'll ensure you won't help yourself, because you focus on the issues you wish you had rather than the issues you actually have. Self-reflection is supposed to help you, and it only helps if it's a long hard look in the mirror. The approach of, "things aren't going the way we hoped but our assumptions could not possibly be wrong so we'll just examine everyone else's" is not generally useful, as it's nothing but a waste of time: you know you'll end up exactly where you started.
Has finally Haskell the problem of how to do destructive updates or not?
If it cannot do destructive updates, I am not interested. The kind of software I am called to build always requires destructive updates for performance reasons and secondly I am so used to assignment and all the design patterns around it that I don't think I should bother with something that does not provide that.
Looking forward to GHC 8.12 and linear types.
No "finally" about it. Haskell must have had destructive updates for at least a couple of decades.
PR_END_OF_FILE_ERROR
https://www.reddit.com/r/haskell/comments/foeyim/ask_what_is...
It appears Lisp has proven itself consistently, at solving difficult problems.
All this does not make me want to abandon Lisp for Haskell; Lisp is still more practical for most of my needs. But if I had to write a parser I'd probably first write it in Haskell and then translate it to Lisp, because Haskell expands the way you think about hard programming problems -- even beyond the realm to which Lisp expands it.
And yes, the syntax of Haskell (besides unary minus) really does feel like it's close to some kind of optimum.
EDIT: I should have clarified I guess - interested to hear the opposite arguments (as a neutral (C++) person :)).
I'd be interested in hearing from your Haskellers what it is about Rust that renders Haskell obsolete. As it stands, I can only construct straw men, and I'm not really willing to do that.
edit: and automatic currying
I do deeply appreciate Rust in how it supports serious functional programming idioms without requiring a GC. The value of immutable-by-default and single-ownership semantics have been infectious far beyond my direct use of Rust. But those very same features of Rust also make the pure function just a little more clunky in that environment.
Oh, and being literally unable to perform I/O (or any other computational effect) outside of the right context is such a clear win for me. Very few languages, even in the functional world, have such a strict separation. The architectural and mental benefits are outstanding.
Some concepts take on a surprisingly simple existence in Haskell. I recently discovered the Yoneda and codensity transformations, as so frequently discussed in Haskell... in the context of a Visitor pattern on a tree structure in Java. Visitors are literally Yonada-ified sum types, and I could only make that connection (and understand the ramifications and benefits) after seeing how it naturally arises in both languages.
It's catching on. Nim has the noSideEffect pragma (enabled by default if a function is defined with "func" rather than "proc"), and D has a "pure" annotation. Both are compiler-checked.
The upshot is that the two languages feel very different, encourage totally different programming patterns and give you different high-level trade-offs. They're far more complementary than substitutable, and I expect my future projects will mix and match both.
Rust is very nice, but when you've used it for long enough you start noticing the warts. I especially miss Higher Kinded Types from Haskell, and I'm constantly reminded of the lack of Functor and Monad etc. At some point I simply realized that for most applications, the generally lower performance of Haskell and the GC is really not a problem at all. I mean, it's not like it's Python slow—it's just a bit slower than C/Rust. The more advanced type system of Haskell is just so nice, that I feel it's worth it.
Rust may be the language that has finally dragged mainstream programming kicking and screaming into the 1970s (it's more or less the equal of Standard ML). It still has a ways to go to catch up with Haskell.