in reply to compiling perl scripts aka why is perl not as fast as C
I often read arguments for and against strict typing vs. no typing as in Perl.
Let me clarify that Perl does have static typing - it is implied by sigils, and works at compile time. Any expression that begins with @ returns a list or an Array, for example.
However instead of type check failures, you get coercions in many places, which is why you often don't recognize them as types.
Other than possibly catching errors and thereby making for more robust programs, strict typing doesn't by itself contribute to any speed gains, does it?
Sure it does. The more a compiler knows about a program, the more it can optimize. Types are just one of those possible informations.
Also in Perl 6 types are very important for extensibility: you can write multi routines with the same name, where each of these single routines only accepts certain types. That means that you can "overload" those names for custom types. For example
class TurkishStr is Str { ... } multi sub uc(TurkishStr $x) { # handle upper-casing i to I with dot above somehow } # now you can write say uc $string; # and it will work both for ordinary stringsand for Turkish Strings.
It seems like just an excuse for macho programmers to snigger at sissy programmers such as me?
Never attribute to malice what may in fact just be your own state of not being well informed.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: compiling perl scripts aka why is perl not as fast as C
by ikegami (Patriarch) on Mar 21, 2010 at 21:59 UTC | |
by moritz (Cardinal) on Mar 22, 2010 at 09:56 UTC | |
by ikegami (Patriarch) on Mar 22, 2010 at 17:10 UTC | |
by moritz (Cardinal) on Mar 22, 2010 at 17:26 UTC | |
by ikegami (Patriarch) on Mar 22, 2010 at 17:39 UTC | |
| |
by Hue-Bond (Priest) on Mar 22, 2010 at 17:50 UTC | |
by ikegami (Patriarch) on Mar 22, 2010 at 17:56 UTC | |
by ikegami (Patriarch) on Mar 22, 2010 at 18:38 UTC |