DEV Community

loading...

Discussion on: What programming concept did you struggle the most with?

Collapse
pj profile image
Paul Johnson

Early on in my career I think OOP concepts like inheritance polymorphism etc gave me the most trouble. After that I think Monads were probably the trickiest concept to grasp and one I don't fully grasp.

There's a wide variety of concepts I would like to learn e.g. dependent types.

Collapse
vtrpldn profile image
Vitor Paladini Author

I share the experience with OOP, it took me a lot of "this pen is an object, it has a method write() and an attribute color" example for me to finally learn it.

Considering monads, I have yet to step into FP for that sole reason, some concepts look real hard.

Collapse
pj profile image
Paul Johnson

I feel with monads experience using them in a variety of ways might be more useful than reading about it. My explanation of them would be "they're a reification of computation", which is totally useless unless you've already spent a bit of time with them practically.

Thread Thread
vtrpldn profile image
Vitor Paladini Author

Makes sense, oftentimes some concepts only "click" for me after a few weeks applying it naively.

GraphQL is a recent example, I was weeks into a project when I finally realized: "Oh, THAT'S why it is better than REST in this situation".

Collapse
austindd profile image
Austin • Edited

Monads aren’t nearly as complicated as people make it seem. It’s literally just a generic interface. Kind of like how you can have array.map, linkedList.map, or promise.map... all those types have a sort of common interface. Those are all “functors”. Monads are the same kind of thing, except in addition to map they have flatmap, which is basically just a different version of map which flattens nested results. This allows certain operations to be easily “chainable”. And that’s pretty much it.

Boom - monads!

Collapse
rad_val_ profile image
Valentin Radu • Edited

Monads are much easier to learn by example. If I tell someone: "Look, this is an Optional, this is how it works, the Optional is a monad. Now imagine you can apply this pattern to a whole lot of things, not just wrapping nullable values", they get it pretty fast and it's usually enough to get them rolling code using monads.

As for inheritance/polymorphism, I used to be somewhat confused about it too and I blame it on the myriad of articles and books that don't clearly differentiate between the two just because the easiest way to show polymorphic behaviour is through inheritance (which is by the way, something you usually want to avoid)

Forem Open with the Forem app