Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: (Completely OT) - Hero(i)n programming language on Slashdot

by BrowserUk (Patriarch)
on Dec 15, 2004 at 16:19 UTC ( [id://415095]=note: print w/replies, xml ) Need Help??


in reply to (Completely OT) - Hero(i)n programming language on Slashdot

I've following along on this thread waiting for the punchline, but it seems to be missing :)

Arguing about whether Perl is or is not strongly typed --and by which of the myriad (conflicting) definitions of that phrase it is or is not so--seems a little like arguing whether Lamborghinis or Ferraris are 'true sports cars'. Everyone has their of understanding of the term and places their own level of importance upon it.

A better discussion might be whether Perl's type system is useful or not. One of the things missing and sorely needed by most languages that have static typing is a generic or polymorphic type, that allows generic collection libraries to be written without wholesale cut&paste (automated or not), to support each different containable type.

After C++ first started gaining popularity, the absence of polymorphic container classes, and the near impossibility of writing them became apparent very rapidly.

The proposed and adopted answer was Templates. These are a mess, especially the early variants. They are essentially nothing more than (slightly) sophisticated C-style source-code macros. Create a template Bag class and then instantiate a Class for each of chars, ints, longs, floats, doubles, strings, Dogs and Widgets, and you end up with 8 copies of the 90% of the code that is common. Cut&Paste under a different name.

Newer veriants of Templates may be more sophisticated than this. I haven't touched C++ for years--and fervantly hope I never have to again.

Anyone who's done anything remotely complicated in Java will also know this problem, of a lack of a generic type. And the problems it creates when dealing with any external data source where the type of the data can only be determined after you've read it. Example, communications protocols. The lack of C/C++ unions makes for very clumbsy handling of datastreams where you cannot predetermine whether the next few bytes are a string, an int, a float etc.

There are now moves afoot to correct this limitation in Java. I can't comment on it, beyond that the fact that as the home page is not on a Sun site, it makes me a little wary. But it does highlight that people are seeking to address this limitation.

Here we are with Perl's 'roll-your-own' OO and 3 1/2 types, and yet we have two, simple, powerful, infinitely flexible polymorphic container types: Hashes of scalars; and arrays of scalars; from which it is possible to construct any number of easily usable containers with specific behaviours, that have a common syntax, and can be efficiently operated on (iterated over, tested for existance, compared, deleted etc.), using many of the built-in language features and functions*.

In addition, we have the tie mechanism that allows us to use our 3 1/2 types to encapsulate a whole raft of other types, behaviours and complexities behind those same, 3 1/2 simple interfaces.

We should be laughing ourselves silly at all those pundits that think that calling Perl "not strongly typed" is an insult.

Whilst they continue to to try and devise a polymorphic container mechanism, that they obviously need, and fighting their compiler over who knows best about what the program should and should not needs to do--we can just get on with the business of writing code, easily and quickly, that does what we need it to do.

*Why people ignore the simplicity and usability of Perl's hashes and arrays as polymorphic containers and instead opt for using the so-called "Factory Pattern" to achieve the same thing with a much less usable and much less efficient interface puzzles me greatly.


Examine what is said, not who speaks.        The end of an era!
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://415095]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found