• @C0MPL3X4
    link
    4725 days ago

    It’s about writing the code, not execution time. Otherwise Assembly wouldn’t take 7 years…

    • @[email protected]
      link
      fedilink
      725 days ago

      Some languages are just worse to work with. like JavaScript. Console.log is like sure I’ll log your object but I’ll tell you what it is now, not what it was when you logged it.

      • Skull giver
        link
        fedilink
        825 days ago

        Fwiw, Javascript’s object logging is a feature I often miss in other languages. If you just want to log the string, use formatted strings or just log obj+“” like you would need to do in every other language. Or even better, log a copy, like you probably wanted to do, with {…obj}.

        I have many gripes with Javascript, but the logging API is pretty solid.

        • @[email protected]
          link
          fedilink
          325 days ago

          I’ve never had a complaint about logging stuff in python. It generally does what I expect.

          “Create a copy of your object and print that” is what I ended up doing, but I don’t think most people would say that’s intuitive. I expect if i print something at a particular time, I get what it is at that point in time.

          • Skull giver
            link
            fedilink
            125 days ago

            Javascript passes objects by reference in most cases. Passing logging objects by copy would actually be an anomaly within the language. The only unexpected part is that the browser console doesn’t toString your objects instantly (for performance reasons mostly), but the same happens in other frameworks for other languages (though often with less latency, milliseconds most of the time).

            As I’ve personally experienced, this can make debugging concurrency issues real fun! Pre-composing your log messages as a string (within the same critical section) will prevent quite a few weird edge cases.

            The Python console doesn’t allow you to expand and dig deep into the object hirerachy of the thing you’re dumping. You either implement a string conversion handler or manually convert the object to a string as well, whereas Javascript doesn’t need the extra string pass and doesn’t flatten the log hierarchy. There are a few JSON logging frameworks you can combine with log aggregators that provide the same functionality, but that’s quite heavy and complicated to set up.

    • @[email protected]
      link
      fedilink
      225 days ago

      I can see it going both ways. Talking about execution times, this would be an exaggeration, but then, these memes always are.