Just ask it to rewrite the shitty code you wrote in a language you barely understand to “follow standard best practices in <language>” or something like that and it will add advanced typing features, functional programming for iterables, advanced exception handling, proper concurrency handling, optimize control flows, use better equivalent functions, etc.

As long as you understand the foundations of these concepts in at least one language anybody can become pretty close to an expert in most languages instantly. Especially since most of them are C based and pretty similar

The output will sometimes change the logic but I mean that’s pretty easy to catch and fix

Rip C++ nerds that memorize the entirety of each releases manual to shave off 3ms in every single function

  • footfaults@lemmygrad.ml
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 days ago

    100% agree with everything you’ve said. I think it really illustrates how Python has not really done a good job around memory management.

    By which I mean, it has done it well enough where you don’t have to think about memory management normally and that actually ends up hurting you because the identity operator explicitly is about checking if two references point to the same object and people forget that, and then some interpreter optimizations around small integers make it so the is operator and equality operator behave the same for small values and people get a wrong impression about the identity operator.

    I have the same problem with Python’s “pass by assignment” way of doing things where it’s not explicit enough for my liking. Don’t get me wrong, I understand what it is doing after 20 years using the language but I sort of appreciate C like languages where references vs values are more explicit with things like ponters.

    Zig has been interesting to me, for this reason.

    • invalidusernamelol [he/him]@hexbear.net
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 days ago

      Haven’t gotten into Zig, but it’s on my list. I’m trying to get into Go and Rust now. Especially since I too have almost 20 years of using Python under my belt and hit those annoying “sometimes I just want to be explicit” moments.

      That being said I will always come back to Python especially because I do now understand those pitfalls that can totally stump someone who’s new to the language. The general syntax and elegance of generator expressions is addictive for small projects and quick tools. No boilerplate and a few comprehensions can do the work of a whole library (albeit quite a bit slower, but pretty frequently runtime is secondary to maintenance time).

      I do like that type hinting is becoming the standard in Python though. I have absolutely abused the private apis for reading type hints in my code to get a sorta poor man’s runtime type validation in mission critical (database) fuctions. I’ve used type hints with a decorator to build API endpoints as well. Hope that someday Python finally just commits and stops pretending to be lazy Rust and just allows you to opt into static typing.