3 ms·
While imperative, and not 'pure' even C was created to set upper bound of the number of iterations of every loop being known before entering, thus PR Dennis Ri
by nyrikki 2y ago
While imperative, and not 'pure' even C was created to set upper bound of the number of iterations of every loop being known before entering, thus PR
Dennis Ritchie's research at MIT was focused on what he called loop programming.
The complexity of loop programs - ALBERT R. MEYER and DENNIS M. RITCHIE
https://people.csail.mit.edu/meyer/meyer-ritchie.pdf https://people.csail.mit.edu/meyer/meyer-ritchie.pdf
Structured programming, the paradigm that almost every modern programmer follows by default is really pushing you to primitive recursive functions.
That almost universal acceptance of structured programming compared to the other two types, pop and functional, is why people are confused about Dykstra's goto is harmful paper.
While primitive recursive functions don't contain the entire set of computable functions, they do contain almost all intuitive ones that are guaranteed to HALT (total).
Unfortunately there are some real needs for languages to support loops that have an indeterminate number of iterations when you enter the loop, but it is a foot gun that is avoidable by only using them when required.
Even COBOL was modernized with unrestricted goto being moved to the ALTER command.
I can't think of a modern, useful language that doesn't allow for PR functions.
But even in C, if you avoid 'while', explicitly avoid fall through, etc... you will produce code that almost always is a total functions that will always HALT.
There are cases like even type inference in ML, which is pathological in that it is way cheaper than the complexity class, thus worth the risk, despite not being total functions that make it hard for a language to restrict those use cases.
So I would say that with a pragmatic approach, all languages support defaults that support most of the points, but imposed constraints that enforce them would seriously constrain the utility of the language.
If you review even the hated SOLID and Clean frameworks, they're pushing you towards this model too IMHO.
I think the universal acceptance of structured programming, makes this easy to forget or even fail to teach. But as an old neck beard, we were taught the risks of WHILE etc...