• PhobosAnomaly@feddit.uk
    link
    fedilink
    arrow-up
    2
    ·
    3 months ago

    I was brought up on C, did a module of Java at uni, and am doing an algorithms course which is python heavy.

    My other half - who’s quite handy with Python - looks in sheer horror at my code which is littered with semicolons.

    I was stumped for half an hour figuring out why the Python interpreter was bouncing an error before it had even reached the main program logic… turns out a { before the block of code royally ruins the interpreter’s day.

    Still, I live and learn.

  • shasta@lemm.ee
    link
    fedilink
    arrow-up
    2
    ·
    3 months ago

    This is why linting and auto-format on save exists in IDEs. Don’t make things harder on yourself.

    • force@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      3 months ago

      That said, with how few expressions are return values, I do wonder why semicolons are the default rather than adding a special character to indicate return values.

      you mean like return/break/etc.?

      because Rust was designed to remind you of functional programming despite not being very functional, and because semicolons allow way better syntax rules in Rust and are generally pretty vital for good, readable lowish-level code. it also allows Rust programmers to use newlines/indents and stuff to pretty up their code a lot without littering it with random \ and |> and begin end and such everywhere, which, given how dense Rust code can be and how much it uses iterators and weird trait magic, is a big plus for readability

  • Carighan Maconar@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    For bonus points take their code and completely go wild with utterly random indentation and line breaks, just to drive the point home. 😈

  • toastal@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    Folks acting like Python is the only language without semicolons. 😏

    I got tripped up so many time in the last 3 weeks using PHP after years in ML family languages. I am already newlining & it’d be poor style to put more than one statement on a line so what is the point of these semicolons?