Hacker News new | past | comments | ask | show | jobs | submit login
Programming Requires Breadth of Knowledge (typeclasses.substack.com)
36 points by ghuntley on June 1, 2023 | hide | past | favorite | 3 comments



Once I learned how simple monads really are I found them a lot less scary, and something I could apply wherever I'm programming, not just in Haskell or another big-brain programming language. And no, not in the "a monad is just a monoid in a category of endofunctors, what's the big deal?" sense.

Monads are a design pattern. Period. You have an object, it has at least two methods: return and bind. Using these two methods together must produce results that follow the monadic laws. Okay, now go nuts with that, because you have a generalized way to sequence operations expressed as combinators with controlled "side effects". The monad encapsulates both the value transformations and the side effects. It's a neat pattern, but just another tool in the programmer's toolkit. Big brain come up with it, but no need big brain to use it. Now grug brain use monad too, trap complexity demon in crystal of monadic type.

I think the more we lose our fear of these cool concepts and treat them like ordinary programmers' tools, the more we might see Haskell used for grug brain stuff.

But really, Rust have enough big brain concepts for everyday use, close enough to Haskell without garbage collector complexity demon. Now where grug put programming socks?


What do you mean by “garbage collector complexity”?

Rust provides value-add over manual memory management but garbage collection is still way simpler to use (if the performance penalty doesn’t matter).


Garbage collectors are notoriously difficult to predict the performance of at runtime compared to deterministic object lifetimes. A GC program also requires many times as much available RAM as a deterministic-lifetime program to achieve the same task with the same level of performance.

Rust lets you code safely in much the same way as you would in a GC language, without the performance and determinism drawbacks of GC. You pay a bit for that in terms of following the borrow checker's rules, but that's not too much a burden once you decide to learn them and get used to them. There's a reason why Rust has supplanted Lisp and Haskell as the new smart kids' toy.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: