5

May I ask why every language I've seen other than pascal has an in place ++ increment operator and fucking python does not ?

Comments
  • 2
    You've answered the question.

    It's an operator, python prefers statement.
  • 9
    Python isn't a programming language.
  • 3
    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.
  • 2
    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.
  • 3
    Rust also doesn't have ++ btw
  • 0
    @Lensflare I use it numerous places
  • 0
    @lbfalvy but rust doesn't count hehe
  • 0
    @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
  • 0
    @lbfalvy where do you think one would be happy in the USA ?
  • 0
    @kiki how is it side effecty if you use it by itself ?
  • 0
    @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.
  • 0
    @lbfalvy I liked France
  • 0
    @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
  • 0
    @lbfalvy im thinking a passport and a boat ticket are in order or flight if its cheaper
  • 1
    @TheWrongGod what do you think side effects are?

    ++ mutates the value of the variable that it is applied to. This is a side effect.
  • 0
    @Lensflare uh that's not a side effect its the purpose
  • 0
    @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
  • 1
    @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.
  • 1
    @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
  • 1
    @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.
  • 0
    @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.
  • 3
    @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.
  • 0
    @Lensflare yes i understand, my main point was, if ++ is something with or without side effects.
  • 0
    @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 !
  • 2
    @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.
Add Comment