Live data from Hacker News

Remove the ++ and –- operators

github.com

11–20 of 249 posts

Re: Remove the ++ and –- operators

#11
post #4

post increment/decrement is definately worth removing imo. so few people understand its behaviour and it enables some really revolting and difficult to read things. i think a lot of people learned this in the 80s, 90s and 00s even... its not a new revelation. the pre-increment/decrement though? i think having these is important. there are plenty of contexts away from numbers where they make sense (things can be order…

What about a function named succ or next? They would make things a bit more explicit, and succ has its own tradition.

Re: Remove the ++ and –- operators

#12

> 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 do too, but it's worth it to not have x++ and ++x thrown around inside of expression bodies (especially while loop conditions).

Re: Remove the ++ and –- operators

#14

I've never understood the obsession with avoiding ++ and --. Douglas Crockford advocates the same thing. All of the examples of why it's bad are contrived and set up to fail. In the majority of real world instances, it's just us incrementing or decrementing a single variable.

In Go, where they're a statement, they're fine. But as an expression, but stuff can happen. In non-contrived, real-world, historical examples.

Re: Remove the ++ and –- operators

#15
post #7
post #5

Why not leave those operators for more "advanced" users? I also contest "++" and "--" operators are seriously tripping up "beginners". In most programming books, it's taught a few chapters in...

Because non-advanced users will incorrectly abuse them. That's why ARC doesn't let you call retain and release manually, even though there's no technical reason it couldn't.

> Because non-advanced users will incorrectly abuse them.

I don't see how this is a valid reason to remove the operators completely. Beginners will get it wrong sometimes, so we should remove it?

Beginning users are likely to make all kinds of errors, so the implication would be maybe we should remove the entire language...?

Not to mention, pre-decrement and post-decrement are not complicated concepts. There are many valid reasons to use both, although post-increment/decrement seems to be the more common use.

Re: Remove the ++ and –- operators

#16
Good. I've always presumed ++ is in C because processors had an increment instruction that was faster than add back then, and for the PDP-11's autoincrement addressing mode. Presumably Dennis' compiler would have been that much bigger in order to spot these optimizations vs having the programmer explicitly invoke them -- perhaps big enough to no longer fit in memory.

Re: Remove the ++ and –- operators

#17
Is this like the Apple idea to have a 1-button mouse? I like to ++ things, because when I'm coding, it fits better with that focused efficient state of mind where you don't have to think about x + 1, you just say ++ and it's bigger. But I'm not an Apple programmer, so maybe this isn't for my style.

Re: Remove the ++ and –- operators

#19
post #15
post #7

Earlier quoted context omitted.

Because non-advanced users will incorrectly abuse them. That's why ARC doesn't let you call retain and release manually, even though there's no technical reason it couldn't.

> Because non-advanced users will incorrectly abuse them. I don't see how this is a valid reason to remove the operators completely. Beginners will get it wrong sometimes, so we should remove it? Beginning users are likely to make all kinds of errors, so the implication would be maybe we should remove the entire language...? Not to mention, pre-decrement and post-decrement are not complicated concepts. There are many…

Well, the same argument can be made for pointers, which are clearly harmful to a safe language.

Swift does include them, but puts a screaming "Unsafe" in front of their type names so that it's clear that unless you really know what you're doing, you're probably doing something wrong.

There's no way to do that with a ++ operator, so it's being removed.

Re: Remove the ++ and –- operators

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

Post reply on HN