Re:Java Without If
by mannykannot on Saturday January 28, 2017 @10:23AM
(#13506657)
Opaque control structures like if/then/else? They seem to be pretty clear when used in human languages.
Re:Java Without If
by chriswarbo on Saturday January 28, 2017 @01:02PM
(#13507741)
"Opaque" as in completely uninspectable, unknown and unknowable to the language itself; as opposed to methods, which can be discovered, inspected and manipulated via reflection.
What real difference does it make whether repeat is a method on integer objects or whether it takes an integer argument?
Re:Java Without If
by chriswarbo on Saturday January 28, 2017 @01:09PM
(#13507779)
Because a method on an integer object would mean it works in the same way as all library and application code; and therefore can be used as-is, or avoided by those who don't want it, or replaced if something better comes along.
Having "for" not be a method on an object means it's something completely different: a magical keyword control structure, a gift from the irreproachable language designers to the lowly language users; since mere users cannot be trusted to make such decisions for themselves.
Whenever I write Java (or Java-like OO), I always have this exact "separate language within a language" feeling.
I'm supposedly working in a high-level, object-oriented, loosely-coupled, message-passing/dynamically-dispatching world of classes and instances; yet an awful lot of code is actually written in a separate language of "primitive values" with opaque control structures like if/then/else, for/while, etc.
Compare this to e.g. Smalltalk, where "ifTrue" is a method on boolean objects, "timesRepeat" is a method on integer objects, etc.