Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Swift had ++ but removed it from the language because does more bad than good.
Here’s why:
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. -
Post 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.
-
@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 -
@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 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
-
@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 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
-
@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:
https://en.m.wikipedia.org/wiki/...
You can also look up the benefits of functional programming. -
@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 -
@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.
-
@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. -
@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. -
@Lensflare yes i understand, my main point was, if ++ is something with or without side effects.
-
@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 ! -
@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 ?
rant