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

No previous Perl programming-experience. I've been consciously aware of Perl since at least 1998 and even poked at the source code of some scripts here and there, but didn't bother to really learn anything about it until recently.

A brief explanation; perhaps someone here will be inspired or is thinking along similar lines:

I've been using an "object system" for JavaScript named Joose: http://joose.it/

Joose is amazing and is, roughly speaking, a port of the Moose object system for Perl to JavaScript. (Moose is mentioned in various comments below and many times in the "Modern Perl" book.)

The principal author/maintainer of Joose v3 (Nickolay Platonov) has developed an ecosystem of tools on top of Joose3 and for Joose-oriented distributions (github.com/SamuraiJack). Much of their design is inspired by popular distributions in Perl's CPAN (Nickolay has a strong background in Perl, obviously). And some of them are still tied into Perl libraries, not simply ports to JavaScript.

As node.js and its package manager NPM have evolved rapidly in the last 12 months, some of the Joose stuff is lagging behind and in need of an overhaul, e.g. Nickolay's "JSAN plugin" for Dist::Zilla.

I've been wanting to help, but it's difficult to hack on Perl code if you don't even know the syntax. Well, that's where chromatic's book has come to the rescue! To be honest, it's been a real eye-opener and, as I suggested earlier, I think this Perl learning-experience is actually going to be a big boon for me in the near term and into the future. It's already allowing me to view Joose and related libraries through new eyes.




Anecdote which amuses me: I find JavaScript tolerable thanks to Joose and other ideas borrowed from Perl.


Not sure if you'd have any thoughts on this matter...

The JavaScript community as a whole (seen especially in the direction of node.js + NPM) is moving away from global namespaces and toward the "module pattern" and dependency injection (note: I had no idea what those terms really meant 6 months ago).

Presently, Joose3 goes against that grain. For example, if in a node.js script you:

   require('joose')
   if (Joose) { console.log(true) } // prints true!
Basically, the global namespace gets auto-populated with "Joose" and a chain of namespaces below that. This is very Perl/Moose-like, of course.

When you define classes, roles, etc. you get similar behavior:

   Joose.Class('MyClass', {...})
   if (MyClass) { console.log('effectively stubbed in a global namespace!') }
   // does log that text to console, as Joose.Class() behaves that way
And in fact, Joose3 encourages you to embrace that behavior (with `use:` builders and lots of discrete files) to arrive at a network of cross-referenced namespaces which altogether form a library, and API usually.

To go with the flow, and especially to take advantage of emerging module specs like AMD (commonjs thing), a redesigned Joose (i.e. Joose4) needs to eschew global namespaces entirely:

   var myJuice = require('joose')
   ...
   // There should be no tie to a "Joose" namespace as such
But how to do that, and elegantly?

Any wisdom from the Perl community in that regard? Maybe someone else has been trying to port Perl stuff to JavaScript/node.js and has found the perfect formalism for translating from global namespaces -> module pattern + dependency injection? Know any Moose wizards that would be willing to help explore this matter?


I haven't written a lot of Joose code, but I use anonymous classes and store their constructors as attributes of a lexically scoped object I inject where I need it, so as to avoid global pollution. So far it works nicely.




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

Search: