Loading ...
Sorry, an error occurred while loading the content.

174Logic Programming in Perl -- Just say no

Expand Messages
  • Curtis Poe
    Mar 30 1:48 PM
    • 0 Attachment
      Sorry for starting a new thread; I just joined this list. I was told
      about the thread regarding different paradigms of programming and how
      "Perl" allows one to handle many different and thus one doesn't need to
      learn other languages. Pulling out one quote from Rob Nagle from the
      thread:

      > Here's a bold statement: you don't really need to learn a new
      > programming language, if you know Perl. Perl allows you to think like
      > you would in Haskell, C, Java, Lisp, etc. You do need to learn all
      > that Perl offers, and that's where HOP fits in.

      Rob, I'm sorry, but this is completely wrong. It reminds of me of a
      kid in a writing class who explained to our prof that he doesn't need
      to visit foreign countries because he has the Internet. I didn't know
      whether to laugh or cry.

      Another example: I speak French. I don't speak it as well as I used
      to, but I can still hobble along a bit. As soon as I started learning
      French, my grades in English shot up quite a bit. Aside from some odd
      idiomatic constructs in both languages, there's little that can be
      expressed in one that can't be expressed in another, but that hardly
      suggests that learning French is a useless exercise.

      More examples: when I learned Java, my OO Perl knowledge and ability
      improved tremendously. There's not much in Java that I can't do in
      Perl (the reverse is not true, oddly enough), but even Java's "almost
      OO" implementation was tremendously useful.

      And then we get to Smalltalk. Take a gander at this code
      (http://squeak.org/tutorials/cphoenix_tutorial/intro.html):

      1. hello: times
      2. (times > 100)
      3. ifTrue: [ Transcript show: 'You will get bored!']
      4. ifFalse: [1 to: times do: [:i | (Transcript show: 'Hello
      World') cr]]

      (I added the line numbers)

      Line two is not a conditional. It's a constructor that returns a
      boolean object. Lines 3 and 4 are the "ifTrue" and "ifFalse" messages
      that are sent to the boolean instance. The object decides how to
      handle (and even ignore) those messages. There really aren't if/else
      statements in Smalltalk. And what does that mean for this argument?
      After I started thinking about that for a while and examining my OO
      code, many of my if/else statements were actually encapsulation
      violations. By rigorously excising them, my code became simple, more
      correct and easier to maintain. By diving into another programming
      culture, I learned more about my own.

      Maybe you can do without other programming languages for the bulk of
      your work, but you cannot replicate their culture in Perl. You cannot
      truly understand what it is to be French without living over there.
      Think of Java: so much Java code out there is merely procedural code
      wrapped in classes. There's nothing OO about it (and the same is true
      of many Perl OO modules). However, those who write that code are quite
      likely to claim they understand OO.

      So my subject was rather tongue-in-cheek, but it's not too far off.
      MMy code currently only touches the full power of logic programming.
      It doesn't allow modules, there are no definite clause grammars (yet)
      and operator support is limited. What does most of that mean? Who
      knows? One will never know if one only goes by my code.

      Cheers,
      Ovid
    • Show all 9 messages in this topic