Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Let's say I want to write a basic application. It reads in an XML file, does some stuff to it, then writes it out to a CSV. Quite a common thing to do, actually. It might look something like:
use strict; use warnings; use XML::Parser; use Text::CSV; # Do my parsing here ... maybe 100 lines # Do my munging here ... maybe 100 lines # Do my writing here ... maybe 25 lines.

A total of no more than 225 lines of code I wrote. Now, let's see how much code was provided for me. Not counting the amount of time I save because Perl natively does for me the following:

  • Memory management
  • Hashes as first class variables
  • Lists as first class variables
  • Datatype conversion
  • A lot more than that

Already, I've saved about 25% over most other languages, just from choosing Perl!

But, that's not what you care about. XML::Parser was a huge portion of this application. Parsing XML is one of the harder things you can do. Let's say that takes about 1500 lines to do. (It's actually much more than that, but who's counting?)

Now, writing to a CSV sounds easy. But, it's actually really complicated. There're a lot of exceptions that have to be handled just right or you get screwed up. Let's say that's another 500 lines of code. (Again, it's more than that, but who's counting?)

So, we have at most 225 lines we wrote and at least 2000 lines we didn't have to. My math may be off, but that seems to be about 90% I didn't have to write, test, maintain, or do anything with ... except blithely use.

Those numbers hold pretty close, in nearly every application I've ever worked with. You want to deal with XSLT? No problem! Excel? Done. Databases? Nearly every one is supported out of the box. OO getting you down? Pick your poison.

Personally, most of my large apps are down in the 80-85% range, because I like to write large object hierarchies. But, that's just me. A lot of people (especially sysadmins) are in the 95-97%(!) range, leveraging huge amounts of code.

Update: I forgot to even mention the time savings, which are often in the 98-99.9% range. I once had a scripty-doo up and running that correlated information between an Oracle database, a MS-SQL database, and an XML document, outputting the results in Excel ... in less than 15 hours, from scratch. That is impossible in any other language. Period.

We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

In reply to 90% of every Perl app IS written already by dragonchild
in thread Multi tiered web applications in Perl by pernod

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 contemplating the Monastery: (3)
As of 2023-06-08 06:01 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.