|Syntactic Confectionery Delight|
Re: C vs. Perlby gmax (Abbot)
|on Oct 22, 2003 at 16:02 UTC||Need Help??|
Some criticism about your code is in order.
In Perl you would write like this
In Perl I would write a one-liner.
your code should be able to handle any number of items
But yours will only handle as may item that can fit into your system's memory. If I had really to handle "any number of items" I would use a DBMS. And still you fail to convince me that I couldn't do the same in C. With more lines of code, perhaps, but I can do it in any language I have used so far.
But let's assume that there is no "apples" in your input. You would print an empty price. You should check first.
The bottom line is, you don't compare two main languages using such a trivial example and offering no alternatives, especially if your "positive" example is questionable as well.
I have coded in C for many years, and when I switched to Perl it wasn't because C wasn't up to my expectations. It's simply that Perl is easier and faster to code.
If you want to consider a more critical comparison of a specific implementation of a well established algorithm, have a look at Perl's pearls
_ _ _ _ (_|| | |(_|>< _|