Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I upvoted you for the time and thought you've put into this, but I'm not sure I agree with your post.

I don't think the example you gave is a good one to debunk his argument against dynamic typing reducing code volume. First and foremost, what do the two code blocks you gave have to do with the "dynamic" nature of Perl and the "static" nature of Java? It seems to me that the gain has more to do with other aspects of the languages.

First off: it seems unfair to have the "import" line in the Java program; surely it isn't because Perl is dynamic that file operations are primitive. Likewise, what does automatic file closing have to do with static vs. dynamic languages? I'll let Java absorb that feature as well. And surely it is in the nature of a scripting language (Perl) to allow programs with no explicit modular structure, while Java (as an OO language) requires class definitions. Nothing about class definition seems to highlight the static-ness or dynamism of a language. I've also sugared this up a bit by eliminating the extra file output stream variable. I haven't Java'd for a while, but I think I got it right.
Here is my modified Java from your example:
PrintStream pStream; try{ pStream = new PrintStream( new FileOutputStream("somefile.txt")); pStream.println("This is written to a file"); catch (Exception e) { System.err.println ("Error writing to file " e); }
To me, this seems a lot more reasonable for comparison. Perl no longer holds an obvious upper hand on code length, especially considering that we can drop the Java example from eight lines to five with some whitespace manipulation.

As far as maintainability goes, I don't see how the Perl code is much more maintainable than the Java. Enlighten me?

Overall, I agree with you that slinging mud at one side or the other isn't productive; both "sides" want the same thing and can learn from each other. I just didn't think your example was very convincing.

~dewey

In reply to Re^2: Interesting read: "Why I use perl and still hate dynamic language weenies too" by dewey
in thread Interesting read: "Why I use perl and still hate dynamic language weenies too" by ghenry

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-24 02:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found