Perl's Extreme Makeover
PurdueGraphicsMan writes "There's an article over at Yahoo! about the upcoming version of Perl (version 6) and some of the new features (RFC list). From the article: "Although Perl 5's expressions are the most sophisticated available and aspired to by other programming languages, "no one pretends for a moment that they're anything but hideously ugly," said Damian Conway, a core Perl developer and associate professor at Monash University in Australia.""
.. is why I prefer python over perl. The resulting code is soo much cleaner.
I suppose it has to do with the old debate of losely or strict typed langauges. Perl is highly modular but I would hate to work in a team of 10 or more perl developers all writing in their own styles and methods. Shudder.
Yahoo decided to support php rather then perl in their next generation yahoo services specificially because of "There is more then one way to do it".
Of course its all being outsourced to India now where they can just hire more developers if complex problems arrise
http://saveie6.com/
Perl5 has lasted us 10 years. If they were to do one major change a month, messing with backwards compatability in your scripts would become a major pain. This way its atleast one major headache rather than a decade long depression.
Pain lasts, kid. Its how you know you're alive. Sometimes I think this growing up thing is just pain management-TheMaxx
Why do we use Perl every day? Because Perl scales to solve both small and large problems. Unlike languages like C, C++, and Java, Perl allows us to write small, trivial programs quickly and easily, without sacrificing the ability to build large applications and systems. The skills and tools we use on large projects are also available when we write small programs.
I'm not a Perl hacker by any means, but after the possibilities are endless, and I don't think Perl will ever die.
CB
free ipod and free gmail!
As a Perl 5 programmer, I don't think Perl 6 will be all that good.
Not everyone will switch immediately, and not everyone will need/want to switch anyway.
I say go on and learn Perl 5, you won't regret it...
...provides almost all of Perls power, with none of the ugliness... [emphasis mine]
...or the online documentation, the unit testing facilities, the CPAN repositories, the portablility, or the developer community.
Sorry, but you had missed some things that Ruby has none of compared to Perl.
No.
Why does everyone say perl syntax is so damned ugly? Appearantly, they haven't seen C code written by someone with a "I'm a C God - Complex". I agree with some of the other posts here, it's only ugly if you have never used the language before. Write yourself a script or two and you quickly catch on.
In fact, it's just like ANY other language (programming or spoken at that), it looks foriegn (go figure) until you put a little effort into it and figure it out.
JM2C
- Mike
It's all going to depend on how much they change the syntax, which Yahoo!!!!!111! doesn't seem to be providing us with right now. (I'm sure if I were on a perl list I'd hear more about it.)
Personally what I'd recommend (as a full-time perl programmer) is to learn 5 anyway. It'll take two or three years before the next edition of the Llama (O'Reilly, _Learning_Perl_, look it up your own darn self on Amazon if you must) is out, and in the meantime you can get out of the baby-talk phase this way. Learn regular expressions thoroughly, absolutely thoroughly, backwards and forwards, even if you won't need to use most of the complex stuff -- you'll wind up using it sooner or later, and if you know if cold, then you've got better odds of remembering something obscure when you need it. [Caveat: apparently regexes are a big part of the language changes. So learn the Perl 5 regex engine as thoroughly as you can, and then compare and contrast with this rundown on the new stuff.]
Obviously core language features aren't likely to go anywhere, and you won't be wasting your time learning them. And you'd be amazed at what even a couple of months will do for your language maturity.
Start now. No sense putting it off.
Freedom isn't free; its price is the well-being of others.
Learn Perl right now because it will make your life better (assuming your life can be made better by a powerful scripting language/glue-layer from heck). Perl 6 is still far off on the horizon and Perl 5 knowledge will largely transfer to Perl 6.
I think that setting out to learn Perl for its own sake will generally not work. One of Perl's strengths is that it grows with you and your needs. Learn a little bit of Perl and you still solve some very useful problems. For example, many people first learned Perl to do some quick-and-dirty projects like one-off data file reformatting, internal report generation, or simple CGI scripting. Learn more as you need it. It's taken me years to get to the point where I might call myself a skilled Perl hacker. But every step along the way was pleasant. I never felt I was learning stuff for the sake of learning stuff; I was always learning something that made my goals right now easier to achieve.
Perl is about serving you, not you serving it.
Search 2010 Gen Con events
Larry, you need to get an alpha out in 2004 (even if all of the Apocalypses have not been published) or I think you are going to see people lose interest in perl 6. In the time between Apocalypse 1 and today, the mono team have basically cranked out an entire development environment of excellent quality.
Signed, an eight year perl programmer and major fan.
I can't believe that nobody's challenged this statement yet. Somehow I don't think that Lisp or Prolog aspire to Perl 5's expressions...
I was very excited about Perl 6 when Larry started releasing apocalypses. I really hate to say it, because I'm as big a fan of Perl as anyone... but at the current rate, we're not going to see a full specification (much less implementation) of Perl 6 anytime in the next 15 years. There have been 6 apocalypses in the past 3 years, and there are supposed to be about 30 in all.
:-) It's just not useful to anyone if it doesn't exist.
Perl has a long history of being practical and useful rather than theoretically perfect, and it makes me sad to see the trend reversing with Perl 6. It seems like Larry is trying to make Perl 6 everything to everyone. That's one sure way to fail (although TMTOWTDI, of course
Use Ctrl-C instead of ESC in Vim!
Definitely true. There is only one reason why Perl code is so frequently ugly:
Perl exposes the mind of the programmer more directly than any other programming language.
If you are more interested in quick hacks and dirty tricks than writing clean and manageable code, your perl will reflect that. If you are interested in impressing people by compressing seventeen operations into a single line of code, your perl will be an ugly, ugly thing.
However, if your intention is to write clear, maintainable, understandable code, then this is what you will write. It isn't hard -- in fact I believe that Perl's flexibility makes this a much easier task than just about any other language. Here are a few of my favourite rules for Perl programmers:
1) Just because you can, doesn't mean you should.
2) One line of code means one operation or idea. MAAAAYBE 2. See point #1.
3) If there is a cute, short, hackerish way to do something, and a longer, more boring, more explicit way to do the same thing, ALWAYS pick the boring way. Anyone who looks at your code in six months will be very pleased (instead of ready to kill you). Since Perl is so flexible, this is always possible. As for performance, well, in my experience the slick, hackerish ways of doing things often slow things down more than the explicit-using-more-lines way of doing things.
In any field, find the strangest thing and then explore it. -John Archibald Wheeler
If the programmer is disciplined and well organized, the code will be disciplined and well organized. If the programmer doesn't value readability, then the code will not be readable. People like to take pot-shots at Perl, but they should really be aimed at Perl programmers.
You guys...
Perl, if written right, can be a VERY good looking, and VERY easy to understand. All of you that say that it is hard to read are:
a) reading code that wasn't meant to be cute, but was meant to work where nothing else was as practical,
b) reading code that was written by someone that didn't know perl, or are
c) reading code written by someone that knows perl a LOT better than you.
In my personal experience, people that gripe about Perl are the ones that use it least. The people I know that use Perl quickly learned to love it.
Over twenty years I've programmed with at least as many languages.
So, I won't claim to know any language intimately.
But... I have programed in Perl for the last five years. Why is simple.
Because Perl let's me leverage the last 20 years of programming. If they see a good idea in another language... they put it in Perl.
You will see a lot of people complain because of how Perl code looks. The simple fact is that you can write clean looking code... or ugly code. Perl doesn't care. It is your code... do it the way you want.
Perl's strength is that it let's a programmer program the way they want to. That is also it's weakness.
My advice would be to spend a few more years with a few other languages. You won't appreciate Perl until you know how elegantly it lets you solve some problems that you have used other tools for.
If you are looking for "structure" and don't have the discipline to enforce it yourself... then stay away from Perl.
--Phillip
Can you say BIRTH TAX
Ninety nine percent
of the Perl Haikus will not
Apply anymore
The procedural stuff will remain the same. The OOD is getting a decent syntax and will no longer be a bolted on hack.
Perl started life as shell script with a built in sed and awk. It has since grown.
The regex stuff in perl 5 is just like sed and grep as far as new user is concerned. The simple regex stuff won't change with perl 6 and the concepts are the same. Perl 6 is going to change the shortcut symbols for the regex expressions.
Perl5 have has a =~ operator that is going to get replaced with a ~~ operator. The ~~ will work in many places where the perl5 =~ won't work. This is part of the push to make perl more orthogonal.
Perl6 will also deal with unicode out of the box with no real issues. Perl5's unicode was a bit of a hackjob as the coders learned along the way. Not that unicode is understood, it will be done right. Some of perl6 seems to be intended to get rid of bad practices based on the concept that "all the world is ascii". For example in Perl upto 6 you can say [a-zA-Z] to mean letters but that won't pickup up the latin-8 char set. Perl6is going to make it harder to say that and easy to say "Letters in the current language".
The list processing may get to the point that it is on the same level as lisp.
Perl6 appears to about about 18 months away so if your going to wait, its a long wait.
Damian Conway gave a great talk on this just a few days ago. If you get a chance to hear him talk, take it.
I'm not sure how "Healthy, readable code with sensible naming conventions and a clear structure" explains to you at a later date why you coded as you did. If you had to write something that looks out of place to deal with some legacy code you inherited, I'm sure you'd psychically pick that up just by glancing at the code. Or perhaps you go round naming vars something like $quirky_flag_to_pick_up_strange_situation_caused_b y_bad_code_in_package_X?
And what if someone less experienced than yourself has to maintain your code at a later date? Something that may seem obvious to you may be off of their radar.
If you never have to ask why and no one less intelligent than you ever looks at your code you either are very very lucky, very stupid or unemployed.
.02
cLive ;-)
-- Trinity in high heels carrying a whip: The donimatrix - there is no spoonerism
I agree that comments are like crutches, as I personally hate having to break my thought process to write a comment.
On the other hand, even the most readable code takes time to look at and decypher. It is far easier to read that one line comment that you wrote last month and immediately recall what you were doing.
Comments may be crutches, but I will always laugh at the idiot with the compound fracture in their femur who refuses to use a crutch to get around because he is too proud.
I'd say Comments are more like Grandpa...
He can tell you some really interesting stories about times you can't remember, but he slows you down immensely so he usually gets left at the old folks home while you try to get where ever you're trying to go.
"Don't blame me, I voted for Kodos!"
s/(.*?\s+)\(.*?\)/$1/g
//gx;
This is trying to match something like adsfdfsdfs()ASDfasd#@$!@afd (adsfad@#$@!)
and replace it with
asdfa asdfa asdf adsfdfsdfs()ASDfasd#@$!@afd
or basically, get rid of things in parenthises that are after at least one white space.
so,
s/\s+\(.*?\)//g would work...
but still a lot of slashes
so try this
my $stuffInParen = qr| \(.*?\) |;
s/\s+ $stuffInParen
or even
my $stuffInParen = qr| \(.*?\) |;
my $whiteSpace = qr| \s+ |;
s/$whiteSpace $stuffInParen//gx;
now, you can look at the code and have a pretty good idea what it's doing. (even without comments). we're switching stuffInParens that follow whitespace with nothing. just because Perl gives you the flexability to write ugly code doesn't mean you should. if you are writing perl code and it looks ugly, you're doing it wrong. you should find another way to do it... with great power comes great responsability.
see http://www.perl.com/lpt/a/2003/06/06/regexps.html for more info.
This isn't the sig you are looking for... Carry on...