Hacker News new | ask | show | jobs
by s_kilk 3856 days ago
A few upsides I perceive:

- optional, well-integrated gradual typing system.

- perl6 is the first mainstream(ish) dynamic language to not suffer from a GIL of some kind. You can do real concurrency and parallelism in perl6.

- perl6 is both equally as powerful, and much more simple than previous versions of perl.

- a bunch of good ideas stolen from other languages. go-routines are in there, pattern-matching, gradual typing, classes, etc. Plus, functional programming is a first-class-citizen of perl6. There's so much good stuff in there.

- overall, I think perl6 has the potential to become a very powerful (and yet robust and well engineered) hacker language, where you will not be constrained by implementation details of the VM the language runs on (I'm looking at you, GIL).

I'd also recommend reading Curtis Poe's answer to a similar question:

https://www.quora.com/Perl-programming-language-1/Should-I-b...

3 comments

> - perl6 is the first mainstream(ish) dynamic language to not suffer from a GIL of some kind. You can do real concurrency and parallelism in perl6.

I went digging to try and understand what this meant, and seems it's referring to syntactic support for promises, which in at least the Rakudo implementation amount to a wrapper around a forking multiprocessing system (like the Python multiprocessing module).

From my perspective this concurrency isn't any more "real" than equivalents available in existing languages, but maybe I'm looking at the wrong thing - you mention global interpreter locks, and usually they refer to threading.

Does some implementation of perl6 have non-GIL threading?

edit: from <https://perl6advent.wordpress.com/2012/12/11/day-11-parrot-t...:

> The solution for these problems implemented in hybrid threads is to sidestep them altogether by disallowing write access to shared variables. The programmer (or in most cases the compiler) is obliged to declare a list of all shared variables before a newly created task is started. The interpreter would then create proxy objects for these variables which the task can use to access the data. These proxies contain references to the original objects. They use these references to forward all reading vtable functions to the originals. Write access on the other hand would lead to a runtime error.

> In other words, all data is owned by the thread creating it and only the owner may write to it. Other threads have only read access.

> For threads to be able to communicate with their creators and other threads, they still need to write to shared variables. This is where green threads come into play. Since green threads are light weight, it is feasible for a thread to create a task just for updating a variable. This task is scheduled on the interpreter owning this variable. To reduce latency, the task is flagged to run immediately. The data-owning interpreter will preempt the currently running task and process the new write task. Put another way, the data-owning interpreter is told what to write to its variables, so other threads don’t have to.

Hi. That blog post refers to parrot vm threads, which is not what the current MoarVM or JVM implementations use. Both these VMs support 'real' OS level threads without any global locking (beyond what is needed for GC). In case of MoarVM, that support is built on libuv. And there is a very interesting high-level interface built on these fundamentals.
Libuv is what node.js is built on, and I've seen some benchmarks of really impressive performance w/r/t MoarVM.[1]. https://github.com/perl6/mu/blob/master/examples/concurrency... Here is how "real" (i.e., not fake, spawn processing) concurrency is done in Perl 6.

Rakudo's had more testing since it's been around forever but MoarVM is where my hopes lie. Here's hoping user adoption isn't fractured that badly like D's Tango vs Phobos debacle (which only now it's recovering from, I'd argue largely due to Andrei Alexandrescu's charismatic persona, haha.) Perl 6 is a really interesting language and I'd encourage you all to play with it, but it's an entirely different beast than Perl 5. They should have just renamed it entirely.

[1] http://www.moarvm.org/features.html

"Rakudo's had more testing since it's been around forever but MoarVM is where my hopes lie" is a little confusing to me. Rakudo and MoarVM are not the same type of thing. Rakudo is a Perl 6 compiler with multiple backends. I don't follow this very carefully, but I think it used to have a Parrot backend, and currently has two maintained backends: one for the JVM and one for MoarVM.

Is that wrong? If not, did you mean "Rakudo on Parrot" or "Rakudo on the JVM" when you wrote just "Rakudo"?

Rakudo is an implementation of Perl 6 built on top of NQP (Not-Quite-Perl. a pseudo lang that implements the easier parts of Perl 6 that can be targeted and optimized by VMs), and MoarVM is a C-based NQP interpreter. There is also an NQP back-end for the JVM, which is now Rakudo runs on the JVM. Think of NQP as an intermediate language (kind of like java bytecode but much higher level).

It's like this: Rakudo -> NQP -> MoarVM

or like this: Rakudo -> NQP -> NQP-JVM implementation -> JVM

Want to get Perl 6 running on the .Net CLR? Implement an NQP interpreter (which is supposed to be fairly easy) and you're 99% done (at least that's my understanding).

Strictly speaking, MoarVM is not an NQP interpreter - it runs MoarVM bytecode.

Sure, MoarVM is by design semantically close to NQP, but if you look at

    $ nqp-m --stagestats -e ''
    Stage start      :   0.000
    Stage parse      :   0.003
    Stage ast        :   0.000
    Stage optimize   :   0.000
    Stage mast       :   0.005
    Stage mbc        :   0.000
    Stage moar       :   0.000
you get mostly the same steps as on the JVM

    $ nqp-j --stagestats -e ''
    Stage start      :   0.000
    Stage classname  :   0.045
    Stage parse      :   0.067
    Stage ast        :   0.000
    Stage optimize   :   0.009
    Stage jast       :   0.145
    Stage classfile  :   0.010
    Stage jar        :   0.000
    Stage jvm        :   0.003
