• anton@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    20
    ·
    7 months ago

    Had to work with a python programer on a small java project (in uni). I passed some (handcrafted) strings in an Optional to be explicit an first thing he does is check whether they are empty (sending on empty strings would not have been problematic). Also he had compilation errors on his branch that lasted over a week. What python does to someone.

    • grue@lemmy.world
      link
      fedilink
      English
      arrow-up
      15
      ·
      7 months ago

      That guy was shitty at Python, then. Python is all about EAFP instead of LBYL.

        • grue@lemmy.world
          link
          fedilink
          English
          arrow-up
          13
          ·
          7 months ago

          “Easier to Ask Forgiveness than Permission” vs. “Look Before You Leap.”

          In other words, in Python you should just write the code to do the thing and then put an exception handler at the bottom instead of cluttering up your function with guard code everywhere.

    • evranch@lemmy.ca
      link
      fedilink
      arrow-up
      2
      ·
      7 months ago

      I wouldn’t call this a “python thing”.

      I grew up with C and C/++ is still my main language, checking for empty strings is instinctive to me. It’s cheap insurance and what does it cost, a couple cycles?

      Though you won’t find me using bare cstrings these days unless there is a damn good reason for it. So much extra work to handle them. Even in embedded work, String classes have superceded them.

    • Elderos@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      7 months ago

      I worked under a self-proclamed Python/JavaScript programmer, and part of the job involved doing rather advanced stuff in various other typed languages like c# and c++. It was hell. The code review were hell. For every little tiny weenie little things we had to go through “why coding c++ like it is python” is a very bad idea.

      What is crazy about developers who exclusively work with scripting languages is that they have no conception of why general good practices exist, and they often will make up their own rules based on their own quirks. In my previous example, the developer in question was the author of a codebase that was in literal development hell, but he was adamant on not changing his ways. I’d definitely be wary of hiring someone who exclusively worked with scripting language, and sometime it is less work to train someone who is a blank slate rather than try to deprogram years of bad habits.