Why write Java ?
I've been away for a while (couple of years in fact), but have recently returned to writing Java, and the most appropriate expression does seem to be "Aaaaaargh!"
OK, so I've been writing Python for the last year or so, so I'm spoiled for expressibility. But Java is worse, far worse, than I remember.
We know the classic examples of over-abstraction in Java, which leads to the obvious quesion: why does the API consistently take care of all the complicated cases, while ignoring the common cases ?
But today I got gotcha'd in the debugger by a far simpler one:
If you are a programmer then ask yourself what this means, hence what value should be returned (it is written in a programming language you have never seen before):
Of course, in Java, it returns 0, not 1.
I debugged all the way down to ( "X" == "X" ) being false. Till I finally remembered the reason: Java is testing object equality, rather than lexiographic equality.
But that just depends on your definition of "reason" - why is the language definition so perverted as to insist on object identity in such an expression, but not insist (to the same frustrating degree) on object identity in an expression like ( 7 == 7 )?
Why do the designers of magical languages think they know better than programmers?
Why did Sun insist that what all other programmers knew about "==" was wrong? And don't get me started on Wirth and bloody Pascal, the "teaching language", where it took me two weeks as a student to figure out how to add a character on to a string. Because chars and strings are different types! (Oh yeah ?)
If you really feel the need to teach programmers something, try teaching them English.
OK, so I've been writing Python for the last year or so, so I'm spoiled for expressibility. But Java is worse, far worse, than I remember.
We know the classic examples of over-abstraction in Java, which leads to the obvious quesion: why does the API consistently take care of all the complicated cases, while ignoring the common cases ?
But today I got gotcha'd in the debugger by a far simpler one:
If you are a programmer then ask yourself what this means, hence what value should be returned (it is written in a programming language you have never seen before):
String s = "7"
if ( s == "7" )
return 1;
else
return 0;
Of course, in Java, it returns 0, not 1.
I debugged all the way down to ( "X" == "X" ) being false. Till I finally remembered the reason: Java is testing object equality, rather than lexiographic equality.
But that just depends on your definition of "reason" - why is the language definition so perverted as to insist on object identity in such an expression, but not insist (to the same frustrating degree) on object identity in an expression like ( 7 == 7 )?
Why do the designers of magical languages think they know better than programmers?
Why did Sun insist that what all other programmers knew about "==" was wrong? And don't get me started on Wirth and bloody Pascal, the "teaching language", where it took me two weeks as a student to figure out how to add a character on to a string. Because chars and strings are different types! (Oh yeah ?)
If you really feel the need to teach programmers something, try teaching them English.
0 Comments:
Post a Comment
<< Home