Hacker News new | past | comments | ask | show | jobs | submit login

Yeah, pretty much. All languages have design patterns, but somehow everything in Java becomes a Pattern. So whether something is called a pattern or not is definitely very culture-dependent.



I think this about monads in Haskell. They're a design pattern (well, several different patterns). They just aren't called that.


Design patterns are considered to be things that you can’t express directly in the language (that’s the Design Patterns book definition). Monads can definitely be expressed directly in Haskell. The only thing you can’t do is prove the Monad laws in Haskell (I think?).

Other languages, like e.g. Rust (because of lack of HKT), cannot express monads like Haskell can.

But yeah, you can definitely call it a design pattern if that’s what the culture around the language is like. But it would be like Java folks calling interfaces with default implementations for something goofy like “Interface with stateless implementations pattern”, and even they don’t go that far.


Late reply; I didn't see this earlier.

But in Haskell, a lot of the time you don't use a monad because you want a monad. You use a monad to do something else - to log in a pure way, for example. That use of a monad to solve a particular problem is a pattern.

I'd even argue that it's using the pattern to compensate for a weakness of the language. (Or, if you prefer, to help with things that are difficult within the language design and philosophy.)


That's sometimes called language idiosyncrasies.




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

Search: