http://qs321.pair.com?node_id=308003


in reply to Re: Re: Re: Arguments needed for comparision between Perl, ASP and Java
in thread Arguments needed for comparision between Perl, ASP and Java

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:

# Method one, passing in a block File.open(filename, "w") { |aFile| aFile.print("We are writing a line of text to a file.\nSecond line") +; } # Method two, handling everything yourself aFile = File.open(filename, "w"); aFile.print("We are writing a line of text to a file.\nSecond line"); aFile.close;
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.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Arguments needed for comparision between Perl, ASP and Java
by zby (Vicar) on Nov 19, 2003 at 15:57 UTC
    I love this quote from the linked B. Eckel article:
    My theory is that when someone is trying to do something and you are constantly prodding them with annoyances, they will use the quickest device available to make those annoyances go away so they can get their thing done, perhaps assuming they'll go back and take out the device later.
    I think this is very close to the 'Huffman coding' line of thinking by Lary Wall.