Remix.run Logo
tubthumper8 2 days ago

Genuinely curious for all these follow up questions:

Is immutability exclusive to functional programming?

Is the ability to use data/values exclusive to functional programming?

Are monads exclusive to functional programming?

For discussions like this, how do we separate "it was done first in functional programming but can also be done in procedural programming" with "it cannot be followed outside of functional programming"?

greener_grass 2 days ago | parent [-]

> Is immutability exclusive to functional programming?

No, but immutable defaults are powerful.

E.g. in JavaScript / Python, the built-in lists and dictionarys (which are blessed with special syntax) are mutable.

> Is the ability to use data/values exclusive to functional programming?

No, but expression-orientation makes this less painful

> Are monads exclusive to functional programming?

You can hack them in by abusing co-routines or perhaps async/await in various languages, but it will never be as good as something built for this purpose.

Type-inferences, type-classes and do-notation make monads workable in practice.

yazzku 2 days ago | parent [-]

You don't need coroutines or async or anything complicated to model monads, just functions and data structures. Search for "c++ monads" and you'll find a ton of examples.

greener_grass 2 days ago | parent [-]

You need the syntax if you want it to actually work well in practice.