• 28 Posts
  • 77 Comments
Joined 9 months ago
cake
Cake day: September 13th, 2024

help-circle





  • Basically, when you compile a program written in Rust or C/C++ (the first and second panels respectively), the compiler needs to know what’s supposed to be executed first when the program is run directly (i.e. when you click on the executable), which in these languages, is denoted by a special function called main(). Executable files can also contain functions and data structures that can be called by other programs, and when they are, you wouldn’t want to run an entire complex and resource intensive program if another program only needs to call a single function from it. In that case, the other program will call the function it wants but not main, so only that function executes and not the entire program.

    However, Python is a scripting language that’s interpreted. So every Python source file is executable provided you have the Python runtime. Python also doesn’t have native support for main functions in the same way Rust and C/C++ does, and it will execute every line of code as it reads the source file. This is why a single line Python file that just calls print is valid, it doesn’t need to be wrapped in a main function to execute. However, what if your Python file is both meant to be executed directly and provides functions that other Python files can call? If you just put the main routine in the root of the file, it would be executed every time another program tries to import the file in order to call functions from it, since the import causes the file to be interpreted and executed in its entirety. You can still just have a main function in your file, but since Python doesn’t natively support it, your main function won’t do anything if you run the file directly because as far as Python is concerned, there is no executable code at the root of the file and you haven’t called any functions.

    The workaround is to have a single if statement at the root of the file that looks like this:

    if __name__ == '__main__':
        main()
    

    It checks a special variable called __name__. If the Python file is directly executed, __name__ will have the value of the string '__main__', which satisfies the if statement so main() is called. If another Python file imports it, the value of __name__ will be the name of that file, so main() isn’t called. It’s clunky and not that efficient, but, 1, it works, and 2, if you cared about efficiency, you wouldn’t be writing it in Python.








  • It’s mostly beginners thinking of it as a shortcut to making software without learning any of the underlying theory. Basically, why struggle your way through a Rust tutorial on fighting the borrow checker when you can just get AI to do it? Though the issue is as soon as there’s something too complex for the AI to figure out, you’re out of luck because you’ve been deliberately avoiding learning the necessary concepts to fix it yourself.

    As for whether serious people are pushing it, most actual software engineers, not really, but company management would absolutely like nothing more than to replace all their developers with AI, so yes they’re pushing it pretty hard.








  • Also, Lemmy has ways of discovering communities. Just browse the all-local or all-federated feeds and you’ll see what communities are popular.

    The “can’t sign up” complaints might have something to do with how most instances make you answer questions like “why do you want to sign up” and “what communities will you browse” as a simple way of stopping automated sign-ups, and if they didn’t put anything in the box or just said things like “IDK I’m from Reddit” they might have been rejected due to the admins thinking they’re a bot or spammer or something.

    Gonna throw in my personal conspiracy theory (that I don’t have any evidence for): I haven’t been on Reddit Alternatives since I found Lemmy, but based on what i remember, there seem to be quite a few people who have spun up their own projects and are promoting them pretty hard on that subreddit. Who’s to say if one or more of them decided to buy bot comments to smear their competitors?






  • Just based on my observations of my life, I seem to have the ability to choose to do or not do things, and that’s good enough for me. Is my choice just part of the infinite universe’s fixed progression through time and I would have done what I did regardless? Are there infinite parallel universes where parallel versions of me exist that have collectively made every choice I can possibly make? Don’t care. I feel like I have free will and IMO that’s what’s most relevant to my life in this universe.


  • By not giving them any rights even though complex expression through language implies a high level of intelligence and sapience. The dog and cat that you can talk to are still considered your property that you can just take to the vet and put down. Animal shelters can now just tell the animals their kill dates so they don’t get too hopeful. Slaughterhouses will be filled with screams you understand instead of just screams. Cosmetic companies and labs can now ask their test subjects for the level of pain while smearing makeup in their eyes. Sea World, zoos, circuses, etc would make peak profits now that they can address their slaves as if they were human slaves.

    I mean, all humans can communicate with each other and we still don’t give rights to some of them. Anyone who thinks we’ll be nice to animals just because they can talk is either a child or otherwise doesn’t know how humans operate.