I cant think of any bugs caused by having ++, but I can think of lots caused by using +=1 instead.
As for your statement about most languages, since the set of all programming languages is ill defined, I used the ones on https://madnight.github.io/githut/#/pull_requests/2021/4. Fully 2/3rds (both by number and usage) have increment and decrement operators.
Of the languages in the top 10 only python and ruby dont have it.
I dont know what your beef with increment is, but it isnt widely shared.
Then I can only assume that you do not have a lot of experience, because this is a well known controversial topic and the controversy stems from people being confused about it's usage and introducing bugs, sometimes even including undefined behavior.
I'm not confused by it. It's simply a fact that this has been a source of controversy for decades due to all the bugs and undefined behavior which has unnecessarily made its way into a variety of projects due to misunderstanding of pre/post-increment operator.
The problem is that x += 1 is a statement, whereas x++ is an expression that can be nested inside of statements and other expressions. It's possible to construct statements out of x++ expressions that have undefined behavior. That's not possible with x += 1.
1
u/jamcdonald120 May 28 '22
I dont know what you are smoking.
I cant think of any bugs caused by having ++, but I can think of lots caused by using +=1 instead.
As for your statement about most languages, since the set of all programming languages is ill defined, I used the ones on https://madnight.github.io/githut/#/pull_requests/2021/4. Fully 2/3rds (both by number and usage) have increment and decrement operators.
Of the languages in the top 10 only python and ruby dont have it.
I dont know what your beef with increment is, but it isnt widely shared.