Perl is 25 years old today
perldoc.perl.org
perldoc.perl.org
When I write in another language I spend a long time looking for a library like the ten I'd find in CPAN, sometimes I find one but often enough not, then a long time complaining about how if I used perl I'd have access to the perfect CPAN module and therefore already be done with the whole project, then basically reimplement the CPAN module in the smaller inferior language, then finally write glue logic to link stuff together.
I never fail to be amazed when I see pages and pages of an inadequate homemade xml parser written in an inferior language or maybe a blizzard of regex, and then hearing bragging about how in Perl the elegant alternative language code would closely resemble line noise. No, in Perl, those pages and pages of buggy code would instead closely resemble one line: "use XML::Simple;" Repeat a zillion times over.
My "perl" programs / systems actually shrink in length over time rather than expanding, which is unusual in smaller languages.
With all due respect to the Java runtime (if not its memory use :-( ), it is part of a totally different ecosystem compared to the usual suspects of the scripting languages.
(And I'd argue that it is always easier to debug a scripting language than C/C++/Java, except maybe just for long running server processes.)
The java 'runtime' is hardly Java. Its like saying Pentium is C.
Java the language is hardly comparable with a scripting language like Perl.
Interesting. It never occurred to me to want this. What sort of use case is this for? It seems Perl is capable of something similar:
use Enbugger::OnError 'USR1';
Then 'kill -USR1 pid' and your process will jump into the debugger.learn more here: https://metacpan.org/module/JJORE/Enbugger-2.013/lib/Enbugge...
Shockingly, attaching to running processes has been a feature of UNIX for decades.
Knowing Perl, it probably is possible, and I just never learned about it.
Add the line where you want the execution to stop:
$DB::single = 1;
Then, run your program as: $ PERLDB_OPTS=NonStop perl -d program.pl
See: http://perldoc.perl.org/perldebug.htmlPerl has integrated debugging. Perl has pluggable runops so profilers can be attached to the platform (e.g. Devel::NYTProf). Distribution == CPAN and the 'make dist' system from ExtUtils::MakeMaker, again built in.
The introspection is -different-, perhaps, but I'm not sure I'd say it's better or worse.
Nothing meaningful? You set it to break into the debugger when that exception is thrown, and then debug it. I'm honestly not sure how this is any different an experience to in java - any java application not actively being debugged will write a stack trace to its log file and either exit or move on to the next request too, no?
Also type erasure.
Funnily enough, they're both examples of the same problem, stitching new features onto a language that was not at all prepared for them.
EDIT: I just used "strace /usr/bin/java -jar myjar.jar" and saw what looks IO but I'm not familiar with strace output yet. It looks like a handy utility though. Can you give an example of something that you expected to see but didn't when you tried it?
http://stackoverflow.com/questions/4185665/guava-equivalent-...
When I was at Google, the opinion among some of the SREs I knew was that Java there was better than elsewhere so you actually did get reasonable debugging stack traces, but the C++ libraries there were still significantly easier to debug problems in than the Java ones.
Yes, I know that those AbstractFactoryFactories let you produce convenient higher order abstractions, but when things go pear shaped, they can make it really hard to figure out what was supposed to be happening, let alone where it went wrong.
This is a fact: <opinion here>.
Java calling anyone else's stack traces is backwards and hilarious, and only going to get better in about 15 years when java finally gets lambdas.
Why is perl in quotes here?
When I took the job at Blekko they said "We do most of our stuff in perl" and I was dubious about that.
However, now that I've been exposed to V5 for a couple of years and have probably written a few thousand lines of code in it, I find its easier to write a quick hack in than Python, and it certainly has a better 'command line' feel than Java. But it wasn't until I started coding up a quick CMS type gizmo for making HTML pages that I truly "got" the power of CPAN backing it up. There is a lot of stuff there. Folks like me who gave up on the language in the V3/V4 days as "hopelessly hacky" should re-visit it.
http://stuff.mit.edu/afs/sipb/user/marc/hotjava/doc/people.h... (top left corner)
I've still to come across a language that lets you get your ideas down as quickly. It's full of fantastic time savers, e.g. the for(<>) construct and the format output functionality cover a bunch of common use cases in minimal keystrokes (let me pipe in some data, analyse it, then spit it out in a clean report).
It can hurt readability but for small one offs, it often doesn't matter.
It's a shame really, since all the building blocks needed to implement a useful mode for writing one-liners are there. In fact, I have a work in progress module that tries to address this issue: https://github.com/gvalkov/python-oneliner
By all means, everybody should use what they are comfortable with. Ruby and Perl allow you to write extremely terse and awesome one-liners, the likes of which will never be possible in Python. But if the first solution that pops into your head is a Python one, why not use that?
It looks like a fantastically expressive language, but i fear the learning curve would be too steep for my time invested to pay off - others would have to spend the same time to learn it as well, negating any code sharing / reuse in my org (we don't use J).
I found others i had to share code with weren't as interested as me about writing maintainable perl code - i got really fed up with a patch work of "write only" perl scripts performing useful functions in prod. From DB maintenance tasks to general housekeeping, to work-arounds for prod app issues that never got prioritised for strategic fixes.
I found in practice python code produced by most others was easier maintained: it seemed to more or less force people to write more readable and therefore, maintainable code.
I also viewed the fact that Python was one of the premier languages across so many problem domains (Systems, DB, GUI, Web, Large data, GPU, etc.) as being a sure fire payoff for any time invested in it.
In environments this size it's not any one persons actions dictate what becomes the status quo: different groups will have different agendas and therefore priorities and views. I guess i was lucky that everyone else was either willing to give Python a go, or was easily convinced.
FWIW over the past few years it's proven to be a good choice for us. There are still O'Reilly books float about, esp between the newcomers but there's no zealous "where's my camel book!" shouts anymore.
What do you mean by "readable" and how does Python seem to enforce that?
This is great - you can cook something up in 5 lines that would take 15+ in Python and 50+ in C++. It also means that it's really tempting for some to abuse this ability, even for code which will be long lived.
I don't believe Python is that inflexible (it's not), and I don't see how the limited and superficial ways in which Python pushes all code to look the same are really that meaningful.
Perl's autovification allows me to build a data structure at parse time with code that is trivially verifiable. Python forces me to sprinkle the code with a thousand tests for whether or not the field is initialized yet, or write extra code to define things like defaultdict instances (with syntax that I always have to look up, and which in my experience most python programmers don't understand).
Not to mention that if I want to use an OO syntax for that data structure I have to write extra code defining a class for it (and inevitably be yelled at by the pythonista security branch for all the __whatnot__ methods I forgot to define).
Python's comprehension/generator syntax is nice, though, and doesn't have a clean analog in perl. One thing it does do well is chaining up "filter" operations on aggregate data structures in a clean way. And that has value and is worth emulating. But honestly most of the rest of the language is junk compared to perl or ruby.
And then there are a pile of modules that implement python-style generators, some using https://metacpan.org/module/Coro (co-routines implemented as threads), some using crazy hacks:
https://metacpan.org/module/Compile::Generators
As for regexes - while they are somewhat clumsy in python, they don't have to be defined distantly:
m = re.match(r'(\d{4})', buf)
if m:
print "year: %s" % m.group(1)
The only thing that really bothers me about the above is the need to separate the assignment of m from the test.Re comprehensions: seems to me they are just Python's version of Perl's map and grep.
grep:
@good = grep { $_->{width} > 9 } @crates;
good = [c for c in crates if c['width'] > 9]
map: @squares = map { $_ * $_ } @nums;
squares = [i*i for i in nums]
Which is better? I think Ruby's way is the best, and Perl/Python are a wash here.Now, on the autovivification note, I wonder if we can make a Python class that has the desired behaviors. Like:
c = PerlishStruct()
c['foo'][17]['bar'] = 'baz'
You don't really think it's junk, do you? Perl, Python and Ruby are extremely similar; I'd say Perl's more ergonomic, but messier; Python's cleaner, but sometimes awkward, and Ruby pretty much has the best of both worlds. m = re.match(r'(\d{4})', buf)
'map' is more general than just the single, convoluted statement of list comprehensions, which really seems as a kludge from unwillingness to accept multi-line lambdas. So something new was invented that had to be learned; then it was argued it is a boon. (Like references in Perl. :-) )(There is some defaultdict functionality for autovivification in Python iirc.)
Yeah, they are all similar. I don't know enough Ruby to have an opinion.
Unmaintainable? Who cared. Got shit done. Too many ways to do things? Who cared. Got shit done.
I have this totally false feeling that BACK THEN* we wrote IRC bots and we were happy. And `perl -e '"A"x800'` was the destroyer of worlds.
* - shit, I just realized I'm young.
Interesting how I consider Perl an 'old' language, and the others new languages. I guess it says more about how revolutionary Perl was at the time and how quickly it became widespread. The only other language I know of that went from 0 to everywhere in under 5 years was Javascript.
PHP was first created in 1994, so it's 18.
Hm. If we do this, then C++ is merely one 'capstone' on the history of Algol development, which is about as old as Lisp is.
Scheme, for example, is a decade older than Common Lisp, but it's still commonly considered a Lisp (no pun intended).
I'd peg Python's coming of age around 2001, although I could be wrong about that. Ruby is even fresher out of the oven, not really reaching the limelight until 2006.
Pascal is 42, C is 40. Lots of fun info on that page.
int i 4;
and the assignment operators being the other way round:
a =+ 2;
The point is, when discussing the age of a language, how important is the degree of change over time? At what point is it a new language? The same is true of human languages. I can understand Shakespeare with little trouble, but I miss some points unless there are footnotes. I can get a bit of Chaucer, but far from full comprehension. Beowulf? Not a prayer. But it's all "English"...
People still run production COBOL programs, today, that were written in the 60s and 70s. They may compile it with a version of COBOL that has support for features like object oriented programming. But the programs were written decades ago, and do not use those features.
I know one person who, 10 years ago, went back to work for the same company that she had worked at 30 years prior. Among other things she found a PL/I program that not only was around, but the last commit on was hers. She asked them, "I'm the last person to touch that, and I don't even know that language any more! Why are you still running it?" The answer was, "It never broke." (Sadly that company went bankrupt in the financial crisis, so her code is probably now dead.)
Code can live forever.
In active use, that's actually easy, especially in the industrial space (that's why I mentioned distributed as well as active, which gives another metric entirely)
Just about a year ago I was tasked with recovering software from a HP1000/RTE machine (driving an industrial oven in a forge), written in a Fortran dating back from before it was properly standardized.
We recovered the code through the machine's serial port, with the built in print functionality, which conveniently prepended a header along with the file's content. Together with pyserial at the other end, a few hours of hacking had a laptop listen via a PL2302 serial/USB adapter, parsed the printed header to get filename and a few metadata, and wrote content to the proper location.
The harder part was manually moving through directories, and printing the files at 1200 baud, through a terribly laggy and completely burned out 80x23 passive monitor.
Headers in the code mentioned it was actually older than me.
With a few massaging, the code actually compiled on a recent gfortran (F95!), but hte linking part was entirely different, and many proprietary symbols were missing. We went through the 30 years old documentation and found what we needed to stub them and plan how to act forward. The thing was actually quite close already to Unix and what we find on Linux these days, only much much more primitive. The code contained critical functions whose role was to compute thermal data for automation, according to various (thermodynamic and other) complex and undocumented rules, so I built a detailed plan about possible actions to take, including linking to C wrappers binding the stuff into Python, complete with a prototypal HTML5 visual status feedback of the automation system. That's when I left the project (and the job).
But for my own stuff I still reach for Perl. Best testing infrastructure on the planet and that, in combination with CPAN, lets me get shit done.
https://groups.google.com/group/comp.sources.unix/browse_frm...
Perl Kit, Version 1.0
Copyright (c) 1987, Larry Wall
You may copy the perl kit in whole or in part as long
as you don't try to make money off it,
or pretend that you wrote it.I had thought someone had done a perl 1 release that built on modern systems, but on a quick hunt I can't find it.
See for example https://github.com/mirrors/perl/commit/8d063cd8450e59ea1c611... for the perl 1.0 annoucement (click on the [...] link to get the full commit message).
My more active interest in perl was pre-git :)
It might be fun to see that run against the Perl core.
I also like looking at the number of lines of code. If your features go up while complexity and lines of code go down -- that could be a good sign.
I have been working as a programmer for 25 years and started using Perl in 1993 or so. I cannot express what it felt like to have this incredibly powerful tool that seemed to integrate all of the sed, awk, shell, and C code that I had for research. Using Perl absolutely felt like magic, particularly for analyzing text.
I love Python, Ruby, and Lua too, but Perl will always be the tool that quickly gets things up and running.
To me Perl is awesome :) Too bad I do PHP for a living, but I still enjoy it when doing something for myself. Like last time I learned about web framework Mojolicious ( http://mojocasts.com/ ) and built http://gotldr.com and http://hntldr.com leveraging Mojolicious and Redis - https://github.com/hippich/perl-tldrer . It took me few evenings, but I really enjoyed tinkering it.
Perl is a very handy and powerful scripting language but it should not be considered as a durable solution. Whatever is quickly hacked using Perl should be probably rewritten in a much more structure language, especially if you plan on maintaining this code.
... in any language should probably be cleaned up if you plan on maintaining it.
Perl6 is looking quite fresh considering how old you think it is. I just submitted an article I'd seen to HN which shows how a formula like...
4.7kΩ ± 5%
... can be parsed inline with Perl6 code.It's interesting to me how often people cite "Unicode in code" as some sort of amazing thing. I once posted on S.O. about the idea that maybe we should have a programming language where the vast array of options in Unicode were exploited to make things like Regular Expressions more readable (avoiding the backslash plague alone would be worth it).
I got smacked down by people complaining that they didn't know how to type anything but ASCII.
Sigh.
re: Unicode - Perl6 does already use unicode characters for some of its operators. Take the Hyperoperator »« (http://perlcabal.org/syn/S03.html#Hyper_operators):
my @a = 1..5;
my @b = 6..10;
my @c = @a »*« @b; # => 6, 14, 24, 36, 50
And there are >> & << synonyms for those who find using unicode chars too odd: @c>>++; # => 7, 15, 25, 37, 5 |
\|/
http://stackoverflow.com/questions/7617852/whats-the-differe...Do people just prefer one function with a bunch of fiddly little enums or something?
Now bear with me for a minute while I explain you this whole thing.
Have you worked with a language where your though tool just wasn't for you? Have you felt that language was pushing down its own self believed principles down your throat? What happens when programmers face such situations? They just leave the tool and go to something else. Perl is one of those few tools that adapts to the programmer, rather than expecting the programmer adapt to it.
Now like every other design choices you can ever make, it has its own tradeoffs. Being flexible, adaptive, powerful and quick to evolve means at times you have to sacrifice a little consistency. You can sure present your arguments and your design perspective against it, but your design again will have its own trade offs.
Why so many different ways of doing things? For example why do we have something like 'map' and 'foreach' in Perl? You won't understand this when you have used and written code that leverages these keywords to their power. Its more or less like explaining why Ice cream is delicious to somebody who has never eaten it. Unless you taste it yourself won't truly understand.
Perl is quick to learn. You can learn as much Perl to do the kind of work you can do in Python/Java/whatever. But as you learn more Perl, you become productive at solving problems. You can do it quickly, with succinct code with more powerful syntactical features.
EDIT:Corrected typo.
croak(): (slang) To die[1]
confess(): to provide information, commonly[2] as one is dying[3]
carp(): To complain, often at length and of minor details[4]
cluck(): Not actually sure about this one, although 'clucking their disapproval' seems to be something of an english idiom.
So yeah, there's some logic to the choices, even if it is rather whimsical. It's a valid point to say it's not immediately obvious, but it doesn't take long (from experience) to figure what they do and out which one you want for a given situation.
[1] http://www.grammarphobia.com/blog/2012/01/croak.html
[2] Obviously some religions promote regular confession, but the 'deathbed confession' is afaik common even among the less pious/religious.
Where are the Perl-hating trolls coming from on HN?
(I thought Guido said that it was time to stop trolling, so it isn't Python people now?)
I don't hate Perl (I first learned CGI programming with it), but I do think there are better ways to write maintainable, enterprise scale software. There are two main problems with Perl (as I see it): 1) The language is so permissive that it allows newbs to write bad code but still obtain results. Habits, both good and bad are learned! 2) Perl experts seem to delight in writing code that's "tricky" (for lack of a better word). It's like a contest to see who can wring the most out of one 80-character line of code and it leads to mid-to-low functioning Perl programmers being confused.
I can't see any relevance for a professional choice if newbies can shoot bigger holes in their foot with a certain tool.
That is a natural result of a powerful tool.
>> Perl experts seem to delight
Anecdotal. Ten years old description of half humorous use (and exercises). Also very different from best practices even then -- and especially different from how many/most work today.
Let me also note: If Perl wasn't better in many ways, you trolls would make serious arguments instead of "experts seem to delight"... [Or as you wrote above "Twenty-five years already? Now it can retire with full benefits."]
But I'll bite a little. Perl has the best OO system of all the scripting languages (Moose). The CPAN is the gold standard for scripting languages (and probably everything else). The testing culture is afaik second to none. The same goes for Unicode support. And so on.
In professional environments or large projects, hopefully you're got a reasonably comprehensive style guides (or better yet, perlcritic config), but for smaller things, it can be a bit of a struggle to understand and conform to the specific style in question if you're trying to contribute to something new.
I don't think it's enough of an argument to dismiss the language though, and agree that the benefits far outweigh the somewhat-pointy learning curve.
[1] The old "Everyone uses 10% of C++, but they all have a different 10%" joke, basically.
I never claimed that Perl wasn't powerful ... in fact I think I stated the opposite. Where I work, Perl is the lingua franca of the ops team and they certainly get things done. But the newbies don't shoot holes in their foot ... they blow it clear off and often don't survive.
My comment above may be perceived as a bit trollish but I was also thinking about "thanking Perl for a job well done". I quit Perl for what I consider valid reasons (which you completely dismiss - My experience may be "anecdotal" to you, but it's still my experience) which you're clearly not going to agree with. But notice that I never said "you shouldn't use it". I'll even admit that some people accomplish a lot with it ... and that CPAN is almost the gold standard for everything (with the exception of Maven Central I think).
So keep using Perl if you want ... but hopefully now you'll understand those of us that will no longer use it and why it's popularity is declining (http://www.tiobe.com/index.php/content/paperinfo/tpci/index....). I expect I'll replace my current tools with something better (more productive/safer/maintainable) in the next 5 years since that's been a continuing pattern for me. What will you be using in 5, 10, 15 or 20 years?
As I quoted, you also posted another obvious troll comment. So the shape of your ears and body odour are quite obvious through the screen...
>>My experience may be "anecdotal" to you
I just note the lack of modern references for your "non"-anecdotal claim.
I can give references to modern practices -- it is enough with the Best Practices book (it is seven years old...)
[As mst noted, the "Modern Perl" book is a very good reference.]
(Stopped reading after that.)
I am not posting this to bag on Perl, but just to show its fingerprint. If you find that periodic table to be funny or cool then you are a lot more likely to be happy with Perl than if it makes you shudder.
That point has been made many, many times.
Edit: To the cultural question, there might be a point. I might add that I don't know Perl 6, but it seems like an insane amount of cool/fun toys (macro language like lisp with an Algol-like syntax?! If they can pull that off it is incredible.) That might say something about me and Perl people. But people I admire use both vim and Windows, so I'm not certain.
But you are in denial if you think that this chart isn't a reasonably representative cultural artifact of the Perl community and the Perl aesthetic. Perl 5 is not exactly poor in operators, and it is the same core community which produced both.
I don't think that Perl is bad. I am saying that Perl is very strongly what it is. And while some people won't like that aesthetic, I don't see why anyone should apologize for it.
$ perldoc perlopJust an anecdote: a startup I work with built a product on Rails 2. It has been successful beyond anyone's wildest dreams. But they have a huge mess on their hands now, and it was caused by -success- :)
How is this different than any other language? You can write bad code in any language. Perl might allow for more obfuscated code which really makes it harder to read - but that again reflects on the programmer - not the language. Take a look at a code in PHP, Python, C, or any language written by "newbs" and you will see poor practices used everywhere.
Modern Perl and other recent books push people towards developing good habits.
The current generation of experts tend to either put our tricky in very well encapsulated CPAN modules, or comment the hell out of it, or both ... or if at all possible, stick it into a paste site somewhere for other people to go "whee!" at and do something sensible in the main codebase.
Your complaints about perl were absolutely valid a decade ago ... these days there's still some truth to them, but we've grown up a lot since then :)
I won't explain myself, smoyer's example (except the 'hate' part) pretty much sums up what I think about Perl. And yes, I believe it's a great language, although looking from a state of development of modern languages point of view, objectively speaking, it's a bit outdated language. And therefore, in my opinion, will find less and less applications in the future (and yes, Python is and will be its main competitor in many fields).