Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

90% of every Perl app IS written already

by dragonchild (Archbishop)
on Oct 21, 2003 at 21:02 UTC ( [id://301068]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Multi tiered web applications in Perl
in thread Multi tiered web applications in Perl

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.

Replies are listed 'Best First'.
Re: 90% of every Perl app IS written already
by dug (Chaplain) on Oct 21, 2003 at 21:16 UTC
    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?)
    Well, *I'm* counting ;-) You use XML parsing as the canonical example, and I appreciate how XML::LibXML simplifies my life (mostly because Perl simplifies my life), but it's not that difficult to parse an XML document using libxml2's native interface.

    Personally, most of my large apps are down in the 80-85% range
    This will help explain why I said your previous statement was patently false. You said 90% of *every* program. The reason that rubbed me wrong is because it can't be true. I re-use a lot. I was just curious as to how much other folks tend to re-use. That's all.

    -- dug

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://301068]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-03-28 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found