Hacker News new | past | comments | ask | show | jobs | submit login
Operators and Meta-operators in Perl 6 (perl6advent.wordpress.com)
44 points by lelf on Dec 22, 2013 | hide | past | favorite | 26 comments




Perl 6 is really an interesting language. There are a lot of tools like this that give you the power to say a lot with a very small number of characters.

(The flip side, of course, is that you can easily make incomprehensible code—I wouldn't want to read code using any but the most natural user-defined operators—but if you set that aside, Perl 6 has a ton of cool ideas.)


The meta-operators remind me of adverbs in J


So what's the situation of Perl 6? Is it production ready? Any demonstration code?


(Assuming you're asking from a really long distance out) Well, there's two current implementations of it (with Rakudo being actively developed): http://www.perl6.org/compilers/features

As for example code, there's some on http://rosettacode.org/wiki/Perl_6 in the bottom section. With all that said, is it production ready? I don't know. I've heard people joke that Rakudo crashes every couple hundred lines of code it executes. Though the parrot developers have said that parrot itself is extremely stable, and they've had decently sized programs running for some time on it. That, and Rakudo is currently working on two new backends besides parrot: JVM and a new vm called MoarVM.


While Rakudo certainly crashes more than anyone wants, it doesn't crash anywhere near as often as you suggest. It's a good thing, as it is implemented in itself; you couldn't get to line one of your script without crashing if it crashed every couple of hundred lines.

Actually, I don't know when the last time I got a random crash in Rakudo was; it may have been years ago. Getting a crash because you ran out of memory, on the other hand, definitely can happen in bigger programs.


No. There have been various test and development implementations over the years but regardless of bugs they're all so slow as to be of questionable utility for any real work. It remains safe to ignore Perl 6 for the time being.


I'm genuinely curious - why are programmers still using Perl instead of Python?


Some people actually find Perl fits the way they think better than Python does. They may find the culture a better fit, or they're better able to find existing solutions, or they simply prefer the concept of "There's more than one way to do it" over "There should be one – and preferably only one – obvious way to do it." Finally some are better paid to write Perl than they are to write Python.

The reality is any/some/all of the reasons above apply to any combination languages in your question. Might as well ask "Why are programmers still using COBOL rather than Erlang?" Because.


CPAN, Unicode, testing, and long term maintainability of the code (Seriously; I can tell the difference between good Perl and bad Perl at a skim. Good Python and bad Python tend to look the same. Truly awful Python is immediately obvious, but that's not an interesting case to consider.)


Why would I use python if I'm well versed in perl?


I work in a group that manages a large amount of Solaris, AIX, and Linux servers, of varying versions.

When I'm writing scripts that can be run on any given system, there are very few things I can use that I know will work. One of those is Perl (5.8.8) and the other is Korn Shell (ksh).


Feeling of being "in the moment" & having maximal individual control (Perl 5) versus long-haul maintainability + potential to be widely collaborative, if perhaps at a slight loss in expressiveness (Python).

Perl 6 being an entirely different beast from either of these two languages, of course.


Really? Python has magic everywhere and requires methods to take self as an argument. Indentation instead of brackets. It's one big hack. Perl is a much nicer language. The real question is, why would I ever use Python over Perl?


What in Python is "magical"? The fact that methods take a "self" argument is a result of it not being magical.


Methods taking "self" as an argument is a dirty hack, ain't no magic there. The language is just pretty ugly. It's got the whole whitespace thing going on, which is forced, and some might think it gives a good aesthetic but that is dust in the wind in terms of help for Python's ease on the eyes. The whole standard namespacing and mix of oop/procedural global functions is just..schizophrenic, the capitalization scheme is dastardly. I haven't seen many languages that look more _basic_ than python. It's a frankenstein of Perl/Ruby and Basic. Forced verbosity is egh.

Here's your magic methods and properties: http://www.rafekettler.com/magicmethods.html

Those magic methods kind of remind me of clever hacks while coding in PHP.


Magic methods have always been my favourite part of python, they're the developers way of ensuring we can do anything that they can do, if there isn't a magic method for it, it's not possible. We can create our own version of anything in the standard library.

Self is one of those things, if you wanted to you could easily add another instance variable, just implement getattr and have it return a partial function. Although I will admit it is one area which does cause more than its fair share of errors, but I prefer it to Ruby's methodology.


Are the magic methods API frozen?


Most "high-level language" programmers disagree with you, including myself.


Speak for yourself. I know about every programming language, high, low, down to assembly. Your ad-homonem attack is so silly considering that you aren't talking to a scripter or web guy. I'm a generalist and Python is one of my least favorites. It has hardly any redeeming qualities other than Django, NumPy library and CPython's speed.


What the heck did you just freaking say about me, you little weenie? I’ll have you know I graduated top of my class in the MIT, and I’ve been involved in numerous secret research projects on exokernels, and I have over 300 confirmed reward checks from Knuth. I am trained in gorilla cryptography and I’m the top Cyber Command hacker in the entire US armed forces.


A canonical synopsis of the typical HN language "debate."



Python ... requires methods to take self as an argument.

Unlike... Perl?


Yeah, a silly criticism of Python versus Perl. Perl borrowed Python's mediocre object system and made the syntax a little worse. Fortunately Moose made both the object system and the syntax a lot better (but Perl 5 was out for a decade before Moose arrived).


Why not? I can't think of a serious reason to favor one over the other between any of Ruby, Perl, and Python.

A lot of people find Python's scope rules annoying.

I've heard Perl has the best unicode support.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: