<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Hercynium</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/hercynium/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/hercynium/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/hercynium//281</id>
    <updated>2013-01-15T18:45:01Z</updated>
    <subtitle>Vaguely Perl-Related Brain Droppings</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>The JVM *could* host a Perl implementation - and do it well!</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/hercynium/2013/01/the-jvm-could-host-a-perl-implementation---and-do-it-well.html" />
    <id>tag:blogs.perl.org,2013:/users/hercynium//281.4202</id>

    <published>2013-01-15T18:12:38Z</published>
    <updated>2013-01-15T18:45:01Z</updated>

    <summary>A response to chromatic&apos;s recent post on modernperlbooks.org, where I argue that the JVM is *quite* suitable for a language as dynamic as Perl, at least for everything but short-running scripts. Clojure is (IMO) proof-positive.</summary>
    <author>
        <name>Hercynium</name>
        <uri>http://perl.scaffidi.net</uri>
    </author>
    
    <category term="clojure" label="clojure" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="moe" label="moe" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl5" label="perl5" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/hercynium/">
        <![CDATA[<p><i>I started writing this as a response to <a href="http://j.mp/SEq7wc">chromatic's post</a> at his Modern Perl blog. Short version: I think that the VM will be no problem for <a href="http://j.mp/X2Cm0E">Moe</a>, Stevan Little's new project to bring a Perl (or dialect) to the JVM.</i></p>

<p>Overall, I think chromatic's points are very good, and I agree with many of them, especially in the "What Moe Could Produce" section.</p>

<p>But I disagree with one point, in that the JVM has (at least to me) proven that it is an excellent platform for hosting dynamic languages. Well, at least <i>one</i> dynamic language.<br />
</p>]]>
        <![CDATA[<p><br />
I spent a year porting Perl 5 code to Clojure. The first phase of the port was (more or less) a bug-for-bug reimplementation of the architecture of our product, including porting a *lot* of the functionality of Catalyst, and some of Moose.</p>

<p>Doing it this way allowed for some good comparisons to be made between the languages. For example, the Clojure code, overall, wasn't really any more or less readable than it was in Perl, nor was it much easier or harder to "grok". Changing the language and VM while keeping the same overall design didn't make the product any more scalable, and not a *whole* lot more robust, but one thing stood out for me - it was <i>faster</i>.</p>

<p><b>a lot faster</b></p>

<p>And yet, IMO, we didn't lose much at all in the way of flexibility, as the Clojure language, despite being Yet Another Lisp Dialect(tm), is actually <i>quite</i> pleasant to work in. Syntax aside, I felt it had a lot in common with Perl, and found that just about any technique or trick I might want in Perl 5 was either available to me or was unnecessary due to the availability of alternatives. Built-in anonymous lists, arrays, and hashes with a concise syntax to use and define them? Check. (in fact, it's '() [] and {}, respectively, with the contents inside the delimiters). Mutability of atoms, data-structures, and objects? Not by default, but you can make them. Even the "object system" has a lot in common with Perl 5. Introspection of *everything*? Symbol-table hacking galore? All that and much more. A very nice toolchain that automates nearly all the drudgery and headaches? Check. Full compatibility and integration with code written in other languages running on the JVM? Wonderfully done. We even added a macro so that regexes felt more like a built-in feature rather than a library.</p>

<p>Only thing missing is an analogue to the CPAN. And I heard that's being worked on...</p>

<p>Compared to Perl, I might complain that Clojure is completely unsuitable for command-line programs. Of course, that's not what Clojure is currently used for (I love <a href="http://leiningen.org">leiningen</a> as a build and dependency tool. I *hate* waiting for it to start up...)</p>

<p><b><font size="+1">Bottom line, I believe that the JVM can handle just about any dynamic language or language construct you throw at it, it's just not suitable for "scripts".</font></b></p>

<p>(unless you keep a persistent JVM instance or use something like <a href="https://github.com/flatland/drip">drip</a> and even then, that seems to me to be a lot of overhead just for scripting)</p>

<p>Anyhow, while I don't agree that Perl is "dead", both Stevan and chromatic make excellent points in their recent talks and posts, and I heartily support any effort that might produce a usable variant of Perl 5 on another VM. I especially think that targeting the JVM is an excellent choice. I've seen a little Scala code, and I think this may just be what I need to start really learning it. That and the fact that some people at my current $work are beginning to use it. I think Moe is feasible. Whether or not it has a shot will depend partially on the community that forms around it, partially on how good and easy whatever "CPAN" might arise is, and partially on how long it takes to get to "production-ready" status.</p>

<p>But that's a topic for another post, and all I have are opinions with nothing real to back them up, which are the kind I tend to keep to myself.</p>

<p><br />
As an aside, a notable issue with Clojure is the density and near-uselessness of the the stack-traces. Nearly as dense as C++ compiler errors with a dozen nested templates and almost as useless as Python stack traces in a Twisted application. Clojure's exception dumps make Moose's dumps look sane. I suspect this is because of Clojure's dynamic nature combined with the backflips needed to make it all work on the JVM, but regardless, it still works wonderfully.</p>]]>
    </content>
</entry>

</feed>
