As the title of this article already describes, today we will try to find out the features of Perl that make it better from C. Also, we will leave the points that make C better than Perl.
The first benefit of Perl over C is that since Perl is an interpreted scripting language and supported on almost all the standard operating systems, it is portable. C, natively, is dependant on the OS it is used for. It is possible to use a cross-compiler to write code from one OS for another OS. But the same code (99% of the time) cannot be used for any two OS's. There are bound to be platform based dependencies.
Secondly, Perl has lots of pre-written modules available for virtually every imaginable programming requirement. But in C, generally, one has to write everything from scratch. This massive Perl code repository is found on CPAN.
Perl can be "compiled" into a single executable using solutions like PAR::Packer and others. Though, this method does not actually "compile" the Perl code (actually it puts the interpreter and all the code to run it into a single executable) and is not very effective most of the time. This feature is growing with time.
Perl is easy to learn and use. With no compilation/linking required to run, it can be executed instantly. While C programs involve a compilation phase. This feature can have a small impact on Perl code being written faster than C code.
Perl syntax is considered more well-formed for text processing and parsing jobs. C does not have any benefits in this particular field. Also, the Perl special variables are very useful for quickly assigning and retrieving values of things that would require multiple lines of code in C. C does not have any such special variables or any similar features.
So, these (there are many more) are the benefits of Perl over C. Surely C language also has many benefits over Perl, one of them being that C can be (and is) used for developing systems level code like writing a complete OS. While Perl cannot (as yet) be used for making an OS. Also, compiled directly to machine code, C programs are considerable faster than Perl scripts doing the same job. This speed difference, however, may vary and could be surprisingly less in real production environments.
Both C and Perl have their benefits but there are few other programming languages that equal Perl in what it does best.
0 comments:
Post a Comment