Perl's Extreme Makeover 408
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.""
Re:Perl: The Beginning (Score:0, Insightful)
Don't use words you can't understand
Expressions .. (Score:4, Insightful)
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
The Parrot Engine? (Score:2, Insightful)
Will that make Perl 6 coders a different kind of "Parrot Head"?
Re:Trolling, maybe (Score:5, Insightful)
Re:Expressions .. (Score:5, Insightful)
Yes but you have to admit that perl has a certain charm about it.
Haven't you ever sat there staring at a subroutine, thinking to yourself "man I sure wish I could just hold shift and slide my finger over the number row to get this done"? Then gone on and painstakingly crafted what you wanted to do in whatever strict language you were actually working in?
Maybe it's just me. But every time I sit down and promise myself to write a new script all tidy and clean in python, about five minutes into it I'm muttering "if this were perl I coulda been DONE by now" and quickly revert back to old faithful.
why rev a language ? (Score:2, Insightful)
Three cheers for Perl! (Score:5, Insightful)
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
Re:Anyone who intimately knows 5 (Score:3, Insightful)
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...
Re:Ruby... (Score:5, Insightful)
Sorry, but you had missed some things that Ruby has none of compared to Perl.
Re:Expressions .. (Score:1, Insightful)
It is absolute possible to write clean and elegant Perl code, but the dicipline to do so has to come from the programmer and is not inherent in the language. Perl's flexibility is both it's greatest strength and greatest weakness.
Maybe OT but I don't get it... (Score:5, Insightful)
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
Re:Why was Perl5 so Popular? (Score:2, Insightful)
Actually, after using languages like Perl, PHP & Python, I started to question the reason why we need binaries.
P.S. I'm yet to try out Ruby.
Re:Anyone who intimately knows 5 (Score:3, Insightful)
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 [rit.edu] 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.
Re:Anyone who intimately knows 5 (Score:5, Insightful)
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.
Re:Expressions .. (Score:4, Insightful)
Whereas I look at my Perl code for about an hour and a half thinking, "Ummmmmmm, what the fuck is this supposed to mean?
Not that either of them have a patch on APL, mind you. APL Roolz.
KFG
Re:Three cheers for Perl! (Score:5, Insightful)
Of course, I would probably argue that Perl cannot solve "large problems" after creating 100k+ line Perl applications. The problem lies that the reason languages like Perl is good for quick and dirty hacks is just the reason they are not that good for large systems that needs to be maintained over longer periods of time with many developers involved.
Larry, please hurry (Score:5, Insightful)
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.
Re:Expressions .. (Score:5, Insightful)
If you haven't got the time to write something properly, forget it - you'll only regret it if you write junk.
Say what? (Score:3, Insightful)
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...
Release date: 2020 (Score:5, Insightful)
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
Re:Ruby... (Score:1, Insightful)
And Ruby has documentation, sure... But nowhere near the amount that Perl does. I do man perl<tab> on my system, and there are 136 manpages available. And that's just manpages! What about perldoc? Plus there's just much more Perl stuff available online. You merely have to look.
I actually really enjoy Ruby. I could almost see myself switching from Perl to Ruby, if a CPAN equivalent were available. I realize that Perl's had a few more years to accumulate modules, but frankly that's Ruby's problem, not mine.
Until things I need are available on Ruby, I'm going to stick with Perl.
Re:Why was Perl5 so Popular? (Score:5, Insightful)
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.
Perl is a window into a programmers heart (Score:5, Insightful)
Re:Who would have thought! (Score:5, Insightful)
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.
Re:Maybe OT but I don't get it... (Score:4, Insightful)
I think that a lot of the complaints about ugly code come from two things: excessive use of automatic variables like @_ and $!, and regexps. Reading automatic variables is something that comes with practice (Quick! Do you know what @+ is?) but reading regexps is likely to remain a problem until people start using /x (or Perl6) and comment them.
Re:Why was Perl5 so Popular? (Score:3, Insightful)
No expert C++ programmer would do a text processing task in C++. Most experienced programmers would use the scripting language they know best. They might write or use a module written in a compiled language if the task is more complicated than simple text munging.
Re:Why was Perl5 so Popular? (Score:2, Insightful)
Perl 5 does have its quirks. Yet, the quirks are hardly something that will make coding impossible. Even with its quirks, it's still a language that works just fine for what it does.
Perl 5 reminds me of an almost regularly cleaned room. You can live there, stay for hours, there's a lot of cool stuff people have brought to the room... do everything you want and have fun. Just don't move the sofa because there's tons of dust under it.
Perl 6 designers, then, are finding us a new room, move all old stuff from the old room there, and then ask the people where each of the things should be put or would the things look better a few meters to the left, perhaps. And they carry out all of the old newspapers and install one of those automated vacuum cleaners too.
Is this still Perl? (Score:3, Insightful)
Re:Anyone who intimately knows 5 (Score:5, Insightful)
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.
Should be formatted thusly (Score:3, Insightful)
of the Perl Haikus will not
Apply anymore
Re:Who would have thought! (Score:1, Insightful)
Re:Expressions .. (Score:5, Insightful)
Pretty ironic when you consider that PHP has exactly the same issue, along with some other issues Perl does not have (lack of namespaces, inadequate comparison operators, etc.).
Re:Anyone who intimately knows 5 (Score:5, Insightful)
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.
Re:Ever heard of comments? (Score:2, Insightful)
perl is a swiss-army-knife (Score:3, Insightful)
What more to say ? Any real engineer has a "toolkit" of languages they use to put things together: I find "shell" to be glue, and "perl" to be rapid production of do-anything using CPAN modules. That's perl's niche.
Re:Anyone who intimately knows 5 (Score:1, Insightful)
Yes.
right...but (Score:5, Insightful)
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 ;-)
Re:for the naysayers.. (Score:3, Insightful)
Re:Ever heard of comments? (Score:3, Insightful)
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.
Re:Anyone who intimately knows 5 (Score:3, Insightful)
If a company doesn't have the discipline to set and enforce coding standards, then the choice of language isn't going to be your biggest problem.
IMHO
Re:Ever heard of comments? (Score:5, Insightful)
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.
Re:Who would have thought! (Score:1, Insightful)
br>Um, dude, you do realize that in the real world this is the situation 90% of the time? Code is generally used for a practical purpose, as far as I know.
Juvenile Court to Try Shooting Defendant
So like is there a certain lines per minute threshold at which one can enjoy Perl?
Re:Perl: The Beginning (Score:2, Insightful)
Re:Perl: The Beginning (Score:5, Insightful)
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 [perl.com] for more info.
Re:Who would have thought! (Score:1, Insightful)
They tried to "invest" in its two perl programmers to port the thing to Java. They wrote a very nice verbatim translation, relying on hashmaps and java regexp libraries and making a mockery of their objects, simply using them as ill-named procedural labyrinths.
You can be ugly in any language.
The only reason I prefer java is that its easier to enforce conventions, encapsulation, OO, etc., so as we ramp up with additional programmers, I won't have to worry as much about noodles of crap.
I'm sure I can do any single programming task faster in perl, but over the long haul with a potentially rotating cast of programmers, java, combined with better design, will make everyone's jobs easier.
Or i'm talking out of my axe and I'm just the next pulper in line.
Beauty is in the eye of the beholder... (Score:3, Insightful)
IMHO, Perl 6 is merely an employment continuation program for perl authors and training consultants. 5.8 doees more than everything I need and other languages fill in where perl is lacking (thr right tool for the right job and all).
Re:Perl: The Beginning (Score:2, Insightful)
-- Erik Naggum, comp.lang.lisp
Re:No, Python (Score:3, Insightful)
1. Use descriptive name for variables, functions, objects, etc. Stick to a convention here.
2. Also stick to a coding standard (brace style, ident, etc).
3. Write good comment, but don't overdo it. Especially true for regexp, where you should describe what you want to match and what constraint you take into account.
4. The most important: generalize as much of your code as possible into object or package.
5. A corrolary of 4 is to re-use existing library. Search CPAN and prefer well-known package over more obscure one.
The only Perl-specific advice I would have is to avoid obscure and lesser-known Perl construct such s compiled regexp, closure, use of local(), etc. If you do use one of these construct, explain the purpose of doing so in a comment, and give pointer to documentation on the subject if appropriate.