Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) 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:

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

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

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2023-03-30 20:53 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (74 votes). Check out past polls.