![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I’m prepping for an interview this afternoon at what is primarily a Perl shop, and so I’m mainlining the O’Reilly Perl in a Nutshell book as a way of reminding myself about the little details of the language. I can write Perl just fine– I just made some major hacks to dailystrips for example, and I write various renaming and text processing scripts all the time in Perl, because it is the language for that kind of thing.
But it’s little corners like, exactly what does bless do, that I’m reminding myself of. I know it’s the OO instance creation operator, and I remember the instantiation procedure but what exactly does it do?
So I go read the source code for Perl, in C, because that’s where the magic is kept, and I discover to my not-so-surprise that bless is a complete and utter hack. It puts a flag in the dereferencer to point to a different function, one that seems added after-the-fact, that instead of handling a procedure one way, instead just handles it another way with the recently dereferenced scalar as the first argument. That’s all it does. OO is so “bolted onto the side” of Perl that it’s amazing how important it seems to have become to the language.
But there’s so much missing from Perl; the whole metaprogramming capabilities of modern languages like Python, Ruby, and Javascript is just gone– done instead with code generation and eval, good grief– and yet the capacity for obfuscation is so terribly great. In many ways, Perl feels more like Bash scripting with a much bigger library of niceties and bolt-ons, which may explain why I use it that way.
This entry was automatically cross-posted from Elf's technical journal, ElfSternberg.com
no subject
Date: 2009-07-10 06:01 pm (UTC)I did this a while back, but it's not at my fingertips anymore.
no subject
Date: 2009-07-11 02:40 am (UTC)Pay No Attention to the Man Behind the Curtain
Date: 2009-07-10 06:20 pm (UTC)Now you've taken all the magic out of your life by exposing it as simple dreck, so where does that leave you? :^)
Personally I consider C one of the worst programming languages ever created, which probably explains its popularity. It's a bunch of programmer shorthand that was never consistent across machines with different word lengths, and statements that looked perfectly simple and reasonable and would compile and execute just as you expected them to in virtually every other language could give you horribly wrong answers in C. And as for "the awesome power and flexibility of pointers", I would be just as happy to see them disappear at the same time that PEEK and POKE and GOTO disappeared from the programming ventricular.
YMMV, but mine is at least an equally informed opinion.
--DB_Story
Re: Pay No Attention to the Man Behind the Curtain
Date: 2009-07-11 02:54 am (UTC)I would be interested to see you try to do anything useful in C without pointers. Go on, try it.
Re: Pay No Attention to the Man Behind the Curtain
Date: 2009-07-11 04:10 am (UTC)Funny thing, I can write in Java, which is pretty darn C-like, and nary an exposed pointer to be seen. And I can name quite a few other high-level languages that I can say the same about.
And yes, I've written in nearly a dozen assembly languages over the years, actually rather like assembly when there's a reason for it (my absolute favorite was for the PDP-11), and have no trouble at all working with direct memory addresses. The point of high-level languages is to not have to deal with the housekeeping tasks and make coding faster and errors harder to commit.
My C experience goes back to 1977, and I've never liked it. But then again, that's just me.
--DB_Story
Re: Pay No Attention to the Man Behind the Curtain
Date: 2009-07-11 05:50 am (UTC)no subject
Date: 2009-07-10 06:47 pm (UTC)(And "Bash scripting with a much bigger library of niceties and bolt-ons" isn't a bad way to describe the origins of Perl... The desire was to incorporate into one tool the libraries and bolt-ons normally involved with shell scripting, things like grep, awk, sed, etc).
The good news is that Perl6 is OO through-and-through; the bad news is that Perl6 has been in development for nearly a decade and isn't ready yet; the second good news is that there are already working implementations of Perl6 (as it stands now) that can do some amazing things; the second bad news is that they aren't ready for production yet.
no subject
Date: 2009-07-11 01:55 pm (UTC)