Live data from Hacker News

Remove the ++ and –- operators

github.com

51–60 of 249 posts

Re: Remove the ++ and –- operators

#54

Earlier quoted context omitted.

Agreed. In the list of disadvantages, we don't see "many professional programmers expect the ++ and -- operator" or "beginners will be confused because old code examples on the web will stop working".

This argument feels like 'legacy for legacy's sake'.

Frankly I think discussions like these show how not all programmers are engineers. Cutting down on complexity and ambiguity is a good thing. Because even if you can handle something, when you have teams of 100+ people with 100 000+ lines of codes, all those potentials for errors quickly adds up.

Re: Remove the ++ and –- operators

#55
post #42

I strongly disagree with this. Being able to do a very simple task like increment or decrement a number inline is useful and reduces clutter and I've always found the idea that the operator complicates things ridiculous. The way they work has always been obvious to me since I first learned to program in PHP as a tween.

"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.

Well 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?

Re: Remove the ++ and –- operators

#57

Removing ++ et al: ok, they have their problems. But retaining x += 1? That one has always annoyed me. Why does '+' (and friends) get this special form, but not my functions? Just because they're built-in. They are useful; no argument there. Largely because 'x' can be a complex reference, and you don't have to type it twice (and the compiler doesn't have to figure out that its the same expression twice). E.g. x=x+1 i…

>Why does '+' (and friends) get this special form, but not my functions?

Your functions can get that (and other) special form. You need to use a language where you can define your own operators. Have you looked at C++, C#, Haskell, or LISP?

Re: Remove the ++ and –- operators

#58
post #42

I strongly disagree with this. Being able to do a very simple task like increment or decrement a number inline is useful and reduces clutter and I've always found the idea that the operator complicates things ridiculous. The way they work has always been obvious to me since I first learned to program in PHP as a tween.

"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.

Apple 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.

Re: Remove the ++ and –- operators

#59

Why remove x++ and not x += 1? Demand X = X + 1. For clarity/readability/formatting.

> Why remove x++ and not x += 1?

A key part of the reason for removing the ++/-- set of operators seems to be that they conflict with Swift's pattern of mutating operators returning void. (An alternative offered was revising them so that they followed that pattern.)

+=/-=, like simple assignment, do not have that problem.

Re: Remove the ++ and –- operators

#60

Removing ++ et al: ok, they have their problems. But retaining x += 1? That one has always annoyed me. Why does '+' (and friends) get this special form, but not my functions? Just because they're built-in. They are useful; no argument there. Largely because 'x' can be a complex reference, and you don't have to type it twice (and the compiler doesn't have to figure out that its the same expression twice). E.g. x=x+1 i…

Another way to express this is, I'd like a language keyword for "left hand side of assignment". Then for x=x+1 I could say

     x =  + 1;
It could then get arbitrarily complex. E.g.

     x =  ( + 1) / atan() - ;
and no matter how complex 'x' was in practice, the compiler (and the code reader) could keep track of what was happening.
Post reply on HN