|P is for Practical|
Re: Re: Re: Re: C vs. Perlby dragonchild (Archbishop)
|on Oct 22, 2003 at 20:02 UTC||Need Help??|
Elian - I specifically stated in a later paragraph that high-performance items should be written in C over Perl. (I make no statement about any other language in that sentence.)
My use of the word "ease" is in the sense of "ease of initial development". Perl is the rapid-prototyping language of choice for me and most people I know. Now, if I need greater performance (for some aspect of performance) after writing the first version(s) in Perl, I will evaluate to see if porting it (or some parts) to another language, such as C, is something I feel is warranted.
And, there are whole classes of problems for which neither C nor Perl is the best tool. For example, database queries. SQL is a much better language for querying normalized data than C or Perl. Hence, the reason why Pro*C exists and why we pass SQL to DBI instead of querying the tables in native Perl.
As for writing interpreters in one language vs. another ... I'm going to suspect that writing the parsing portion for an interpreter is easier to do in Perl than in C, simply for the string manipulation functions. Now, having that parser do its work within a reasonable amount of time (for some value of reasonable) ... that's where it becomes a high-performance item, and another language (such as C) could be considered.
There is also a lot more history writing a parser in C vs. Perl, so a number of the standard gotchas have been solved in C. Solutions in one language, especially ones that take advantage of extremely advanced language features, are generally not easily translatable to another language. So, one would have to rebuild all those standard solutions in Perl. (This, I suspect, is one of the reasons why more parsers are not written in languages other than C, even if there may be other reasons to do so.)
(Please note that I have never written anything more than a toy parser. It would definitely be something interesting to do.)
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.