Perl Features of the Future - Part 1
Kevin writes "This story
highlights some of the features being included in Perl 6. "There will be substantial changes in the move from Perl 5 to Perl 6. We've been hamstrung for a while by the need to maintain backward compatibility all the way back to Perl 1. There are some things we want to remove, because they seemed like good ideas when they were introduced but they're more trouble than [they're worth] now."
Also there exist CPAN module Text::Balanced which does balanced expressions matching.
--
Ilya Martynov (http://martynov.org/)
One of the goals of Perl 6 is to make non-trivial projects possible. That's good. The way it's being done is bad. Perl was once a lightweight, extremely flexible language. Now it's become a huge ugly monster. People wanted OO, so a nasty hack was bolted on top to allow some semblance of it. Now this nasty hack is being expanded. Sure, the code's different, but the basic form is the same. Kludge upon kludge upon kludge; I'd much rather have a nice, clean, pure language (and not one with loads of irritating whitespace thank you very much).
The same goes for the syntax. All the switching between $, @ and % is really irritating (ask a newbie how to get at the length of the keys array of a hash inside a hash, for example), and the changes proposed for 6 are just making this worse -- it seems that Larry, in his infinite wisdom, wants to prefix every data type with a different hard-to-type character. Perl was only designed for the three data types, and adding more is a mess.
Perl 6 is a complete rewrite, but it keeps all the mess which has accumulated over the previous versions. This is not good. Sure, my const int $var = 27; may look neat (in the same way that, say, Pascal does), but $var isn't entirely constant, or entirely an integer, it's just a hack which makes it sort of behave like one. The whole thing is an exercise in pseudo-computer science masturbation with little real purpose except to please the managers who dislike the one thing that makes Perl special.
On a similar note is regexes. I'm an avid fan of regular expressions simply because a nondeterministic finite automata is far more flexible than linear code. However, Larry must have been smoking that cheap $2 crack when he wrote this . Does he want Perl 6 to be flex or something?
I won't be going on to use 6. It's a nice idea, but it's completely unnecessary. It won't make large projects any easier to manage (the language is still, at heart, an almighty hack -- an impressive one, but still a hack). It won't make OO any cleaner. It won't make development any faster. To put it bluntly, Perl scripts will still look less beautiful than our friend Mr Goatse. I'd prefer to use a language which has always been pure synthesis of science and engineering, not some half-baked imposter.
Perl 6 will be nice, but I'm guessing it will be the end of Perl. It can't do what it wants to do whilst still being based upon a nasty mess. There are now other options, which provide all of Perl's power and none of the mess. Sorry, but BSD^W Perl is dying. Larry is buggering it up the ass without lubricants, just like Shoeboy is doing to Larry's daughter.
Hey, it's perl. It's not like you can read it.
I'm so f**king tired of hearing how perl is hard to read.
ITS NOT HARD TO READ UNLESS YOU MAKE IT HARD TO READ!!! and this is true for ANY and EVERY language out there. I can read perl all day long without problems, as long as it wasn't meant to be hard to read, but if you put a C program in front of me it might as well be some made up language that doesn't work, i woudln't be able to tell the difference.
I've come to the conclusion that those of you that say perl is hard to read either a) don't have a single solitary clue about perl at all, b) are trying to stir people up, or c) are trying to convince everyone else that your favorite language is "better" for each and every circumstance, which isn't true of any language at all, not even perl.
Hey, its Slashdot. I'm voting for all three.
The whole idea of perl is that you can write quick scripts or real applications without learing a new language without having a deep understanding of programming.
The only problem is when people who write quick scripts decide to try and make real programs, and the result is unreadable spaghetti. The same thing used to happen when sysadmin "gurus" strung together unreadable combinations of shell, sed, and awk...
If you to do "serious" programming, "use strict;" is your friend. Or waste time with C or Java.
Conformity is the jailer of freedom and enemy of growth. -JFK
I agree.
I think every computer scientist worth thier pay should realize that language advocacy stinks. Every language has its niche--a reason for why some guy sat back and said, "I need to write a shortcut language to do this" or "wouldn't it be great if I could have a better correlation between the way I think/design and the language I write in" and it evolves from there. Perl was designed as a glue language heavily modeled after awk/sed and other unix tools and the concept of following natural language and "having more than one way to do/say it" so you need to have a good feel for the language pieces as you do when you become a master of english and understand different connotations and methods of stating something.
That being said, it is unfortunate that because there are large groups of people who either A) get religious about the language they choose or B) choose not to learn other languages to a point of knowing thier true niche we take every language and bloat it out and take it out of its scope. And in turn that makes it that much harder to grasp each new languages niche because you have to sort through a bunch of crap that trys to make every language the universal language.
Well, it's human nature I guess. Easy to point out as a problem but not easy to fix...but remember that the next time you are about to tell your coworker that they should "write that in _____" instead of answering thier question. Or, be careful when you complain that "____ is bloated or is too hard to understand" because you are just adding fuel to the fire my friend. It is better by far to state why you chose a certain language on a certain project than to be a universal advocate of "_____".
Advocacy is a clear mark of inexperience.
I need a TiVo for my car. Pause live traffic now.
Maybe I won't get invited to the PERL hacker parties any more, but I have to agree. PERL 5's hacks for object oriented programming have always seemed unnecessarily complicated and ugly, and I don't see things getting any better in PERL 6.
...)
I too looked at Python. Like you, I decided that basing your language's syntax on differing amounts of whitespace was a really, really bad idea, not because it's ugly, but because I have enough trouble keeping tab damage under control on a single platform.
So I'm looking at Ruby. In fact, the only thing stopping me ditching PERL for Ruby tomorrow is lack of time for re-learning, given all the other new stuff I'm learning right now (J2EE, Objective-C, Cocoa, OpenGL,
GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
Parse::RecDescent is available for the 5.x series (I think it's part of the core download for 5.8, and was optional for 5.6, but am not 100% sure about that), but it seems like it's going to become a more core component when 6 arrives. If you want to be able to do this stuff, look into it -- you don't have to wait for Perl6 to start using this. It's available now, and it's *great*. :)
DO NOT LEAVE IT IS NOT REAL
I meet none of a, b and c. Here's my opinion:
Python is easier to read than the equivalent Perl code, even if the latter well-indented. Now before you close your mozilla tab, or mark this as "Flamebait", please hear me out.
Yeah, I agree that bad code is bad code, regardless of the lang.
But compare these two equivalent statements of good code:
pythonNumber = 1
my $perlNumber = 1;
Do the "$", the "my" and the ";" look necessary, or extraneous and confusing? They are the latter to me.
What about $_ and @_ ? Those don't seem very sensible. Nor does "<>", the backtick "`" or several other common Perl paradigms such as the fact that it makes a big difference whether you have single quotes or double quotes around a string.
Yes, I agree that some of Perl's "hard-to-read" reputation is deserved, but not all of it.
Why do reasonable people think Perl is hard to read? Because it has lots of unneeded, non-alphanumeric characters and there are lots of conventions that don't make sense (e.g. '<>' meaning a line of standard input).
Joe
http://www.joegrossberg.com
If it's not hard to read, then why are the designers of perl 6 making a lot of efforts to make it a lot easier to read than perl 5?
Quoting Larry Wall from the Apocalypses:
- In fact, regular expression culture is a mess, and I share some of the blame for making it that way. Since my mother always told me to clean up my own messes, I suppose I'll have to do just that. [emphasis mine]
- But Perl has often been tagged as a language in which it's easy to write programs that are difficult to read, and it's no secret that regular expression syntax that has been the chief culprit. [emphasis mine]
- there's a lot of regex culture that needs breaking.
- [Read all of Apocalypse 5 to learn exactly why perl 5 sucks to read. Even the extended syntax ain't really the most readable syntax.]
- As a specific example, there are various ways things could improve if we muster the courage to break the ``weird'' relationship between @foo and $foo[].
... the botch that in Perl 5 requires us to distinguish $foo[] from $foo->[]
- I think length(@array) should be equivalent to @array.length(), so if there's a length method available, it should be called.
- Legacy Perl $pkg'var Should Die.
- odd looking constructions like: $foo->[1][2][3]
- We're definitely killing Perl 5's slice syntax
- Various special punctuation variables are gone in Perl 6
- Typeglobs are gone.
- I'd like to get rid of the gratuitously ugly \E as an end-of-scope marker.
- I've always thought qw() was kind of ugly, so I'd like to replace it with something prettier.
- Angle Brackets Should Not Be Used for File Globbing. Indeed, they won't be. In fact, angle brackets won't be used for input at all, I suspect.
- This allows us to simplify the special case in Perl 5 represented by the _ token, which was always rather difficult to explain.
- The basic underlying question is "What exactly do those curlies mean?" For Perl 5 and earlier, the answer to that question was, "Too many things". Or rather, too many things with inconsistent rules.
- curlies are so extremely overloaded in Perl 5
- The old use integer pragma was a hack.
There's more, but I got tired of skimming the Apocalypses.I agree. I was unduly influenced by Ada syntax here, and it was a mistake.
Just for a point of reference, I'm a perl programmer who doesn't fit your categories (a), (b), or (c), but still finds perl code hard to read fairly often.
With all that said, I'll close with one more quote from the Wall:
my $perlNumber = 1;
... "<>"
"my" makes it a local variable. It's only necessary if you want that.
"$" is used to denote a scalar variable. Technically, it is extraneous. (It's part of perl's shell heritage.) On the other hand, some programmers intentionally add several extraneous characters to every variable (hungarian notation), so it must be a taste thing.
";" is necessary in languages which don't consider whitespace to be significant. Some people consider significant white space to be annoying and/or dangerous.
What about $_ and @_ ?
"$_" and "@_" are pronouns. They usually disappear in the same way "self" does. (Actually, in perl6, "self" is spelled "$_".) Perl, imitating natural language, has more pronouns than most computer languages.
"<>" is an idiom. In natural languages, commonly used idioms tend to get shorter. "<>" is an idiom for "read the next line from the file(s) named on the command line, or from standard input if there are no files on the command line." How much code would it take you to write that in python?
Perl is refreshingly concise and expressive.