by benreesman · 4y ago · 0 comments
Every hacker in the peanut gallery deep-down knows that they should know Haskell and Lisp well. They resent the fact that their job or personal life or whatever doesn’t leave room to get serious about computation theory. And they vent this frustration endlessly on people lucky enough to have had the bandwidth at the right time to thoughtfully contrast computation with physical computing machines (the only person I know to stomp Lemire in AVX is a GHC hacker).
I’m kinda fat because I haven’t fixed it yet. People don’t know Haskell and Lisp well because they haven’t fixed it yet.
Neither is an appealing look.
Haskell 98 is a pretty awesome programming language. It's not the best fit for every domain, but you can write concise readable code in it. The type system is just sophisticated enough to let you model your domain, but not so sophisticated that it becomes a distraction.
A lot of modern Haskell code has the unfortunate property that the types of the functions are harder to understand than their implementations. Type inference is much more valuable when it's the other way round. You know that [a] -> [a] is the right type for the 'reverse' function, so if you get a type error, you're sure that you made an error in your implementation. Conversely, many modern Haskell libraries give rise to extremely complex types, even when you're doing something mundane like making an SQL query. When you get a type error, it's then anyone's guess whether you misannotated a type somewhere or made an error in your implementation.
I personally feel that partial types systems are the way forward. Type the 80-90% of your code that's easy to type without a fancy type system. Dynamically type the rest and write some tests for it. Fancy types make you feel smart (and in all seriousness are a fascinating and important research topic), but their practical utility is limited IMO.
Something like fully typed forms (so that e.g. <Input type='text' path='address.street' /> only works if your form data has a { address : {street : string} } + branded types for more custom data fields) is absolutely magical and makes working with lots of highly complex forms a breeze. Tests just don't compare.
But I eventually cracked the code and now it like where is deep enough to bury anything running Ubuntu. Let’s fucking break non-dynamic linking of libc because GNU.
NixOS is fundamentally wrong on a few key points. But it’s close enough to right to make everything else look ridiculous. Who doesn’t love never really knowing without rigorous audit what is running on my machine that’s highly optimized for Drepper’s career.
I had some pretty bad language instruction in college, but the professor teaching Haskell was the worst. Maybe it really was a case of "if you can't explain it simply, you don't understand it well enough.", but I remember everyone finishing that class (just barely) and nobody ever wanting to do use it again.
However, as an actual tool to do actual work, I really don't see why you would go about it for anything but very specific projects.
Well, it’s been paying my wages for the past eight years, so it’s incredibly useful to me. Are we services “very specific projects”? Are data processing systems? Are geospatial data munging? Are financial systems? Those all sound like mundane, every day projects, and they’re exactly what I’ve been working on.
And when it comes to “actual work”, that’s where Haskell truly shines - being able to fearless refactor code and iterate until the compiler is happy again is my favourite feature of Haskell. It’s not the “neat type system”, it’s the ability to not have to keep the entire project in my head at absolutely all times because I might forget to make a stupid change the compiler should have caught for me. The productivity is massive, once you’ve invested the time, but it does take time and it is an investment.
These systems make it easy(er) to model concepts in a mathematical way and this is my natural (or preferred?) mode of thinking. And they enable you to do it easily and ergonomically. What is there not to like?
(I know there are flaws at hand, even some potentially very debilitating flaws depending on your use case. But damn, I'd use these languages wherever I can.)
Interesting point. What is the purpose of type-declarations? To make implementation easier to understand, I think. When you know (and understand) the type of a component or function you know how to use it, and how to not use it, and thus how to write code that uses it and does what you think it should do.
But if types are harder to understand than the implementation, then types don't help much, do they?
I feel this is largely a lie. The type system is still a crippled language that is also incompatible with the runtime language. It possible to do some very specific things in it, but does it help you describe a system's data flows? Memory allocation patterns? GUI layout engine?
I think the solution is: Just use regular code, it works best. Use types to describe interfaces. Simple types, because with anything else you're painting yourself in a corner.
> It possible to do some very specific things in it, but does it help you describe a system's data flows? Memory allocation patterns? GUI layout engine?
I feel you're underselling quite a bit when you say very specific things, but again, perhaps this depends on the problem domain, your thinking style, your programming style or some other undetermined factor. Out of the things you mention, I would say a definite yes to system's data flows, weaker yes for GUI layout and no to memory allocation patterns, because that is a known weak point.
So in practice, I'll go for a language that allows me to do both easily, instead of going for something like Haskell where any imperative way of doing things is very painful (as well as other issues, of course). So why would I use Haskell and limit myself for fairly marginal benefit?
Luckily, this doesn't take as much time as it sounds, because exercise (and other time consuming things) aren't helpful for losing weight. Everything else yes, losing weight no.
That's because it's pretty much entirely about your diet, and exercising makes you hungrier, which makes it harder to comply with the diet.
That kind of lazy thinking "isn't even wrong." You learn haskell to become the kind of person who "has learned."
The ignorant imagine haskell is a promised superpower that will under-deliver "productivity gains." It's a new way of thinking and building software.
The lack of tech debt comes from there not being the horrible OO sins. OO is great but there is a lot of “assume not null” and L in SOLID violations in practice and it all adds up.
Haskell has explicit opt-in nulls (optionals) and there is no L to worry about as there is no subtyping.