Hacker News new | past | comments | ask | show | jobs | submit login

How many new initiatives use Perl though? There's a lot of legacy code in that list.




We had the "What language?" talk when we started work on Cloudmin, as well as when we began planning some web services. Perl ended up on top in both cases. Admittedly, we have a historic codebase of several hundred thousand lines of Perl, but we've both worked in Python at least as much as Perl in the past several years and there is a version of our API in Python that we could have started from. We weren't forced to choose Perl for legacy reasons, but we chose it, anyway.

We're pretty much agnostic about languages; we prefer dynamic languages, but not much beyond that. Our website is running on Drupal and several custom modules in PHP. We'll be adding those afore-mentioned web services via frontend PHP code, but the backend will be Perl. Haskell might make an appearance at some point in the future for concurrency work where performance matters, but for now, Perl is plenty fast and has reasonable concurrency mechanisms for our needs.

So, we're still cranking out tens of thousands of lines of Perl every year, and will be launching a couple of new products in the next six months also written in Perl.

But, I will mention that our products directly and easily support PHP, Ruby on Rails and Django deployments, but not Catalyst. And it's because we're simply not hearing requests for Catalyst from paying customers. Maybe the Catalyst developers are more old-school and don't trust a control panel (even one written in Perl), or maybe there's a helluva a lot more PHP and a handful more Ruby on Rails and Django developers out there (note that PHP developers using our software outnumber RoR and Django developers to a degree that makes the latter two practically noise in the signal). So, realistically, I have to agree. Perl is a niche language for new developments, but then again, so are Python and Ruby.


Perl is what I use for my new initiatives, and it's a choice I've made through careful consideration of many alternatives. Perl has the right "balance" of languages features for web applications.

Some options I've tried and what I didn't like:

Haskell is much faster and a better language in general, but just doesn't have enough usable libraries for writing web applications. (My first Haskell web application was an application that generated an image of the latest Twitter post from a user using a given hashtag. It went together quickly enough, but I didn't really feel like "wow, this was a great web development experience that has changed my life". I do feel that way about Haskell for text processing and system programming, ironically. It definitely beats Perl there. But for simple and complex web applications, Perl is much better.)

CL has the best development tools of any language, so I really wanted to like it, but it doesn't really have a coherent community. I started writing a web application in CL to allow clients to email us files, even when they were behind a firewall that blocked outgoing email and ftp (!). This didn't go too well; I really didn't like cl-who or html-template, and there were no other options. (People in #lisp agreed with me, but their advice was to "just write my own". The answer to every question about libraries on #lisp is "just write your own".) I started porting Template::Refine from Perl to CL (see template-refine and cl-template-refine on my github), so I could generate HTML. closure-xml and cl-stp are great XML libraries, BTW. The next thing I wanted was a dependency-injection framework. There were no libraries for that, so I had to "just write my own". cl-junkie is on my github (junkie, "dependency injection", get it?), but I got bored and didn't finish it. I ended up not needing the app anyway. Too much yak-shaving lets you get over the excitement of your actual idea, and leads to it never being done. With Perl I can get a working application before I am not excited anymore. (Then I get excited about cleaning up the libraries, and do that afterwards. Bootstrapping++)

