http://qs321.pair.com?node_id=700270


in reply to when to c, when to perl

I look at a lot more than just speed when picking the necessary language.

Most of the time speed is not absolutely critical. Most of the time it is not more important than a) doing the job *right*, b) being maintainable, c) being a bit portable, and other such priorities.

I might use C out of memory concerns. Perl uses a *lot* of memory in its data types.

I might use C because I want a finer level of control. A lot of byte-by-byte or bit-by-bit work is very straightforward in C, while I wouldn't want to do so much packing in Perl. There are things about C that are syntactically very convenient, like its structs, its pointers, and doing bitwise operations in C.

Perl is a heavy layer of abstraction over C. Most of the time this is a very nice thing. But sometimes you want to work under that abstraction, and you simply would rather not have it the way. In that case, I choose C over Perl. C is very simple, and really puts very little in your way. The standard library is very simple and concise, and the language is standardized. Sometimes less is more.

I also tend to use C when I want to have a close connection with my operating system or with my processor, in the way that Dennis Ritchie referred to C as a "portable assembly language". C is just more convenient than Perl in these cases. Perl is nice at making things the same (and easy) across OSes or processors, not at being really particular to them when you want to be.

I guess I didn't really explain any of that very well. I just felt I could explain why I use C about as much as I use Perl, and how speed isn't usually the reason.