3 ms·
> Haskell has had a profound impact on the way I think about programming and how I architect my code and build services. > And I've had a lot of fun micro-opti
by setopt 2y ago
> Haskell has had a profound impact on the way I think about programming and how I architect my code and build services.
> And I've had a lot of fun micro-optimizing Haskell code for Project Euler problems when I was studying.
Sounds a lot like my experience. I never really used Haskell for "real work", where I need support for high-performance numerical calculations that is simply better in other languages (Python, Julia, C/C++, Fortran).
But learning functional programming through Haskell – mostly by following the "Learn you a Haskell" book and then spending time working through Project Euler exercises using it – had a quite formative effect on how I write code.
I even ended up baking some functional programming concepts into my Fortran code later. For instance, I implemented the ability to "map" functions on my data structures, and made heavy use of "pure functions" which are supported by the modern Fortran standard (the compiler then checks for side effects).
It's however hard to go all the way on functional programming in HPC contexts, although I wish there were better libraries available to enable this.
- nextos 2y ago> But learning functional programming through Haskell [...] had a quite formative effect on how I write code. I think it is a shame Haskell has gained a reputation of being hard, because it can be an enriching learning experience. Lots of its complexity is accidental, and comes from the myriad of language extensions that have been created for research purposes. There was an initiative to define a simpler subset of the language, which IMHO would have been great, but it didn't take off: https://www.simplehaskell.org https://www.simplehaskell.org. Ultimately, one can stick to Haskell 98 or Haskell 2010 plus some newer cherry-picked extensions.
- gtirloni 2y agoSounds a lot like the C++ experience. In my time learning Haskell a decade ago, it was rare to find some code that wasn't using an experimental extension.
- bbkane 2y agoI think Elm is a fantastic "simplified Haskell" with pretty good beginner-friendly guides. It's unfortunate that Elm is mostly tied to the frontend and has been effectively abandoned for the last couple of years. Interestingly, Elm has inspired a host of "successors", including Gleam + Lustre, which look really great (I haven't had a chance to really try them yet).
- nextos 2y agoWhat about Roc or Koka? Or simply moving to OCaml? It's looking pretty great after v5, with multicore and effect handlers.
- giraffe_lady 2y agoOCaml is great but the type system is actually quite different from Haskell's once you get into it. It also has many "escape hatches" out of the functional pathway. Even if you approach it with a learner's discipline you'll run into them even in the standard lib. With haskell you can look to the ecosystem to see how to accomplish specific things with a pure functional approach. When you look at ocaml projects in that way you often find people choosing not to.
- mattpallissard 2y agoOh but the OCaml module system is the bees knees.
- giraffe_lady 2y agoYeah I didn't mean any of this as a negative lol. I haven't touched haskell since I learned ocaml. I still think haskell has the edge as an educational language for functional programming and type systems though, which is kind of what we're talking about but not entirely.
- mattpallissard 2y ago
- l5870uoo9y 2y agoPure functions are a crazy useful abstractions. Complex business logic? Extract it into a type-safe pure function. Still to "unsafe"? Testing pure functions are fast and simple. Unclear what a complex function does? Extract it into meaningful pure functions.
- ayakang31415 2y agoHaskell sounds like a good language to hone your programming skills. What kind of projects is Haskell suited for to get started (besides Euler project)? I use Python primarily for scientific research (mostly numerical computation).
- setopt 2y agoI didn’t play with this myself, but I’ve heard good things about writing parsers in Haskell (e.g. the Parsec library and friends). Hell, even Pandoc is written in Haskell and that’s arguably the king of document parsers. So that could be one area. I also heard cool things about QuickCheck, which I think is the inspiration for Hypothesis in the Python ecosystem, if you want to explore more how to do testing. Perhaps the “Real World Haskell” book might be a good fit to see other possible projects. Except the obvious functional programming concepts, one thing I enjoyed exploring in Haskell was “infinite data structures” and “lazy evaluation” – like how you could provide a recursion relation to define an infinite list of numbers, but only the finite elements in the list you ask to print are actually calculated behind the scenes. This “lazy evaluation” can be used to build algorithms that would be completely unreasonable in any other language. I also liked how easy it is to define new data structures. Like implementing a minimal tree data structure can be done in literally one line of code, which is just ridiculous compared to most languages that I’ve tried.