Sunday, August 2, 2009

Why is Java so Dogmnatic about everything being a part of a class?

One of my main complaints about java is that the language insists everything be part of a class including main. However, since main() is called before a class has been instantiated, it must still be static, which is frankly, the same as being a global function!





Can anyone defend the purpose in having main() as part of an uninstantiated class?

Why is Java so Dogmnatic about everything being a part of a class?
I tried googling this for a while and could not find a clear answer (or anything that alluded to a small explanation!).





I really do not like OOP at all. I remember my first Java class- it was also my last.





Not only is the coding obnoxious, but what a memory hog java is! UGH.





Actually Java is the reason I changed my major! LOL no kidding.





Good luck on your quest; I'll be watching this to see what others say.





Come to the Unix side. We're waiting for you. ;)
Reply:How would you prefer to write it? It's never bothered me.





It just simplifies the types of files to maintain to one. A class. And by doing it this way, you can easily add a main method to any class and be able to instantiate it from the command line.





I think the real problem you're having here is that you're trying to write procedural code in an object-oriented language. You really have to embrace the whole oo mentality to enjoy the true beauty of java. If the way you think about solving a problem is by executing a series of steps (procedural), rather than creating a collection of tools (object-oriented) than you're probably using the wrong language.


No comments:

Post a Comment