Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>how often does it happen, that you'd want to swap effects without changing program code?

Anytime you want to test (and e.g. don't perform the actual side effects but mock them)?

Or change from e.g. logging to a file to logging to a DB or syslog?

And lots of other cases!



Is this fundamentally different from simply providing different implementations of a “Logger” or “Database” interface? Why does the involvement of side-effects result in the machinery being so different?


That's what the OP is about: hiding implementations behind an interface.

Effects are different because side effects are impure which is not allowed by default in a pure language. Machinery is needed to hide the effects in effect-managing containers so they don't contaminate pure code.


I understand that, what I’m trying to understand is if there’s a claim being made that such machinery is especially desirable in this circumstance... is this claimed to be “the way you have to do it in pure languages” or “a really nice way of doing it, which is enabled by language purity”?




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: