4 ms·
When you think in types rather then objects it makes more sense. Or at least I think `+(u, v)` or `u + v`, is more natural then `u.plus(v)` or `u.+(v)` I the f
by runarberg 12y ago
When you think in types rather then objects it makes more sense. Or at least I think `+(u, v)` or `u + v`, is more natural then `u.plus(v)` or `u.+(v)`
I the former case u and v are of numeric types that fulfil some numeric properties, so no interfaces are necessary, they are implied.
- RivieraKid 12y ago> Or at least I think `+(u, v)` or `u + v`, is more natural then `u.plus(v)` or `u.+(v)` I definitely agree with that, I said that object.method() style is often more natural. Typically when you have an object with some internal state and you want to send a message to it that will change its state. For example: threadPool.run(command) feels more natural than run(thread_pool, command).
- jghn 12y agoIt's more natural to you (and to be fair, most programmers who have used OOP languages) purely because you're used to languages which work that way.
- RivieraKid 12y ago> purely because you're used to languages which work that way. You don't know that. I think that for people new to programming both styles can be natural, depending on the specific situation.
- jghn 12y agoI agree, and that was largely my point. People discuss certain styles as being more natural, but in nearly every case (including this syntactical debate) I assert that it is solely due to what the most mainstream languages do and thus what people are more used to seeing. That's not the same as being natural
- andreasvc 12y agoNo, it is not some arbitrary choice, it confirms to the [second] most dominant word order in natural languages: subject-verb-object.
- canjobear 12y agoIn fact, the most common word order in natural languages is subject-object-verb. https://en.wikipedia.org/wiki/Subject%E2%80%93object%E2%80%93verb#Incidence https://en.wikipedia.org/wiki/Subject%E2%80%93object%E2%80%9... But SVO is a close second, and certainly more common than verb-subject-object (the equivalent of `function(arg1, arg2)`).
- desdiv 12y agoIf a language makes the dot and the method invocation brackets optional, then `u + v` and `u.+(v)` would be semantically identical. The former would just syntax sugar for the latter.