3 ms·
"These operators increase the burden to learn Swift as a first programming language" It looks like they may be trying to make it easier for current tweens that
by ra1n85 11y ago
"These operators increase the burden to learn Swift as a first programming language"
It looks like they may be trying to make it easier for current tweens that would have otherwise learned PHP.
Don't see the value in this. These operators are terse, well known, and are implemented in a wide array of languages.
- JoeAltmaier 11y agoWell known for old timers. But some folks have an actual issue understanding them. For those of us that are comfortable; fine, no issue. But they are a little strange; the order of operations in a complex expression can be hard to tease out for novices. Are they worth it?
- Nadya 11y agoWhat about for beginners like me who instantly understood `++` and `--` as increment/decrement but avoided `+=` and `-=` for being rather nonsensical? This half-reeks of something that a professional/advanced user thinks trips up beginners without actually tripping up beginners. Or they have an anecdotal sample size of n < 10 and decided since it confused 1 person that 10% of people get confused.
- cballard 11y agoApple has a long history of readability over terseness. "plus plus" doesn't mean anything. It might even be confusing that it doesn't add 2.
- dstanko 11y agoFrom Swift documentation: for i in 0..<count { print("Person \(i + 1) is called \(names[i])") } This ..< operator is so much more logical, of course! Not to mention == and ===. Logically, the first one compares twice and the second compares three times (for luck), just in case first two comparisons didn't go through...
- deleted 11y ago[deleted]
- cballard 11y agoI would implement that like: zip(names, 1...names.count).forEach { name, index in print("Person \(index) is called \(name)") } Or, in an ideal world: zip(names, 1...names.count) .map({ name, index in "Person \(index) is called \(name)" }) .forEach(print) Currently, that isn't valid Swift, "print" can't be used like that, though if you define a closure it works: let printIt = { x in print(x) } zip(names, 1...names.count) .map({ name, index in "Person \(index) is called \(name)" }) .forEach(printIt) I think that Swift could use = for equality, since assignments return Void and comparison returns Bool. Maybe it should. But your argument boils down to "if you can't be clear everywhere, don't be clear anywhere". That's not a good goal.
- dstanko 11y agoMy argument ultimately "there are better things to do". At the same time, interpreting ++ as add-add is certainly not an argument. You can say that you don't like infix and postfix operators, but not whether they are readable. If you consider readability, then why !a instead of not(a)? Why || instead of or?
- Shish2k 11y agoSpeaking as somebody who has no idea what X..<Y means, I assume it means "start from X and carry on for as long as you are less-than Y"? Is that correct? I wonder what somebody who had no idea about X++ would guess it meant? Based on my daily conversations, if I didn't know already, I would guess it means "variable X has done a good job and deserves some IRC karma"...
- dstanko 11y agoWhat's an IRC? What's a variable? :) Look, don't get me wrong, I applaud the intent to make the language easy for total beginners. I argue that it's a longer stretch to understand ..< operator than ++. Arguments like people who never programmed before should be able to use it are great, but one should consider those in the context of the entire grammar, not just one operator. In my opinion Swift does not shine here, regardless what Apple says.
- josu 11y agoPlus a relatively easy concept to understand even if you encounter them for the first time. I'd say that it's even more intuitive than +=.