12 ms·
The Perl Renaissance
- nnq 14y ago...don't get mad for the question, but: anybody has any arguments for using Perl instead of, let's say Python, these days? (besides the "I already know it incredibly well" argument) ...cause the lack of an answer to such a question has only one conclusion: the language is dying, even if this is not already happening in a visible way! (don't get me wrong, I'm not a Perl hater, and fyi, I think the world would be a much better place if Rasmus Lerdorf would have learned Perl and written a nice Perl web framework instead of inventing PHP :) )
- drucken 14y ago- CPAN - efficient and compact regex scripts - one-liners. Of course, some of these could be considered a reason NOT to use Perl depending on your specific circumstances.
- nnq 14y agoCPAN ~ pypi ~ rubyforge. Ruby allows you to write decent one-liners too, though people don't like to use it this way. the only argument I can extract from this is "Perl has a much nicer syntax for working with regexps", and I agree with this (and I hate it when other languages don't fully embrace regexps and treat them as first class citizens). but that's the thing, not even the "reasons not to use it" are unique to Perl any longer: heck, if you want to write incomprehensible code for "job security" reasons, Ruby gives you enough rope to hang the whole neighborhood (and Python too has a "dark side", but fortunately most people don't know or want to learn about it)
- falsedan 14y agowork uses pypi every day, and I had to set up a caching proxy because mirrors are frequently unavailable. It was inconceivable coming from CPAN that the major package distribution network for a major language may be down.
- mgkimsal 14y agoOT but I think it's one of the reasons mandrake/mandriva never quite took off. There was never a great centralized repository network you could count no - I grew tired of using the PLF system to grab a list of mirrors, and having to update it all the time because participating mirrors were offline or defunct after a few weeks/months.
- Ologn 14y agoI had to deal with the major third party, more or less essential, Ruby and RoR gems a few years ago. Rubyforge was a part of this constellation of essential third party gems. Dealing with gems was definitely dependency hell, with mixed up cross dependencies, which were dependent on certain versions of other gems, that were sometimes conflicting when there were a number of gems. Also, you would go to the main Ruby web pages and click links to documentation and the links would be broken - not some obscure, old documentation page to another old, obscure module, but from central help web pages to other pages of central importance. I have used CPAN for many years and it is so much more rock solid and automagic. If a mirror is down it jumps to the next one without a beat. The CPAN modules are great too. I was using XML:Simple recently, but the XML files got too big. So I looked around a little and started using XML:Twig, which works great. Then I needed to sort alphabetically words in a variety of languages. So I went with Sort:ArbBiLex which allows me to create my own sort dictionary and has suggested Western language dictionaries on the documentation page. And yes, it has a cmp call which allows for easy multi-column sorting. For whatever problem I have, it seems someone has already written a module for it, which I can get going with little effort.
- yxhuvud 14y agoBundler helps a lot though when it comes to managing the gem dependency hell.
- wazoox 14y agoPython significant white space. Really, that's what preventing me for ever liking Python.
- coldtea 14y agoGet an editor that shows whitespace. (Non)Problem solved. Not to mention you should indent your code exactly the same way (in a consistent format, either tabs or spaces) with how you'd indented Python code.
- jeremyjh 14y agoIt isn't totally solved. For example, you cannot write a lambda that contains a line-break. Its not a big problem, but it is a trade-off.
- nnq 14y agosignificant whitespace is not why you cannot write a lambda that contains a line-break. the problems are not really related. just ditch the difference between statements and expressions and allow multi-line expressions. true, then it will no longer be Python but a whole different language :)
- brendoncrawford 14y agoPut this in a text editor and run it in python: print(reduce((lambda x, y: x + y), xrange(10))) print(reduce((lambda x, y: x + \ y), xrange(10))) HINT: It runs.
- sylvinus 14y agoOpinions on Python aside, I'd never hire somebody saying something like that at an interview, even about a language I don't like. You should really look past petty details when evaluating any tech and come up with actual arguments.
- nnq 14y ago
- mhd 14y agoSo it's dying, but not visibly? I can't really parse that, but I bet the answer will contain quite a few Perl 6 references…
- nnq 14y agoI use "visibly dying" for a technology that people are migrating away from - this usually generates things like blog posts titled "X is moving away from RoR because it's crap and rewriting their stack in new fangled scala framework". But there are other ways something like a language can die in: no new projects get written in it, no new programmers learn it etc. ...this is a slow "death in silence and darkness" (think Pascal).
- mhd 14y agoI see what you mean. And just a few years ago I would've agree that this applies to Perl. But then we got projects like Moose, Dancer, Mojolicious, the whole "Modern Perl" movement and a renewed focus on Perl 5 (very regular releases). I think a part of the community was waiting for Perl 6 and thus everything was a bit stagnant, but lately I don't get that feeling anymore. It feels closer to Firefox, which is showing some renewed vigor lately, than to e.g. Tcl (sadly…). This isn't really the only presentation/post about this. After all, it's not like Django and Rails receive the same amount of hype as they did in the beginning, so if you're just going by that, we probably all should switch entirely to Go and Node…
- knotz 14y agoIt's a very fun language to begin with. Which is not unimportant if you want to keep being motivated after three decades being a programmer. Peter Norvig described 7 features which made Lisp different. Perl shares 6 of them. Important features like first-class functions, dynamic access to the symbol table, and automatic storage management. (source "High Order Perl" by MJ Dominus).
- nnq 14y agowell, putting aside things "dynamic access to the symbol table" or run-time ast manipulation types of black magic, first class functions and "automatic storage management" are available in both Python, Ruby (...yeah, you need to twist your mind towards thinking in blocks/procs as first class functions, which annoys the hell outta me, but doesn't seem to be a problem for others) and most other "dynamic" languages.
- edwinnathaniel 14y agoUniversal on NIX systems. Python has a few 2.x versions depending on the Distros. Some distros may opted to go 3.x only. Ruby isn't necessarily universal on NIX systems. Perl is.
- wazoox 14y agoArch Linux now ships Python3 only. That's quite a problem, because many things still depend on Python 2.x (for instance building Firefox from source).
- PommeDeTerre 14y agoSo download the latest Python 2.7.x source code and install it yourself. Python is extremely easy and quick to build from source on Linux.
- autarch 14y ago...don't get mad for the question, but: anybody has any arguments for using Python instead of, let's say Ruby, these days? (besides the "I already know it incredibly well" argument) ...cause the lack of an answer to such a question has only one conclusion: the language is dying, even if this is not already happening in a visible way! (don't get me wrong, I'm not a Python hater, and fyi, I think the world would be a much better place if David Heinemeier Hansson would have learned Python and written a nice Python web framework instead of inventing Rails :) )
- bryanl 14y agoRuby doesn't have great support for math, science or AI. There are projects out there trying to make the ecosystem better, but currently it trails Python.
- dasmoth 14y agoFor biology -- especially the genomics side -- Perl was absolutely dominant 10 years ago. It's been gradually edged out by other things (substantially Python and R) since then. Desire for better statistical tools may be a driver here, but it's interesting that it's led to a switch of languages rather than building more stats tools for Perl
- gajomi 14y agoI would say that Perl is still dominant in computational genomics. About a year ago I wrote some code to do some basic comparative analysis at the genome level alongside some more gene focused phylogeny efforts. Since the whole thing was quite simple it wasn't a problem to write the overall structure, but getting the bioinformatics Python libraries working was a pain. Even if the code tiself was Python the API was littered with various Perl and Bash idioms and there was a major bug in at least one of the tree building methods (had to patch it myself). Calls to subprocesses within the libraries (a heavy part of most bioinformatics work, where there are thousands of stand alone command line programs) would often fail without warning. The state of the art in this area is definitely behind Ruby and far behind Perl. However, Python is still my main language and I am very happy with that. The numpy/scipy stack and everything building around that is incomparable to anything in Perl of Ruby. Also for the last month or so I have been doing work in the IPython notebook. It has really helped my productivity and documentation efforts. And it looks really cool.
- deleted 14y ago[deleted]
- eCa 14y agoThat question can be turned around: Why should someone use Python (or Ruby) instead of Perl? For someone who hasn't used any of those, I'd say give each of them a few hours and see which style suits you best. Of course, try to find modern examples to learn from. When it comes to Perl that means: * Mojolicious [1] (or Dancer [2]) as the web framework * DBIx::Class [3] as the ORM (maybe with some sugar [4]) * Moose [5] (or Mouse or Moo) as the object system [1] http://mojolicio.us/ http://mojolicio.us/ [2] http://www.perldancer.org/ http://www.perldancer.org/ [3] https://metacpan.org/module/DBIx::Class https://metacpan.org/module/DBIx::Class [4] https://metacpan.org/module/DBIx::Class::Candy https://metacpan.org/module/DBIx::Class::Candy [5] https://metacpan.org/module/Moose https://metacpan.org/module/Moose
- anonymous 14y agoPython and Ruby both have garbage collectors and can deal with reference cycles. Perl only has reference counting, leading to programs that leak memory due to reference cycles and needing to hunt down where in the code you're creating them. It's the only high-level language I know of that only has reference counting for memory management.
- lazyjones 14y ago> It's the only high-level language I know of that only has reference counting for memory management. It's also the only high-level language I know of that can't really be parsed ("only Perl can parse Perl" they say). It's a dead language really, you can also see this from the number of noisy evangelists vs. professional users nowdays (and that comes from someone who has used Perl almost exclusively for the past 10 years), if you couldn't see it from the diminishing quality of important modules on CPAN (e.g. I pulled my hair today over JSON::XS generating '-inf' from values on one side and crashing on the other side while trying to parse it). So, I'm learning Go now and improving my JS skills.
- jstanley 14y ago"you can also see this from the number of noisy evangelists vs. professional users nowadays" Actually, where I work, we use Perl almost exclusively. I don't know a single person who I would consider a "noisy evangelist" - we just quietly get stuff done.
- toddh 14y agoText processing with interpolation, the dynamic type system, and regular expressions is insanely easy as they are integrated directly into the language. You don't have a lot match, compile, and match group type scaffolding in your code.
- wiremine 14y ago> anybody has any arguments for using Perl instead of, let's say Python, these days? The Perl community is software's Maker subculture [1]. They have a "heck yeah, we'll give that a try" perspective lacking from other subcultures. The the larger software ecosystem ever lost this Maker/Perl worldview, it would be a huge lose. Taking a step back: In some ways, I think languages get larger adopted because of their culture. Their technical implementation is just a manifestation of the culture. (And, I think this explains why LISP has never broken out. It isn't a language problem, it's a cultural problem). [1] http://en.wikipedia.org/wiki/Maker_subculture http://en.wikipedia.org/wiki/Maker_subculture
- walshemj 14y agoCPAN is probably the main one when i built a front end to authority labs api all of the heavy lifting (apart from the Callback handler) was done using perl modules
- wschroed 14y agoTail recursion. ;) Bioinformatics. I am currently looking for a couple software developers (https://news.ycombinator.com/item?id=5203736 https://news.ycombinator.com/item?id=5203736) for positions where Perl is the dominantly used language.
- jrockway 14y agoCPAN.
- nnq 14y agodisclaimer: I really didn't intend to transform this into a discussion that's 70% about Python (I could have said Ruby or Javascript instead, the question was about Perl and the comparison was just an example). Right now I would downvote my own parent comment if I could, just to get higher the other comments that are actually relevant to Perl programmers.
- cpressey 14y agoMainly for the sake of completeness, I will mention: block scope. I program in Python a lot, and I like it, but it always boggles my mind when I remember that block "locals" are still visible after a block is closed. JS and PHP are (I believe) the same way about this. The Perl (and C) approach of "proper" block scope feels much less icky to me.
- oneandoneis2 14y agoWow.. I've been using Perl heavily for the last three years and he still managed to cram some amazingly useful stuff I didn't know into that short talk. Well worth watching if you still equate "Perl code" with "line noise" :)
- joel_perl_prog 14y agoGreat talk! I've never posted before, but I'm inspired to today. Forgive me if my code is formatted terribly this post. I used Perl back around 2000, like everybody else, to make CGIs. Then went away from it for a long time. But I've used Perl over the last year to create a large DMCA takedown system, the bulk of which is spidering and analyzing web pages for infringements. Torrent trackers, one-click file download sites, etc. It's been a beautiful experience. The code runs quickly (for a scripting language), and CPAN is AMAZING. I feel Perl was the best choice for this project, and since I enjoy the language--and trust me, it's NOT line noise: these aren't little scripts, this package-based, documented, modular software development, the likes of which people normally associate with Java (for instance. I have to say I disagree with one point in that talk. I don't think there are "too many" ways to do OO in Perl--and this sort of ties into his gripe about "@_" and slurping in subroutine arguments, which I think is pure joy. I'm not certain, but I think Larry Wall got this from Lisp. Please correct me if I'm wrong on my history there. Anyway, in one package that I use as an object, I have this code: #/ @param object $this an Offense::Analyzer #/ @param string $event an EVENT_x constant value #/ @param int $targetId a target id #/ @param int $obvious TRUE for obvious offenses, or FALSE #/ @param int $same TRUE for offenses found on the same target, or FALSE #/ @return int the value for the given event, or undef sub getEvent($$$$$) { my ($this, $event, $targetId) = (shift, getEventFor(shift), shift); my $obvious = getObviousKeyFor(shift); my $same = getSameTargetKeyFor(shift); return undef unless $this->hasTarget($targetId); $this->{'data'}{$targetId}[$obvious][$same][$event]; } And I supplement that code with the following convenience getters: sub getIgnored($$$$) { shift->getEvent(EVENT_IGNORED, @_) } sub getNotified($$$$) { shift->getEvent(EVENT_NOTIFIED, @_) } sub getQueued($$$$) { shift->getEvent(EVENT_QUEUED, @_) } sub getRemoved($$$$) { shift->getEvent(EVENT_REMOVED, @_) } I love the convenience of being able to use the incoming arguments array in this manner. In fact, because you explicitly pass the object reference as the first argument to methods in Perl, I even have this: #/ @param object an Offense::Analyzer #/ @param string an EVENT_x constant value #/ @param int a target id #/ @return int the value for the given event sub getEventTotal($$$) { int(getEvent(@_, TRUE, TRUE)) + int(getEvent(@_, TRUE, FALSE)) + int(getEvent(@_, FALSE, TRUE)) + int(getEvent(@_, FALSE, FALSE)); } Those are not static method calls (so to speak--package sub calls), but are object method calls. I love that convenience. Does your fluency need to be very high for this to seem like a good idea? Probably. And in this manner, Perl can never compete with Python. But I guess my argument is similar to the argument a lot of Lisp dialect programmers make: I'm an advanced user, I don't need to be babysat, I can take care of myself, and I'm ok with exploiting the expressiveness of the language.
- pfortuny 14y agoThe fact that they "like" the language. Not noticing it does not equal "nonexistent". Your perceptions do not describe the whole reality. Any turing complete language can do any job. As long as they are not astoundingly unequal, which is not the case, people choose based on... taste.
- ShiningRay 14y agoI'm always looking forward to Perl6, waiting for its stable version, for 10 years.
- berntb 14y agoAs I understand, it has been going on for as long as Python 3 -- which is starting to be used in a few places now. (The difference is that Perl 6 is really, really, really ambitious. Let's see if it ever gets production-ready.)
- Roboprog 14y agoI think perl 5.10 and beyond kind of preempted perl 6. Alas, perl 6 in some ways isn't even perl. Perl 6 is cool, but Larry should have made a new name for his next hobby :-)
- eCa 14y agoPerl 5 and Perl 6 are two different languages; Perl 6 is a sibling, rather than successor, to Perl 5. http://dev.perl.org/ http://dev.perl.org/
- mpdehaan2 14y agoI would recommend starting with MooseX::Declare instead of Moose if you are trying to upgrade your Perl, as Moose is great above standard Perl OO but doesn't go far enough by itself. Previously I found that MoooseX::Method::Signatures was very slow, so I ended up selecting Method::Signatures::Simple. Coupled together, you end up code that looks somewhere between Ruby and Java. It's not my first choice for a new project, but it's not a bad way to fixup an old but large codebase. Possible code example: https://github.com/mpdehaan/Elevator/ https://github.com/mpdehaan/Elevator/
- psadri 14y agoPerl unfortunately has a bad image vs its true reality. I think Perl / Python are interchangeable as a language choice for web scale projects. If your biggest problem is whether to use Python vs Perl vs X, then I say good luck to you -- you should really have more important problems to worry about. I'd never use ruby for a web scale project (as evidenced by the many services solely dedicated to scaling ruby on rails apps). PHP is not really a language. Maybe the future belongs to ECMAScript.
- jlikesp 14y agoAnything you can build in Perl, you can also build in Ruby or Python (or hell, even PHP), so it seems rather pointless to argue any of these solutions are superior to another. At the end of the day the choice is largely personal preference (or company requirement). Also, I know plenty of programmers who still earn a living writing Perl, so it's clearly not a dead language by any stretch of the imagination. Personally, I would LOVE the chance to work on a Mojolicious project. IMHO that's the best web application framework today (in any language).