in reply to Revisiting the old clichés of programming languages
Perl is slow:Well, it is interpretedWell, Perl is slow compared to languages like C, but the impact its "interpretedness" has isn't great. (For the record, Perl isn't interpreted. When you run a Perl program, it first gets compiled into bytecode. Then the bytecode gets run). Even if you was a compiler that turned Perl code into a native binary, Perl would still be slow. The slowness is the price you have to pay for the flexibility you get.
For instance, from a programmers point of view, a scalar can hold a number or a string. That's convenient. But if you want to add two (integer) variables, in C you have the addresses of the variables, so it's just FETCH, FETCH, ADD. Not so in Perl. You first FETCH the meta data (SV), which is a struct. Then you test whether the variable holds an integer value (check a bit in one of the structs fields). If it has an integer value, do you a FETCH of that (add offset to pointer stored in the SV struct). If not, fetch the string value (follow two pointers from the SV), turn the string value into a pointer, store the integer value (which may require upgrading the PV hanging off the SV into an PVIV), and flip the bit in the SV. Repeat this for the other value. Then you add the two values, giving you a new value. Said new value need to be stored into an PV, which needs an SV as well, so you've two calls to malloc to get you memory for the structs. Which you have to fill in. Of course, this assumes no magic has been attached to the values. Which you have to check for.
Compared to C, this makes Perl slow. Now, this is a price we all pay gladly; but that doesn't make Perl fast.
Perl is prone to obfuscation:It's hard to create a useful language where it's hard to do obfuscation.
PHP is for web developmentMany people consider Perl to be for web development as well. And it's hard to deny. The sharp increase of the usage of Perl in the mid nineties coincided with the general public discovering the "web".
but I have seen full applications (not web related) written in PHPWell, people use regular expressions to find prime numbers, but that doesn't mean regular expressions are for numerical calculations.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Revisiting the old clichés of programming languages
by chromatic (Archbishop) on Jan 26, 2009 at 18:31 UTC | |
by JavaFan (Canon) on Jan 26, 2009 at 18:38 UTC |