except that MoarVM bytecode files do not get bundled into JARs and there's no need to do the extra processing that happens in the 'classname' stage.
GIL stands for the Global Interpreter Lock, which python has been criticized for a lot. I don't know whether perl5 or other languages have one, really.
> GIL stands for the Global Interpreter Lock, which python has been criticized for a lot.

It's pretty clear the GP knows what a GIL is, he's wondering if Perl 6 is truly GIL-free, or if it "just" abstracts out the GIL using language primitives for a forking multiprocess system (already, that's a nice step, but it's not "GIL-free").

I'd like to know the same thing.

(Side remark: it seems the comment has been edited, expanding it a lot. It was not clear to me initially. And anyway, it is good to have acronyms expanded for other readers.)
To be fair the GIL is only an issue if you are doing CPU bound thread-based parallelism in Python. There are way to do real parallelism in Python, for example via several processes.
Parrot VM hasn't been supported for quite some time. I'm pretty sure that it's been mostly abandoned.

The current VMs are MoarVM, JVM, and some are working on a JavaScript backend.

Has the Parrot VM project been abandoned, or just Perl 6 support for it?
A little of each, and technically neither.

Parrot isn't wholly abandoned, but Reini Urban is the only person still hacking on it. On the other hand, he is the person most likely to bring Parrot back around to being a good backend for Perl 6, so it has that going for it.

Currently no implementation of Perl 6 targets Parrot. Rakudo used to (indeed, was born on Parrot), but suspended support for Parrot in connection with the push to get Rakudo-on-MoarVM up to 6.0.0 quality by Christmas. The Rakudo team were careful not to say they were writing Parrot off, but they also gave no particular criteria for when they would unsuspend it.

(I in no way speak for Rakudo or anyone else, but I suspect the implicit criteria for unsuspension are three: Parrot must demonstrate, in code, that being a good backend for Perl 6 is a higher priority than being a good backend for entirely hypothetical other clients; it must undertake, survive, and complete a major decrufting if not re-architecting; and of course, it must be more interesting, for enough people, to target Parrot than to hack Perl 6 on Moar, JVM, JS, Mono, the perl5 VM, p2, WebAssembly, native code, the Factor VM, or whatever else.)

There are also those who view MoarVM as the new Parrot -- Parrot as it would have been if its implementation hadn't started until it was clear what Perl 6 would really need under it. (Aaaaaand without the technical or political fallout of "let's make a VM for ALL the dynamic languages!")

Hm. Your opinions don't match my recollections.

Aaaaaand without the technical or political fallout of "let's make a VM for ALL the dynamic languages!"

I remember Larry being really keen on that idea. The quote went something like "If everyone complains that CPAN gives Perl an unfair advantage, let's give everyone access to CPAN."

http://www.perl.com/pub/2003/07/16/soto2003.html

I didn't say Larry wasn't keen on a multi-language VM in 2003.[1] I said that Parrot's pursuit of that goal contributed to (an intricately braided series of) technical and political conflicts with Rakudo, culminating in a breakdown of relations between them across 2013-2015.

Why would I think that? I am aware of your recollections. I have read everything you blogged about the collapse of Parrot.

I have also read everything several other people wrote about the inception of MoarVM and the suspension of Parrot support, including key figures from both sides and several third-party observers. I have read the IRC logs of Parrot design meetings, including negotiations with the Rakudo leads, for the period leading up to the rupture. I have read key announcements by Parrot and Rakudo lead designers from earlier than this, wherein I think I see the seeds of the breakdown sown.

I made a detailed study of all this last spring, when I learned about the suspension. I have also been checking in intermittently on Parrot since 2002, and on every Perl 6 implementation I could find since the post-Pugs revival. And since last spring I have been kept aware of your position in particular through sundry comments here and on Reddit; you are a reliable presence whenever someone mentions Perl 6 or Rakudo without condemning it.

I can't speak to specific differences between my opinions and your recollections, since you did not see fit to say what those were. But I am hardly uninformed and I know of no error in what I said (viz., the actual words that I typed).

[1] If I wanted a document to make my point for me, I could hardly do better than the 2003 State of the Onion. Here's where Larry's head was in 2003: Yes, he thought a multi-language VM was just what Perl needed. He also thought that the Perl 6 design was basically done. He clearly didn't think there would be too much difference in kind between Parrot and the p5p runtime, as shown by his speculating that Ponie could be ready to support 5.10 and could entirely replace p5p by 5.12. He had not yet written the Apocalypse on the object system; its release in 2004 is really when it became clear how deep and structural the changes from 5 to 6 would be, and consequently it's also when it really became clear what a VM would need to provide to be good for Perl 6. Heck, in 2003 Larry thought "slow progress" meant a couple of major redesign documents a year, and he thought slow progress was just coming to an end. About the only thing that address was right about is that Larry didn't know very much. (Well, that and the switch statement.) If I'm saying reality disproved early conceptions about the realization of Perl 6, SotO 2003 is Exhibit A.

> - perl6 is the first mainstream(ish) dynamic language to not suffer from a GIL of some kind. You can do real concurrency and parallelism in perl6.

Admittedly, not everyone would define it as mainstream... but Tcl doesn't have a GIL and has had threading for a good, long time.

> - perl6 is the first mainstream(ish) dynamic language to not suffer from a GIL of some kind.

GILs are features of implementations, not languages; Ruby has implementations (most notably JRuby) without a GIL. And Clojure doesn't have a GIL, and seems to be approaching mainstream.

And Perl 6 isn't mainstream yet (it hopes to be, but then so do most languages.) And there's plenty of not-currently-mainstream dynamic languages without GILs in their primary implementations; many in the Lisp/Scheme family.