DEV Community

Discussion on: Explain Haskell like I'm five

Collapse
 
17cupsofcoffee profile image
Joe Clay • Edited

Haskell is a language which places a lot of value on the idea that functions should only be able to have effects on the things that they return. In Python, for example, there's nothing to say that calling add(1, 2) won't also change your desktop background to a picture of a unicorn. I mean, it probably shouldn't, but it could. Haskell is designed in such a way that stuff like this isn't possible (or at least, can't be done without you knowing it's happening).

As with any programming style, this has upsides (the flow of data through your program is much easier to understand) and downsides (sometimes you do want to affect the world outside of your function, and it can be a little tricky).

I don't tend to write Haskell very much, but I feel like learning it has changed how I look at code in other languages for the better - it's definitely worth giving it a go!

I'd recommend Haskell Programming From First Principles as a good starting point for learning the language - it's a paid book, but the first 92 pages are free.

Collapse
 
idanarye profile image
Idan Arye

Haskell is a language which places a lot of value on the idea that functions should only be able to have effects on the things you pass into them.

Actually, no - functions in Haskell are not able to affect the things that you pass into them. They are only able to affect their own return value.

Collapse
 
17cupsofcoffee profile image
Joe Clay • Edited

Whoops, yeah - only affected by the things you pass in, only has an effect on the return value. You're totally right, I'll update my comment.

Thread Thread
 
terceranexus6 profile image
Paula

Thank you both guys!