Flutterby™! : Perl stuff tabdump

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

Perl stuff tabdump

2009-03-10 18:08:28.3405+00 by Dan Lyke 8 comments

I've used the remark that Perl is "write once", even snickered about Jamie Zawinski's famous line:

Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.

I've cursed coming back to code that looks like @{$self->{-list}} that worked when I wrote it, but now needs enhancement, praised Python for various features, asked why I'm bothering with those slow interpreted languages when C++ with Boost allows most of what I want, and yet, when I need to get something running fast, I find myself returning again to Perl.

So, a bunch of programming links stolen from and inspired by recent new activity over at Genehack.

[ related topics: John S Jacobs-Anderson Perl Open Source Invention and Design Software Engineering Python ]

comments in ascending chronological order (reverse):

#Comment Re: made: 2009-03-10 19:32:51.616971+00 by: dexev

Strangely, I turn to python (or bash!) when I'm in those situations. I've come to believe that programming languages are a lot like human languages -- the first one you master just imprints its patterns in your brain, and in a very real sense you 'think' in that language.

A few years ago I had someone tell me: "You write very good C code in Python" -- and it's still true (to a lesser extent, I hope) today. Even when I use a proper 'pythonic' structure it's very concious, in the same way I'd use a Latin or a French phrase in my spoken language.

(Incidentally, trying to write good C code in JavaScript is a recipe for frustration.)

#Comment Re: made: 2009-03-10 22:42:07.655266+00 by: meuon

Modified: "trying to write good code in JavaScript is a recipe for frustration".

#Comment Re: made: 2009-03-11 03:05:58.296765+00 by: ebradway [edit history]

For years I've tried to write in Perl:

char str[30]; strcpy(str, "Hello, World!"); for (char * s = str; s++; s) if (s == ',') break;

Of course, you can do this easily with regex in Perl. But if the array contains something other than text, you're screwed...

#Comment Re: Moose made: 2009-03-11 16:18:00.174333+00 by: Dave Sherohman

If you're concerned about Moose's performance, take a look at Mouse. It's a designed specifically as a lightweight drop-in replacement for Moose, minus a couple rarely-used capabilities which slow the whole thing down just by being there:

"Compatibility with Moose has been the utmost concern. Fewer than 1% of the tests fail when run against Moose instead of Mouse. Mouse code coverage is also over 96%. Even the error messages are taken from Moose. The Mouse code just runs the test suite 4x faster.

The idea is that, if you need the extra power, you should be able to run s/Mouse/Moose/g on your codebase and have nothing break. To that end, nothingmuch has written Squirrel (part of this distribution) which will act as Mouse unless Moose is loaded, in which case it will act as Moose."

Mouse on CPAN: http://search.cpan.org/~sartak/Mouse-0.14/lib/Mouse.pm

#Comment Re: made: 2009-03-11 17:19:53.260161+00 by: Dan Lyke

Awesome, thanks, Dave! I haven't started using Moose yet, so doing the Mouse subset sounds like a perfect way to move forward! The only down-side is it's not an Ubuntu package.

Eric, there are times when using pack to convert binary data to a string type, running the regex engine on it, and then unpack is a perfectly reasonable approach.

Re: JavaScript... yeah, I'm trying to do some mapping stuff right now using OpenLayers, and egads what an abomination.

#Comment Re: Sepia made: 2009-03-12 16:30:39.145803+00 by: sean

Sepia is actually separate from PerlySense, and takes a somewhat different approach to development. The "philosophy" section of the documentation tries to explain this.

Sean

#Comment Re: made: 2009-03-16 13:21:59.280001+00 by: m

http://geekandpoke.typepad.com...oke/images/2008/06/30/perl01.jpg

#Comment Re: made: 2009-03-31 13:41:41.211073+00 by: Dan Lyke [edit history]

Argh. Okay, you Sepia users, gimme a quick head-start:

  1. I do emacs bin/myapp.py
  2. I've got my ~/.emacs set up such that that buffer is in sepia-mode.
  3. M-. M-. or any of the other shortcuts all complain that they can't find the symbol I'm trying to find.
  4. M-x sepia-repl brings up an interactive window into which I can type things like ,h, but I don't see how to load my app.

Does bin/myapp.py have to be structured in some way (which I'm happy to do)? What am I missing?