Random Perl ... rant

Jonathan Rockway jon at jrock.us
Thu Apr 3 12:05:17 BST 2008


* On Thu, Apr 03 2008, Iain Barnett wrote:
> Are you all having a laugh? Or perhaps you're watching WarGames on
> beta max while listening to Meat Is Murder?
>
> Visual Studio s*** all over Komodo (the free one, don't know about the
> paid for one) and EPIC for Eclipse. Really. I'm not here to sell  you
> a copy, but if you'd used it you'd realise it was light years  ahead
> (and I don't mean back in the mists of time or for a week  before you
> gave up). M$ may not do a lot of things well, but dotNet  and Visual
> Studio are very very good. Perhaps Eclipse is really good  for Java,
> too, I don't use Java. I get the feeling it would be better  than
> EPIC, but EPIC needs more support (hint hint).

Here's the difference between Java and Perl when it comes to IDEs.  Java
source files contain all the meta-information that the IDE needs to know
in order to provide nice features.  Perl doesn't have any language
features that would allow you to put that information in the program
text.  Here's an example of how you'd write Perl if you wanted working
method name completion:

  package Another::Class;
  use My::Class;
  use Some::Exception;

  use Moose;

  method OH_HAI throws Some::Exception {
      my Another::Class $self = shift;
      my My::Class      $foo  = shift;

      my Fixnum $product = double($foo->number); # throws Some::Exception

      #  ... now you can complete on $self, $foo, and $product, as long
      #  as you agree to never use any dynamic features of Perl, like
      # *{ Foo::bar } = sub { ... }
  }

Any productivity gained by using Perl has just been lost by restricting
yourself to what amounts to Java with sigils.  Java needs an IDE because
the language is so verbose that the computer can type most everything
for you.  Perl doesn't need an IDE because every line *means* something.
(FWIW, I don't use IDEs when writing Java either.  Emacs provides me
with all the features I need for wrangling it.  It doesn't provide a
drop down menu of method names, but after reading the docs, my brain can
do that much faster anyway.  What a fucking concept.)

Now the good news is that heuristics work great on Perl code.  I use
emacs' "dynamic abbreviations" feature, which is just as good as "real"
code completion.

Here's how it works.  You type some text:

  my $foo = Ano

Then you press M-/, and emacs scans the current buffer, other perl
buffers, and all other buffers for what looks like a completion.  M-/
lets you cycle through the alternatives:

  my $foo = Another::Class
  my $foo = Another::Class::With::Some::Awesome::Feature

The difference between this and something "smarter" is that emacs has
absolutely no idea whether what it's completing for you makes sense (or
is syntactically valid).  The fact of the matter is, that doesn't
matter.  You type some long thing once, and as long as that file is open
you'll be able to get at it very quickly in the future.

Oh, like most of emacs' text replacement functions, it's sensitive to
the "case context".  So if you've written "package Classname" somewhere,
and want a variable to store an instance, you can type "my $cl" and it
will complete to the all-lowercase "$classname".

Anyway, the point of this rant is that IDEs are necessary for Java
because the language requires you to offload every detail of the code to
the source file.  Perl lets you keep that information in your brain.

And finally, Perl allows for some development techniques which the IDE
languages don't readily allow, like coding in a REPL.  Can you imagine
how many hoops you'd have to jump through to usefully develop Java in a
REPL?  I can, and it's a lot :P

Regards,
Jonathan Rockway


More information about the london.pm mailing list