Live data from Hacker News

Remove the ++ and –- operators

github.com

81–90 of 249 posts

Re: Remove the ++ and –- operators

#81
scala has no ++ or -- operators. It's a-okay. Swift is shaping up to look a lot like scala actually. The biggest problem with ++ and -- operators is that they hide a side-effect in another unrelated operation. In a language that supports more functional approaches at the outset, it makes sense to just omit these operators I think.

Re: Remove the ++ and –- operators

#82
post #3

> Their expressive advantage is minimal - x++ is not much shorter than x += 1 Personal opinion, but I definitely miss '++' every time I'm doing '+=' in Python.

I think I'd argue with the "not much shorter" because it's less typing to perform a `++` versus `+=1`; I hold shift, I type the = key, obtaining the +, then I have to pause typing long enough to release the shift key, type the = key again, and now my other hand has to get involved and type a 1. And that's without the spaces.

If typing is the bottleneck in your development you're not solving difficult problems and could probably make more money solving difficult problems at a different job.

Re: Remove the ++ and –- operators

#83
post #75
post #3

Earlier quoted context omitted.

I think I'd argue with the "not much shorter" because it's less typing to perform a `++` versus `+=1`; I hold shift, I type the = key, obtaining the +, then I have to pause typing long enough to release the shift key, type the = key again, and now my other hand has to get involved and type a 1. And that's without the spaces.

Well, I type the * key to get a +, then shift and 0 to get a =, then 1 to get a 1. Slow, and my fingers have to jump completely over the keyboard. What is far more annoying, and should be banned, are `these` (I have to press shift+' twice to get one `, otherwise I end up with á' instead of `a`), and {}[], as they are on AltGr+7/8/9/0

Which type of keyboard do you use? I know English-International has a similar issue with `'`, `"`, and `'`. I think QWERTZ or a German keyboard do as well? Can try changing it to English - US to get around that if you run Windows. Not sure about Mac/Linux.

I swapped the US out for international because it was important to me to type Pokémon properly. It is an annoyance to have to type ` followed by a space because it is waiting for a vowel to let me type ù. Same with ' which let's me type ç or " which lets me type ü... etc. I disable it when programming for the reason you cited. It can be annoying to deal with. Especially when my IDE tries to autocomplete " and I typed "" instead of " (followed by a space) and I get """".

Re: Remove the ++ and –- operators

#86

"Drop one of x++ or ++x. C++ programmers generally prefer the prefix forms, but everyone else generally prefers the postfix forms. Dropping either one would be a significant deviation from C." Funny given the name of the language.

C++ is not even a good increment of C. Yes it had a lot of inspiration from C, but in all seriousness, it should not have been called C++ since it is not backwards compatible with C without some serious work. Honestly longest running ironic language name.

Re: Remove the ++ and –- operators

#87

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

Which is actually quite common. Unicode is ASCII compatible and on Windows you still have to do carriage return before a line feed, although there are no teleprinters involved.

Re: Remove the ++ and –- operators

#88

VOTES-- MORE SERIOUSLY....CODING CAN BE ABOUT AESTHETICS. YES, JUST BECAUSE. CODE CAN LOOK GOOD AND THAT IS A VALUE. BUT ALSO, AESTHETICS CAN HAVE A NON-MEANINGLESS AFFECT ON COMPREHENSION, READABILITY, CODING-PLEASURE AND PRODUCTIVITY. SO MONEY, BASICALLY. PERSONALLY, I LOVE THE ++ AND -- AESTHETIC. IT'S JUST A COOL GLYPH/DIGRAM/IDIOM. BRING BACK THE QUIRKINESS ( OKAY, NOT TO THE PERL-LEVEL ) BUT BRING IT BACK!

Is this some kind of troll/satire on aesthetics?

Re: Remove the ++ and –- operators

#89

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.

Coincidentally, I've had a little discussion with a non-programmer friend of mine about this operator the other day. He does a little scripting in a game maker program sometimes, and told me that the ++ operator confused him way more than it ever helped him, because he keeps typing stuff like "x + 7" instead of "x = x + 7"

Re: Remove the ++ and –- operators

#90

"These operators increase the burden to learn Swift as a first programming language" Come on. There are legitimate reasons not to carry one language's expressions to another, but this isn't a good one. Most people first learn of ++/-- as "By the way, you can use ++ as a shortcut to add one" and leave it at that.

But its more complex than that- there are the prefix and postfix forms, which both leave the base incremented but return a different value (before or after the increment). That's the complexity that trips up novices.
Post reply on HN