Moving along, there is Scala and Clojure. Scala is a fine langauge, it really "gets" functional programming. Clojure is not to my liking. (And it's not the parentheses; I have a shit-ton of "production" Emacs Lisp lying around.)

These languages are both cases of the "oh, just write your own libraries" community problem. Even worse is the potential to reuse Java libraries. I don't see the point of using a nice functional language with overly-verbose libraries that are going to randomly throw NullPointerExceptions. Many other problems I have with Java carry over to Scala and Clojure if you use Java libraries. (Design pattern overload, extremely poor object system, no types that cannot be null, etc.)

(I know I said "bootstrapping++" above, and that you can bootstrap clean Scala/Clojure libraries off the messy Java ones. But it's just too painful for me. It's not boring, it's just pure pain.)

I use Scala for Android applications simply because there is absolutely no other option. (I couldn't get any Clojure code to compile, and I am certainly not going to use plain Java. I prefer Scala to both anyway, but obviously I would prefer various non-JVM languages to those.)

So then there are Ruby and Python. Both are basically Perl with very tiny superficial differences, so there is no reason to waste my time becoming good at those. (Similarly, if you are a Ruby guru, you will probably not be too excited to switch to Perl. Same language, except you aren't a guru anymore.) I think Perl's libraries are, in general, more extensive and more mature than Python or Ruby's. But for the beaten path, you will do fine with any. Ruby has this "Rails" thing that I hear is pretty popular.

One thing I've noticed, though, is that the Perl community is better at stealing from Ruby and Python than those communities are at stealing from us. DBIx::Class is significantly more advanced than any Python or Ruby ORM that I know of, KiokuDB is the only sane object database among those three languages, etc., etc. But Ruby and Python still don't have anything close. OTOH, Python's WSGI and Ruby's Rack are great ideas... so the Perl community now has PSGI and Plack. So you can see why I find it compelling to stick with Perl. Good ideas eventually migrate over here, and the community supports them.

Anyway, if I had a point, it's that there is no reason to disqualify Perl from "what should I write my new app in" discussions, except ignorance. Perl has its tradeoffs, but so does anything else available. (Don't let "I last used Perl in 1995, so Perl must still be the same as it was in 1995," ruin your next application development project!)


Ruby and Python are basically Perl with superficial differences? How in the world did you come to that conclusion? I don't think I have ever seen anyone make that argument before.


I can only explain in terms of an experiment:

Write an algorithm (or app) in your favorite language of the three. Then port it to a different one of those three.

Now port to Common Lisp or Haskell, and see how your code feels different.

I find that Ruby/Python/Perl basically let you write the same program with different syntax. "$self->foo" instead of "@foo". I find that Haskell changes the way you actually program. Example: Nobody (except me) uses a type like Haskell's Error monad in Perl; they use exceptions.

(Similarly, look for a "web framework" in Perl/Python/Ruby. Perl has Catalyst. Python has Django. Ruby has Rails. They are all different, true, but the idea is the same. If three people each started the same project on those various frameworks, the end result, code-wise, would be very similar.)


While you will have that experience with a lot of code, there are some concepts that don't translate so easily.

As an experiment port this Ruby to Perl:

  def  each (arg,*more_args)
      ( [] != more_args ) ?
          arg.each {|l| each(*more_args) {|r| yield [l]+ r }} :
          arg.each { |r| yield [r] }
  end

  each( 1..2, 'a'..'c', 'A'..'D') { |args|   puts args.join " " }
Then port this Python to Perl:

  def fib():
      fn2 = 1
      fn1 = 1
      while True:
          (fn1, fn2, oldfn2) = (fn1+fn2, fn1, fn2)
          yield oldfn2

  g = fib()
  for i in range(20):
      print i, g.next()
See what I mean?


The second one is easily translated into Perl 6:

    sub fib() {
        my $fn2 = 1;
        my $fn1 = 1;
        gather loop {
            my $oldfn2;
            ($fn1, $fn2, $oldfn2) = ($fn1 + $fn2, $fn1, $fn2);
            take $oldfn2;
        }
    }

    my @g = fib;
    for ^20 -> $i {
        say $i, @g.shift;
    }
That's untested because lazy evaluation isn't yet supported in Rakudo Perl 6, but my understanding is that feature should be up and running in the next few weeks.

I don't know enough Ruby to make heads or tails of the first example, though...


Some people refer to carbonated sugary beverages as "soda" and others say "pop", but both are still speaking the same language.


  $point->missed
I know Perl far, far better than I know Ruby or Python. But I can't easily reach for the abstractions in those examples within Perl.

That said, I'm in agreement with your basic point. On the whole the scripting languages (including JavaScript) are much more similar than different.


I don't consider these as being particularly interesting differences. With the right modules, I can write code that looks like that in Perl. (It's not idiomatic, though, so it is worth exploring other languages to see which idioms you'd like to steal. I stole monads and applicative functors from Haskell for Perl in MooseX::Data, for example. Monadic control flow is not a common Perl idiom, but it is perfect for my asynchronous CPAN client.)

I am talking major differences, things that are so fundamental that you can't really steal. Looking at Haskell, I see things like lazy evaluation, purity, static typing and type inference, etc. Very, very different from Perl.

In Scheme, I see the "call stack" as a graph of frames, not as a linked-list as in C. This is quite radical.

But in Ruby and Python all I see are different built-in functions, some with special syntax. (Generators, list comprehensions, etc., etc.)

I know Perl far, far better than I know Ruby or Python. But I can't easily reach for the abstractions in those examples within Perl.

I can. I hope you are considering CPAN as part of Perl, because "core perl" is a very, very outdated and broken programming language. I think I would even prefer Java!


Really? People make it all the time. The only way to see significant differences between them is to be too close to them, and too far from anything else, to have perspective. There certainly are differences, yes, but they are next-door neighbors in the sprawling, diverse city of programming languages.


Or to have a different opinion of significant I guess.

Python has docstrings and list comprehensions and keyword arguments and generator functions and readable syntax. To me, these are all significant differences from Perl.

See also Eric Raymond's piece "Why Python?" at http://www.linuxjournal.com/article/3882


Not sure your list of differences is up to date. We have keyword arguments (with rich user-defined type constraints) and docstrings via Moose and MooseX::Declare. We have generator functions (actually, first-class continuations and coroutines) via the Coro module. I have never had trouble reading even very bad Perl code, so it seems to me like it is "readable".

(There a few list comprehension modules on CPAN, but they are all implemented wrong. A correct implementation is not difficult, but I personally don't see the value and haven't bothered to implement it right.)


I'll add another feature that Python tends toward standardization and batteries included rather than modules. With the right modules, you can probably make Java look like Python, but that's not the point... to me at least. I'm explicitly talking about opinion here. I hope it's ok for me to have a different opinion.


Ruby is definitely strongly perl based (cross-bred most noticeably with smalltalk).

From http://linuxdevcenter.com/pub/a/linux/2001/11/29/ruby.html:

Stewart: I gather you had worked with both Perl and Python before creating Ruby. What bits of Perl did you incorporate in Ruby?

Matz: A lot. Ruby's class library is an object-oriented reorganization of Perl functionality--plus some Smalltalk and Lisp stuff. I used too much I guess. I shouldn't have inherited $_, $&, and the other, ugly style variables.


>One thing I've noticed, though, is that the Perl community is better at stealing from Ruby and Python than those communities are at stealing from us. DBIx::Class is significantly more advanced than any Python or Ruby ORM that I know of, KiokuDB is the only sane object database among those three languages, etc., etc. But Ruby and Python still don't have anything close. OTOH, Python's WSGI and Ruby's Rack are great ideas... so the Perl community now has PSGI and Plack. So you can see why I find it compelling to stick with Perl. Good ideas eventually migrate over here, and the community supports them.

I upvoted for this. Perl is kind of the "English" of the programming world, picking up whatever useful artifacts from other ideas it can without being concerned over language or design purity. Perl's design concept is to use whatever's best - i.e. be agnostic and be pragmatic.

This has it's good sides and bad sides (just like English). Perl can be both easy to learn the basics of, but very tricky in advanced usage, and it suffers from the "hard to maintain" problem. But it can be a nice dense language that maps well to a reasonably logical thinking process (it's probably by semi-intention since L.Wall is a Linguist).

Perl 5 is certainly showing its age though.


"Hard to maintain" is true of code written in any language. Software is generally hard to maintain.

Perl has had this stigma forever and the community has compensated in many ways; Perl Best Practices, 100s of Test:: modules, Moose, etc., so you actually have a pretty good chance of writing maintainable software. One feature I consider key to good OOP are "roles", and only Perl, Smalltalk, and Haskell really have those.

People like to repeat things they hear, but if you think about it, Perl is not at all unmaintainable.


One can certainly hack out some very maintainable Perl code. I agree 100%. I just started doing some work on an old 10kloc Perl app I wrote 3 years ago and because I planned it out in a sensible manner, have been able to jump in without too much trouble.

But I've also choked when trying to work on trivial scripts I tossed together in a rush.

I've always found Python to naturally follow more maintainable code patterns -- and it seems really designed with a philosophy towards that goal. But I've always liked Perl better since the code flows more like how I think (at least in a write once kind of way).


This is quite seriously the best advocacy of Perl I have seen in a long, long time.


What do you think of Perl 6 so far?


Youporn is a top 50 site and was started in 2006.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: