News for hackers. Stuff that matters.
Re:Java in the Small by jraph on Wednesday December 18, 2024 @05:51PM (#42456389)
I never understood why people bother with this when writing their python main file, which is never going to be imported because it doesn't make sense in the first place.
Re:Java in the Small by elteto on Wednesday December 18, 2024 @07:43PM (#42457145)
Because I dislike interspersing executable statements at module level with function definitions. I’d rather have all code live inside functions and have one main entry point for the script. It’s just a personal preference, nothing wrong with not doing that though.
Re:Java in the Small by jraph on Wednesday December 18, 2024 @09:49PM (#42457907)
But you could have a single main() call without the if statement, couldn't you?
Re:Java in the Small by telotortium on Wednesday December 18, 2024 @08:37PM (#42457452)
REPL-based development. You might be developing a script, but notice a bug. If you import your script as a module, you can run the function you’re debugging, figure out what’s wrong, edit the file, and then reimport the module (using importlib.reload).
Re:Java in the Small by jraph on Wednesday December 18, 2024 @09:49PM (#42457915)
Okay, that's quite convincing, thanks!