Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: C vs. Perl

by Roger (Parson)
on Oct 23, 2003 at 02:05 UTC ( [id://301445]=note: print w/replies, xml ) Need Help??


in reply to C vs. Perl

It's not fair to compare the core of C with Perl. They are not on the same level. Perl is like C with lots of handy and powerful libraries, and Perl has built-in memory management.

Ok, let's give C the additional libraries DIE, ARRAY, FILE, HASH and SPLIT, and the competition is more fair.

#include <stdio.h> #include <DIE.h> #include <ARRAY.h> #include <HASH.h> #include <SPLIT.h> #include <FILE.h> int main(int argc, char **argv) { FILE *f; char *buf; HASH *h = new HASH(); if ((f = fopen("data", "r")) == NULL) DIE("unable to open file"); while(buf = READFILE(f)) { ARRAY *ar = SPLIT(buf); h->AddElement(ar[0], ar[1]); free(ar); free(buf); } printf("price of apple is : %s\n", h->GetElement("apple")); fclose(f); return(0); }

Replies are listed 'Best First'.
Re: Re: C vs. Perl
by Anonymous Monk on Oct 23, 2003 at 02:26 UTC
    Of all the offbeat replies in this thread, this has to be the most ridiculous - While we are at it, why don't we also add the GETPRICE.h library, then our code would be as simple as:

    #include <stdio.h> #include <GETPRICE.h> int main(int argc, int *argv[]) { PRICE *p; if (init_price(p, "file") != 0) return 1; printf("The price of an apple is %s\n", get_price(p, "apple")); destroy_price(p); return 0; }

    The summary of this thread should simply be - C and Perl are different, get over it.

      I think you are missing the point. The GETPRICE module implements a specific business rule, it is not a utility module.

      Yes I agree Perl and C are different, but they are really not THAT different.

Re2: C vs. Perl
by dragonchild (Archbishop) on Oct 23, 2003 at 17:22 UTC
    Excellent point, and a wonderful example. Now, I believe that these libraries do exist (in a fashion) in the Perl distribution. I'd be curious to see how one would use these libraries in a real program ...

    ------
    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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found