Also, do y’all call main() in the if block or do you just put the code you want to run in the if block?

  • embed_me@programming.dev
    link
    fedilink
    arrow-up
    38
    arrow-down
    2
    ·
    1 month ago

    Sometimes I have the misfortune of working with python code written by someone else and I wonder how a language like this became anything more than a scripting language

    • addie@feddit.uk
      link
      fedilink
      arrow-up
      26
      ·
      1 month ago

      I feel that Python is a bit of a ‘Microsoft Word’ of languages. Your own scripts are obviously completely fine, using a sensible and pragmatic selection of the language features in a robust fashion, but everyone else’s are absurd collections of hacks that fall to pieces at the first modification.

      To an extent, ‘other people’s C++ / Bash scripts’ have the same problem. I’m usually okay with ‘other people’s Java’, which to me is one of the big selling points of the language - the slight wordiness and lack of ‘really stupid shit’ makes collaboration easier.

      Now, a Python script that’s more than about two pages long? That makes me question its utility. The ‘duck typing’ everywhere makes any code that you can’t ‘keep in your head’ very difficult to reason about.

      • ebc@lemmy.ca
        link
        fedilink
        arrow-up
        0
        ·
        1 month ago

        other people’s Java

        I’m gonna have to disagree here, it’s always a guessing game of how many layers of abstraction they’ve used to seemingly avoid writing any implementation code… Can’t put the code related to “bicycles” in the Bicycle class, no, that obviously goes in WheeledDeviceServiceFactoryBeanImpl that’s in the ‘utils’ package.

        • addie@feddit.uk
          link
          fedilink
          arrow-up
          1
          ·
          1 month ago

          Enough of that crazy talk - plainly WheeledDeviceServiceFactoryBeanImpl is where the dependency injection annotations are placed. If you can decide what the code does without stepping through it with a debugger, and any backtrace doesn’t have at least two hundred lines of Spring boot, then plainly it isn’t enterprise enough.

          Fair enough, though. You can write stupid overly-abstract shit in any language, but Java does encourage it.

        • addie@feddit.uk
          link
          fedilink
          arrow-up
          4
          arrow-down
          1
          ·
          1 month ago

          Well now. My primary exposure to Go would be using it to take first place in my company’s ‘Advent of Code’ several years ago, in order to see what it was like, after which I’ve been pleased never to have to use it again. Some of our teams have used it to provide microservices - REST APIs that do database queries, some lightweight logic, and conversion to and from JSON - and my experience of working with that is that they’ve inexplicably managed to scatter all the logic among dozens of files, for what might be done with 80 lines of Python. I suspect the problem in that case is the developers, though.

          It has some good aspects - I like how easy it is to do a static build that can be deployed in a container.

          The actual language itself I find fairly abominable. The lack of exceptions means that error handling is all through everything, and not necessarily any better than other modern languages. The lack of overloads means that you’ll have multiple definitions of eg. Math.min cluttering things up. I don’t think the container classes are particularly good. The implementation of pointers seems solely implemented to let you have null pointer exceptions, it’s a pointless wart.

          If what you’re wanting to code is the kind of thing that Google do, in the exact same way that Google do it, and you have a team of hipsters who all know how it works, then it may be a fine choice. Otherwise I would probably recommend using something else.

          • silasmariner@programming.dev
            cake
            link
            fedilink
            arrow-up
            0
            arrow-down
            1
            ·
            1 month ago

            This is the most excellent summary of Go I have ever read. I agree with everything you’ve said, although as a fan of Scala and in particular its asynchronous programming ecosystem (cats for me, but I’ll forgive those who prefer the walled garden of zio) I would also add that, whilst its async model with go routines is generally pretty easy to use, it can shit the bed on some highly-concurrent workloads and fail to schedule stuff in time that it really should’ve, and because it’s such a mother-knows-best language there’s fuck all you can do to give higher priority to the threads that you happen to know need more TLC

      • embed_me@programming.dev
        link
        fedilink
        arrow-up
        8
        ·
        1 month ago

        Agreed. I program mainly in C so its easier for me to make sense of bad C code than bad python code which just makes me cry