3 ms·
This is related to something that I pondered about yesterday. In main stream languages, imperative programs require you to read the whole thing, while function
by kaeluka 13y ago
This is related to something that I pondered about yesterday.
In main stream languages, imperative programs require you to read the whole thing, while functional programs allow you to look at a function and derive its meaning only from its implementation: there can't be another influence on the outcome, as there are no side effects and types are -- in ML/Haskell family members -- precise. So referential transparency, in a sense helps you to read code depth-first, only looking at the relevant bits now.
As soon as you branch off from basic type systems and add in, for instance, subtyping or type classes or existential quantification, this ability is getting weakened. Now, in order to understand what a piece of code does, you need to understand some context: 'which implementation is it?', 'what do the possible implementations have in common?'. The effects of this small complexities add up until there's too much information to be kept in biological memory at the same time, the oldest thunk of information gets purged.
I do think that typed and pure languages have big advantages here: the information that I need is available immediately from looking at the type of the reference to it. If the types aren't funky, I can assume that it will terminate, throw no exception, not suffer from data races -- I can exclusively think about what it does, not how (btw, I'm not having one specific reference language in mind right now, I'm just thinking about what would be possible).