3 ms·
Java isn't impossible for students to learn. I suggest, however, that it is not the best choice; because when it comes to learning how to program you want a lan
by aphyr 16y ago
Java isn't impossible for students to learn. I suggest, however, that it is not the best choice; because when it comes to learning how to program you want a language which is maximally expressive with a minimal amount of work. It artificially restricts the problem space you can tackle by making simple things more complicated than they need to be.
When you're writing an algorithm to count words in a file, would you prefer
string = File.read 'path'
or
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = new BufferedReader(
new FileReader("path"));
char[] buf = new char[1024];
int numRead=0;
while((numRead=reader.read(buf)) != -1){
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
reader.close();
string = fileData.toString();
How about introducing anonymous functions? How much time will it take you to explain the intricacies of creating an anonymous subclass whose only purpose for existence is to encapsulate a single instance with a single method, inside which all variables from the containing scope must be marked as final? Or would you prefer something like Smalltalk?
[ :x | x * x ] value: 2
Sure, students can wrap their heads around both. But the important thing is the concept, not the expression. After all, if they go on to program in the real world, they'll be adapting their knowledge to different languages.
- kotrin 16y ago"But the important thing is the concept, not the expression" Nailed it.
- DanielRibeiro 16y agoNot to mention that the type system in Java is always surprising. List<Integer> is not a List<Number> but Integer[] is a Number[] (which can throw ArrayStoreException as covariance makes no sense on mutable collections - ref: http://programming-scala.labs.oreilly.com/ch12.html http://programming-scala.labs.oreilly.com/ch12.html ) And compare smalltalks' (and ruby's and python's) everything is an object to Java's: there are some primtive things, and null is not an object. Don't get me wrong: java is very taughtable to beginners. The basic usage is ok, while cumbersome. But Java shows its deep issues when you start using it for more serious stuff.