Perl, Python and noo perl
jepri at webone.com.au
Fri Apr 5 16:24:09 EST 2002
>Jeremy <jepri at webone.com.au> writes:
>>> excessive. Unfortunately the more arcane ways of accomplishing a task there
>>> is, the more instances of hard to understand code will crop up, as people
>>> exercise their ego or their desire to be obtuse.
>> There is a difference between doing it different ways and doing it
>> pathologically. If a programmer starts inserting gratuitous line noise into
>> his programs then s/he's earnt a 'carreer directions meeting' with her/his
>> employer. But a programmer shouldn't have to give up, say functional
>> programming constructs because the shop language is a BDSM object-orientated
>Agreed. I'm not sure if you were directing that at python, as python supports
>map/filter/reduce etc and can be quite useful as a functional language. It's
>making a lot of inroads in the biology and chemistry fields, in preference
>lisp or perl, and its functional aspects certainly help that cause.
No, I just had a run-in with Eiffel. It's a real BDSM language, which is probably
why it's a favourite for first year comp sci at the ANU.
It's nice that a modern open source language like Python is getting into academia
but I wouldn't get too excited about it, because these are people who still
have fond memories of Fortran 77.
>> It certainly lacks the shortcuts of a more traditional OO language, but it
>> also do a few tricks that few OO languages can get close to.
>Any examples? With python you can do crazy tricks such as changing the base
>classes of a particular instance on the fly. It's also trivial to customise
>methods used to set and extract attributes, which is very powerful.
Perl5 can't change it's base classes on the fly, but I just wrote a mostly OO
program that uses objects to generate coderefs that return data lisp style.
The oddest thing it can do is with Symbol::Approx::Sub, which is a module that
will, on the fly, detect misspelt subroutine (and method) names and redirect
the program to the 'right' method. Nobody in their right mind would actually
use it, but it is cool.
You can also dynamically install subroutines and methods into the symbol table.
Now that I come to think of it, I think you can change base classes in Perl
uding Exporter, but I've never even had the need to try. I'll have to give
it a go.
Anyone else got some neat OO tricks?
More information about the linux