4 ms·
I'm on board with Java not being a great first language but I'm pretty tired of posts constantly citing ancient unidiomatic Java to prove how bad of a language
by agency 10y ago
I'm on board with Java not being a great first language but I'm pretty tired of posts constantly citing ancient unidiomatic Java to prove how bad of a language it is. Their file i/o example could just as easily be
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class fileIO {
public static void main(String[] args) throws IOException {
Files.copy(Paths.get("test.txt"), System.out);
}
}
Granted that Files utility was added in 2011. Even in 2010 there were plenty of better ways to write that example.
- omn1 10y agoI don't see how this is much easier for a beginner. :)
- agency 10y agoAgain, I don't think Java is a good beginner programming language, but this version: 1. Avoids try/catch syntax, and in fact can defer mentioning exceptions entirely (at the cost of the "throws" declaration being a mystery, which the main function already is to a beginner) 2. Does not require understanding of loops. In fact their example loop is particular egregious in its use of assignment in the loop condition which is especially likely to confuse beginners who are still learning the difference between "=" and "==" 3. Does not require introduction to Java's Reader I/O abstraction 4. Does not require familiarity with null references I'm not saying my version wouldn't be confusing for beginners, but it would be hard to write a worse version than the one they give.
- tps5 10y agoNothing kills a beginner's interest more than "you need to have a class and a main method, always, and I can't explain why, just trust me, you'll understand later." Java was my first language. No one explained any of that stuff to me. And for whatever reason I lacked the agency to go figure it out for myself although I had internet access. Probably because I assumed paying attention in class and doing my homework was enough.
- jlarocco 10y agoI think that says more about your teacher (and maybe about you) than it does about Java as a first language. Bad teachers will teach poorly no matter which language they're teaching.
- agency 10y agoI agree. I don't believe Java is a good first programming language. I'm just tired of posts bashing Java by citing code that doesn't take advantage of any of the improvements in the language since 1.4.