Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
IntrusionCM13825357dYou've answered the question.
It's an operator, python prefers statement.
sariel9002357dPython isn't a programming language.
Lensflare9583357dSwift had ++ but removed it from the language because does more bad than good.
The vast majority of places where ++ is used is the classic for loop.
And a foreach loop that iterates over elements in a collection is just better.
In other places, ++ would be just confusing and hard to follow.
+= 1 is more expressive.
+ 1 without mutation is even better because it promotes avoiding mutable state.
lorentz12788357dPost increment is the biggest footgun to be standardized by C. Pre-increment is alright but it's still easy to overlook when skimming over the code for mutations. += that returns the assigned value is probably the best middle ground between concise and explicit.
lorentz12788357dRust also doesn't have ++ btw
@Lensflare I use it numerous places
@lbfalvy but rust doesn't count hehe
@lbfalvy saw a bear cub today scavenging in the same spot doing the same thing
All animals are pretty predictable I suppose
A line of bred crumbs and if the bird starts at the same point it will peck the same places over all
Just like I felt like sharing this more than once
@lbfalvy where do you think one would be happy in the USA ?
@kiki how is it side effecty if you use it by itself ?
lorentz12788356d@TheWrongGod I don't live in the USA, my samples are Eastern Europe and Britain and I'm happier in Britain, but I also live a different life.
@lbfalvy I liked France
@lbfalvy London was nice too the section I was in was near that art museum archive where they store random peoples artifacts
Never stayed in London more than a day or two though always traveled across the Chunnel
@lbfalvy im thinking a passport and a boat ticket are in order or flight if its cheaper
Lensflare9583356d@TheWrongGod what do you think side effects are?
++ mutates the value of the variable that it is applied to. This is a side effect.
@Lensflare uh that's not a side effect its the purpose
@Lensflare about the only time it can fuck up is when someone tries to increment and assign the value to a variable while using its pre form
Lensflare9583356d@TheWrongGod wether or not it’s on purpose is not the point.
Code with side effects has many disadvantages.
Side effects should be avoided when possible.
See referential transparency for example:
You can also look up the benefits of functional programming.
TheWrongGod45355d@Lensflare yes I started looking at f#
Didn't really see the point of it
Sounded good buy obviously not remembering it must not have made a deep impression
lorentz12788355d@TheWrongGod Functional programming isn't something you can just pick up in a couple days and use like any other language; it requires a very different approach to problems, while procedural and object-oriented operations have 1:1 mappings those generally defeat the purpose. Learning functional programming is a lot like re-learning everything you learned after your first few weeks of programming except the very general rules pertaining to the nature of clean code.
thebiochemic1609355d@Lensflare i guess the main purpose of ++ is incrementing the numeric value by 1 and delivering the result as an assignable value.
The side effect is incrementing the numeric value of the container, that held this value in the first place.
So yeah: x=+1 is better than ++x. But then again, i really dont care, if i have to use either of them.
Lensflare9583355d@thebiochemic you are of course free to not care and use whatever you want :)
I was just trying to give some hints to why some languages do not have ++. It’s not a missing feature but a deliberate design decision.
Similarly to how some languages don’t have goto.
thebiochemic1609355d@Lensflare yes i understand, my main point was, if ++ is something with or without side effects.
TheWrongGod45354d@thebiochemic its a syntactical convenience is my point ! These are things that I would incorporate into a new unified language
Amazes me this is an arguing point the ++ is iconic !
lorentz12788354d@TheWrongGod Convenience features serve to make good code easier to write. If the language otherwise takes the stance that mutation is bad (as many do), or at least that unnoticed side effects are dangerous and therefore mutation always must be an individual statement, then introducing this operator would be like telling your users to write bad code.
May I ask why every language I've seen other than pascal has an in place ++ increment operator and fucking python does not ?