From: Paul Tremblay <[EMAIL PROTECTED]>

> This question may be too vague for a good answer, but my curiosity
> makes me ask it anyway. I thought I read somewhere that perl is
> actually faster than C for certain tasks. The vagueness of the
> question probably lies in exactly what task, who writes the program,
> the size and type of data, and a dozen other factors.

        Computing power is cheap, programmers' time is expensive!

> Specifically, I am writing a perl script to convert RTF to XML. I
> downloaded a utility called unrtf, written in C, which converts RTF to
> HTML, a somewhat easier task. I got depressed when I ran unrtf on
> small files and saw that it didn't take *any* time. But when I ran it
> on a big file of 1.8 megabytes, it actually took 6 minutes and 30
> seconds. My script only took a minute! (Hooray, after all this hard
> work, that's a little encouraging to see!)
> 
> When I ran the same file through a java utility called majix, it took
> over a minute. It is hard to say exactly, because majix supplies their
> own timer, and this timer only starts when java starts processing the
> documents, some 20 or 30 seconds after you launch it.
> 
> I had actually considered learning C++ to make my little script really
> fast so that people would consider using it. I really doubt I would
> have really gone through all that trouble, but now I am wondering if
> C++ would have given that much of a time advantage--if any at all.

You might be able to speed it up a bit, but I doubt it.
I mean text munglig is something Perl has been optimized to do. Keep 
in mind that you spend most of the time in libraries and functions 
implemented in C, heavily optimized.
 
> Certainly, a perl script would be easier to maintain and debug.
> 
> Thoughs on how C, java, and perl compare on speed? 

[rem]I don't like Java.[/rem]
Java was always more of a marketing hype then a usefull language. And 
it's strong points were never thought to be text processing. Plus the 
Java runtime is bigger and havier than Perl runtime. I would not even 
consider it.

C COULD be the quickest, but doesn't have to be. Plus to be able to 
do anything you'd have to use some libraries anyway. Then it might be 
almost the same whether you use a C library from C or from Perl.

When considering whether to rewrite some Perl code into C think about 
one thing. How much time does the program spend in your code and how 
much in libraries, regexps, builtins, ...?
And how much time YOU lose while rewriting and maintaining?

Usualy you'll find out it's not worth the effort, or that rewriting a 
tiny piece of code in C and leaving the rest in Perl will be best.

Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
                                        --- me


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to