-
Notifications
You must be signed in to change notification settings - Fork 1
Description
(I find no elsewhere to comment, so I click the link for the feedback and redirected here. Correct me if it is the wrong place.)
First of all, I am not a fan of Kotlin. But I think it actually introduced some good things.
Technically, the following "familiar" code is effective more complex:
fun start(): String {
return "OK"
}
It introduces a block scope and a keyword return for local control (which makes the control jump to the end of the function body). Both are unnecessary and redundant at this point, even considered harmful.
This is bad because in fact both block scopes and keywords like return are quite complicated monsters in semantics.
Canonically, a block with lexical scoping is the rewrite of a lambda abstraction (i.e. a function in most languages) with an immediate call to that abstraction. This is quite heavy and certainlly a mental burden where the local scoping is irrelevant. Note the rewrite is adopted in many functional languages (both impure ones like Scheme and pure ones like ML).
OTOH, return, as a simplified (restricted) version of P. Landin's J operator, is a control operator. This is also quite heavy and unnecessary here.
Sadly, the restricted designs have been built-in in many languages decades ago, esp. ALGOL-like ones (C, Pascal, Java, JavaScript, ...). Abuse of them have already caused many indirect but real damages to industrial programmers who learned programming with a traditional ALGOL-like language:
- Most of them have poor knowledge of many basic topics about programming (languages), e.g. how scoping works.
- Even experts would suffer. I've seen someone who confused block scope and function scope contributed to the ISO C++ draft, and the bug was even missing by the editor.
- Most of them have little knowledge of some more advanced topics, e.g. how to compose the control operators properly in a language.
- Lack of the knowledge effectively prevents proper designs for powerful features on concurrency and scheduling of the computing resources being adopted in the modern languages.
- As another result of lack of such knowledge, some comtemporary languages retain stupid designs with no sound reasons.
- Why a function body must be a block in so many languages?
- Why even a lambda-expression in C++ must have a block as its body?
- Users are encouraged to think in improper (over-simplified) ways of computing with bad flavors, whatever hells of operational semantics they meet ...
- Why Python is that popular, then?
- Non-exhaustive industrial damages continue here...
I don't think Kotlin has done much right in its design. But at the very beginning, it provides a better choice here.