by crystal_revenge · 1y ago · 0 comments
I learned Java only after Python and I remember being not quite familiar with types so even the 'void' and 'String[]' where a bit mysterious. After learning basic types that part made sense. Then you start learning about Classes and objects, and you understood that main is a static method of this class Main that must be required somehow. As you dive deeper you start learning when this class is called. In a weird way what started as complete, unknowable boiler plate slowly evolved into something sensible as you began to understand the language better. I have no doubt that seasoned Java devs see a lot more in that invocation that I do.
Good riddance though!
1. Programmer A creates a class because they need to do create an entry point, a callback, an interface... basically anything since everything requires a class. Result: we have an class.
2. Programmer B sees a class and carelessly adds instance variables, turning the whole thing mutable. Result: we have an imperative ball of mud.
3. Another programmer adds implementation inheritance for code reuse (because instance variables made factoring out common code into a function impossible without refactoring to turn instance variables from step 2 into arguments). Result: we have an imperative ball of mud and a nightmare of arbitrary dynamic dispatch.
At some point reference cycles arise and grandchild objects hold references to their grandparents in order to produce... some flat dictionary later sent over the wire.
4. As more work is done over that bit of code, the situation only worsens. Refactoring is costly and tedious, so it doesn’t happen. Misery continues until code is removed, typically because it tends to accumulate inefficiencies around itself, forcing a rewrite.
While the teaching is partially to blame, i say it is more that most people are sloppy and undisciplined thinkers. When they dont have any incentive to produce disciplined code, they wont.
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"
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.
If you're speaking of `__main()`-style entry point, though, you're right, and Java makes it... complicated.
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.
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.And yeah, it was pretty cool looking back on it later and realising I knew what it all meant!
And yeah, good riddance nonetheless!
The answer is: infinitely much. You could have to write each character in strings as separate characters for example. It would be absolute utter madness but it "would make sense later".
As we become more and more acquainted with programming, a lot of what we do why we do it is incoherent nonsense to a beginner, but important nonetheless.
The limit is actually your time and effort. But nobody likes to write optimal assembly by hand, the balance has to be struck somewhere.
You can't really escape String[], which imo is fine. It's better than argv/argc in C at least.
(I somehow mostly avoided learning Java, and my last passing contact with it was 20+ years ago, so these are honest questions).
The main function can be written with `String[] args` if you need it.
This is a decent summary of the changes:
https://www.happycoders.eu/java/main-method/
Further details:
This looks like a hack just for the main file, it would have been good if these functions can be called from other files.
The IO class is good. The rest is information hiding. Now if you could write anything else in Java in this form,it would make sense.
Thus, many sub-optimal project coordination approaches ended up fighting the design patterns. Java is a good student language, but there are so many better options now... with fewer footguns, and without Oracles farts. =3
Pulling the oracle card when java is mentioned is a useless stunt.
Do you actually use that option at enterprise scale? =3
It’s much better than ideal.
As much as I love hating Oracle, they pushed the language forward much more than Sun ever did.
The only reason Java is still somewhat relevant is ironically Android/Kotlin, and SAP/heinous-dual-stack-blobs product lines.
Best regards, =3
Java/JVM is literally everywhere. And let me get this clear: not a fan of both java-the-language and java-the-culture.
Depends on the use-case, but I also like Elixir/Erlang, Julia, and Go.
Not all are very popular, yet each offer something uniquely beautiful. =3
(One might argue Go comes close, though)
Javas selling point is that it can do everything reasonably well and has a huge talent pool.