Surely `public static void main` has less congnitive load than
if __name__ == "__main__":
main() if __name__ == "__main__":
main()I had the same issue with Swift. There’s 30 ways to write the exact same line of code, all created by various levels of syntax sugar. Very annoying to read, and even more annoying because engaging different levels of sugar can engage different rulesets.
print("Hello World") is a perfectly valid and runnable Python code.
And when you are working on a small part of a large code base, you usually don't care about __main__ either. So yes, it's complexity but it's complexity that you don't need to encounter right away.
Python is intuitive off the bat. public static void main(String[] args) is not.
class Program {
static void Main() {
Console.WriteLine("...");
}
}
But these days, we can just do: Console.WriteLine("..."); $ cat Hello.java
void main() { System.out.println("Hello, world!"); }
$ java --enable-preview --source 21 Hello.java 2>/dev/null
Hello, world!
$
This is currently a preview feature in Java 21 and 22.