How does it affect you this change day to day?
How does it affect you this change day to day?
But yeah I don't understand why the author is so excited about this. How "ugly" a trivial "Hello, World!" does not really matter much and isn't a good indication of anything about the language's ability to handle more than "Hello, World!"
Java (historically) is famous for going a bit too hard core into overly abstract & verboseobject oriented design patterns - create a factory to get another factory to get a different factory and whatnot. The hello world is where java shows that style of code is what historical java felt was the ideal.
The factory pattern is tightly coupled with polymorphism. If you're not using polymorphism, then you may not typically need factories. But if you are, then at some point you're going to have some conditional logic about what concrete type of class you're going to create of a particular interface.
Modern Java is lending itself more towards data oriented programming, and coders are trending in that direction. This may or may not last, like every trend. But even then, at the moment this tends to still involve using sealed interfaces and records, so you still have some form of instance creation and polymorphism.
How do you avoid factories? Doesn't you code end up littered with worse code?
> How do you avoid factories? Doesn't you code end up littered with worse code?
Easier for me to use "public abstract class" and then leave open methods inside like "protected abstract doAction();" that are forcefully implemented on each variation of that class.
There is still just one base implementation, I guess the main difference is using strong typed classes that keep the specific code inside specific classes. With factories one tends to end up with a very large source code file that details with too many specific different topics, was making maintenance and testing harder afterwards.
Or maybe I just never really understood properly the value of factories.
If you always know which concrete class to instantiate and use at each point in the code, it doesn't sound like you need polymorphism in the first place.
Or I could just be missing something.
that's why java programmers are the most productive programmers ever
if you count productivity by lines of code
Sure, but for beginner programmers who don't have the discipline down yet, it's unnecessarily hard. I bought a Java programming book as a kid and got stuck because of a typo that produced an error message I couldn't understand. This was the time before StackOverflow and Reddit. In retrospect, this delayed my programming journey by at least a year.
Longer Hello Worlds make frustration and getting stuck like this more likely.
(Though the ultimate conclusion of this line of thinking is that programming 101 courses should be taught in as concise and syntax-light a language as possible, giving the learner as few opportunities to screw up the input as possible. I’m a fan of teaching programming in Ruby, personally. Not theory of programming, mind you; just programming as an iterative human process.)
100% this. To make Java be the all-language makes it a mess without a defined goal. It is better to start learning with a language better suited for it. And then the learner can specialize and expand to other languages. This also helps to create awareness that different languages have different use cases.
I used to teach Java, and the total sum of magic incantations you needed before starting to actually "Hello, world" were an instant turn off for many students.
From my recollections as a student, compiling C or C++ in intro classes was just a matter of calling `gcc myprogram.c` or `g++ myprogram.cpp`, followed by `./a.out` for testing, which is rather easy to explain to students who already know what a command-line is.
Now that I think of it I rarely even write a truly new class from scratch, usually you just implement/extend some framework-specific thing.
The scanner class is one such thing, but you also have things like wrapping a Reader in a BufferedReader to add buffering, and building a Pattern object to build a Matcher object which has a few different methods you can call to actually do anything useful
It is very OO, but it's also a bit annoying, and more modern java libs tend to give you a more comfortable API. Sadly modern java also tends to come with springboot and people who can't do anything, unless they use springboot
Spring Boot (and Spring generally) is more of a “Java culture” issue — someone on this thread used the term “framework fetishism” and it’s spot on.
Thankfully there are teams, typically in mobile or polyglot microservices environments, who are moving away from this. But yeah — still far too common.