3 ms·
Except a static class method is just a hand-wavy way of denying reality: that a program has a single entry point that has nothing to do with classes As much as
by raverbashing 1y ago
Except a static class method is just a hand-wavy way of denying reality: that a program has a single entry point that has nothing to do with classes
As much as C++ has a lot of problems, them and other languages (python/ruby/etc) never denied that the procedural world existed, while Java wants to blindfold you and push you through a corridor until you get out of it and into the "perfect (not) OOP world"
- mayoff 1y agoBut in Java, a program doesn't have a single static entry point. You can have as many different classes as you want, each with its own static void main, and choose which to use as the entry point when you start up your JVM.
- chii 1y agoYou've just described separate programs that happen to be bundled together (in the same jar presumably). Each invocation of the jvm requires that you specify the class for which a single static main exists. The other classes containing other static mains are irrelevant.
- izacus 1y agoNo they didn't. Seems like you arbitrarily redefined what a program means to argue.
- pansa2 1y ago> python/ruby/etc never denied that the procedural world existed Interestingly, those two languages use very different mechanisms for top-level functions - although I’m not sure if there’s a significant difference in practice. Python has true standalone functions, whereas in Ruby’s they’re really methods of a `main` object.
- 1718627440 1y agoIn python you are recommended to use if __name__ == '__main__': sys.exit (main (sys.argv)) and not put any code that is executed at the top-level. Otherwise its also executed when you import the file.
- Yoric 1y agoIf you're speaking of `main()`, that's not true in Java: you can have many entry points and decide upon launch which one you're using. If you're speaking of `__main()`-style entry point, though, you're right, and Java makes it... complicated.
- raverbashing 1y agoYes I meant the latter