Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Revealing difference in interpretation of 'number' between Perl and $other_language

by mr_mischief (Monsignor)
on Sep 17, 2008 at 14:42 UTC ( #712013=note: print w/replies, xml ) Need Help??

in reply to Revealing difference in interpretation of 'number' between Perl and $other_language

A number is never a sequence of bits. A number is an abstract ideal.

C and C++ represent a limited subset of numbers to the compiler as a sequence of bits, because sometimes it's worthwhile to burden the programmer for the benefit of the computer.

Perl represents data as containers around scalar values, and the language deals with the same scalar container holding different types of scalar values for the programmer. This is because it's often worthwhile to burden the computer for the benefit of the programmer. Perl does sometimes need a hint about how to treat a particular value, but usually the right thing just happens, and the Perl programmer can be more efficient in implementing a program because of that.

The issue of passing a Perl string to C or C++ is that C and C++ do not handle the automated data conversion that Perl does. They need the programmer to specify things for them for efficiency and automated type checking because that's the niche those languages were meant to fill.

That C and C++ don't handle a value that Perl handles quite well could as readily be seen as a weakness in those languages as in Perl, but it's really not a weakness of either. It's just a matter of working at two different abstraction levels. The C++ guy who's complaining would have to specify a type for his variables in C++ in the first place, whereas in this situation the type needs to be specified but not until it is about to be passed into C++. That he thinks that's retarded just shows his bias and no concrete advantage of one language overall over the other.

  • Comment on Re: Revealing difference in interpretation of 'number' between Perl and $other_language

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://712013]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2018-05-26 02:41 GMT
Find Nodes?
    Voting Booth?