Perl, Powered By Haskell

Autrijus Tang is well-known for developing the first working Perl 6 interpreter, Pugs. Pugs is written in Haskell, my new favorite language. Perl.com has an interview with Autrijus, and page 2 of that interview gets particularly interesting. Here are some quotes from Autrijus:

Haskell . . . is faster than C++, more concise than Perl, more regular than Python, more flexible than Ruby, more typeful than C#, more robust than Java, and has absolutely nothing in common with PHP.

(If it has nothing in common with PHP, it must be great, right?)

Haskell is a pure functional language optimised for conciseness and clarity. It handles infinite data structures natively, and offers rich types and function abstractions that give Haskell programs a strong declarative flavor–the entire Pugs compiler and runtime is under 3000 lines of code.

Most languages require you to pay a “language tax”: code that does nothing with the main algorithm, placed there only to make the computer happy. [Java, anyone? — jgoerzen]

On the other end of spectrum, we often shy away from abstracting huge legacy code because we are afraid of breaking the complex interplay of flow control and global and mutable variables. Besides, the paths leading to common targets of refactoring–those Design Patterns–are often non-obvious.

Because Haskell makes all side effects explicit, code can be refactored in a safe and automatic way. Indeed, you can ask a bot on to turn programs to its most abstracted form for you.

Go check out the interview (page 2) for more, including a demo program that Autrijus wrote to show off Haskell.

Thanks to metaperl for the link.

4 thoughts on “Perl, Powered By Haskell

  1. I’m inclined to learn Haskell as I already have learned Caml which is also a functional language. I can see that these languages have some advantages over, say java, the problem to their wider adoption I think is the lack of a big “standard library” like you get in java. I’d really like to see them more used though…

    1. I also learned OCaml first. It was a nice language, but some things bugged me: its weak I/O and the fact that its lists aren’t lazy. In my opinion, lists in OCaml should have operated like streams in OCaml do.

      Then I discovered Haskell, where lists work just like I wanted them to.

      I’ve been very happy.

      You are correct about the standard library size, but there has been quite a bit of work on that in Haskell in the past year or so. Haskell takes a Perlish approach of having a smaller standard library, but many easy-to-install modules. In the past year, we’ve seen new modules for SSL, IPv6, LDAP, Python integration, libmagic, Perl regexps, FTP clients and servers, filesystem virtualization, FUSE (filesystems in userland), and a few more. That in addition to the strong base (and the amazing Parsec parser combinator library).

      So yes, we don’t have quite all the frills of Python’s library (IMAP library, for instance), but we do have quite a few things going.

  2. Haskell faster than C++?? Does he mean in coding time? Because if he means execution time, everything else I’ve read indicates Haskell is way down on the list of speed. OCaml is often compared favorably to C++ speed-wise.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.