Re: Re: Re: Re: Arguments needed for comparision between Perl, ASP and Javaby tilly (Archbishop)
|on Nov 18, 2003 at 15:40 UTC||Need Help??|
The point is to compare code with the same function, ya?
My point is that the code should be code that you might wnat to write. I don't know ASP well enough to know whether it provides error checking. The Java example does not, in fact it goes out of the way to fight the language and ensure that it does not! I'll give a Ruby example shortly with error checking that illustrates why I don't know about the ASP example even though no error checking is shown.
Some links on Java's checked exceptions first. James Gosling on why Java has checked exceptions. (I love his quote about, "In Java you can't escape the creepy feeling.") Bruce Eckel on why checked exceptions are bad. And the discussion that I am pulling these links from. In the code example, of course, the exceptions were swallowed, illustrating exactly the issue with checked exceptions.
The long and short of it is that most programmers sadly do not care about doing things right. If you care, then Java makes it easy to make sure that you captured every last case. But most don't, and immediately sabatoge the system. Perl makes it possible to do things right with less work, but the default behaviour does not do things right. Ruby and Python, by contrast, tend to do the right thing without programmers having to care. Here is the above example in Ruby to demonstrate what I mean:
Believe it or not, this example includes all the error checking that you might ever want! It properly will catch cases where you can't open the file, opened it but can't write to it (perhaps you forgot to specify that it was opened for writing), or tried to close it and caught an error there (perhaps the disk is full). Very few programmers will go out of their way to do error checking that carefully. In Ruby you have to go out of your way to avoid error checking!
I don't know where ASP stands on that spectrum since I don't use it. I don't know where Perl 6 will stand either, but I hope that it moves closer to the above Ruby example.
But, I can see you ask, what if I don't care? My answer is that programmers who don't care are hazards to any code-base they are allowed to pollute. If they don't currently care, explain patiently why it is important, and come back to show where it would have saved them work to have cared up front, until they (hopefully) learn better.
So even though adding error checking to one but not the rest may make the comparison unfair, examples without error checking are still bad examples, and I don't like seeing them propagated as illustrations of what code should look like. So add it to the rest as well, since that is what a good programmer will likely want the code to do.