What you can write in Perl 6 today
perlgeek.de
perlgeek.de
... and we're getting tired. it is much easier to find ruby and python guys, and i always thought ... "python? that's for sissies." until we tried it. and fellow programmers, i still had energy at the end of the day. that was the most striking. perl tires you out. perl culture and community tires you out. what a difference python makes.
initially i missed some things, but you quickly begin to see the light, and in no way will go back.
my theory is that python/js/lisp are simple because the core ideas are few. ie, because the rest of the language is the logical implication of a relatively few simple ideas. lisp is the best at this. the fewer special forms, the fact that you write in the same data structures the compiler sees (less complication) which translates into less to remember. less to keep in mind (quickly, what is the difference between 'use' and 'require' and system("") or system(@) ... bleh) which leads to less energy needs to get your stuff done. on this energy scale, perl rates pretty high. not as high as c++ but high enough that i never want to use it again.
so go ahead reader, mod me down and throw your tantrum, and try python (or ruby, etc ...)
This is about syntax. Please do post the equivalent examples in any of those languages. I bet the perl 6 will be a lot shorter, which is the whole point.
Lisp and Python aren't as simple as you think they are, and Perl isn't as complicated, either.
i'm tired already.
say [+] 1...5; # sum
say [*] 1...5; # product
say [<] @list; # is @list strictly ordered ascendingly?
What the hell? With [*] they go for a reduction, but with [<] they go for a reduction over a zip of the list with its own tail. The behavior changes completely! How do you predict that? That's simply dumb. Extremely dumb. Things like this don't make the language complicated, they make it risky. It is risky to write Perl 6 programs. And we know programs don't get any thrill out of that.Edit: And apparently it even respects the associativity of the operator! There is nothing gained by making the language more complicated just to cut a few characters.
[+] 1...5 = 1+2+3+4+5
[*] 1...5 = 1*2*3*4*5
[**] 1...5 = 1**2**3**4**5
[<] 1...5 = 1<2<3<4<5
Note that this means, unlike the normal reduce, that it follows the operator's default precedence rules, and presumably the less-than operator works similarly to Python's in that it allows comparison chaining (i.e. 1 < 2 < 3 works as you'd expect) to make the result using reduce seem natural.That has nothing to do with the technical merits of the language, but perception is important - especially when you are trying to convince someone to use it for a project. Ruby is positioned as being "new and exciting" and the successor to Perl. If Perl 6 is going to be relevant it needs to get in that spot.
my $foo = $bar < 1 ?? 0 !! 1;
Every other language on the planet including perl uses ?: for the tertiary but perl6 just had to be different for no good reason other than to be different. No. No, No, No thank you. Consistency matters. The most important feature in any programming language is clarity. Producing Pascal's Triangle using less than 5 characters of source code is not something programming language designers should be aspiring to. Python is looking better every day.The interesting question is whether Perl 6 can slough off syntactic baggage from C and Perl 5 for the purpose of clarity and attract more new programmers. I believe the changes from regular expressions to grammars demonstrate the viability of this concept.
Internal consistency of Perl 6 is more important -- even to novices learning the language -- than consistency with other languages, even Perl 5. Many of the linguistic and syntactic quirks of Perl 5 came from other languages. Not all -- but many.
Including Python? ;-)