17 ms·
I don't care how un-sexy perl is by current standards. It's damn efficient, even for new projects. Also, it's not hard for a developper worth its salt to get pr
by guylhem 13y ago
I don't care how un-sexy perl is by current standards. It's damn efficient, even for new projects. Also, it's not hard for a developper worth its salt to get productive in perl.
At the moment I'm playing with some threaded perl to parse very large text files - part of the code was developed by a C++/Java/js fan, who just realized it was the best tool for the job, and created that after a few days of playing with perl.
- Pacabel 13y agoBut is that really unique to Perl these days? It may have been true in the mid-1990s, but things have changed since then. Python and Ruby both have a much cleaner syntax, yet still offer very comparable functionality, excellent portability, ample standard and third-party libraries, excellent documentation, supportive communities, great regex support, and basically everything else that Perl offers. Since everything positive about Perl is also offered by alternative languages today, and those alternatives are themselves much better than Perl in some respects, Perl seems like a less and less enticing option each day.
- _delirium 13y agoIt could be familiarity, but for small- to medium-scale "scripts", I still find Perl to be the best alternative to bash+sed+awk+grep thrown in, when I want to go to something more conventionally programming-ish. Basically its original use-case, before Modern Perl. You can use Python for that, but the jump from Unix shell to Python feels bigger; everything is more verbose and less awk-y in Python. Which can be good for maintainability of bigger scripts, but feels heavyweight for some stuff.
- wting 13y agoAre you aware of sh? http://amoffat.github.io/sh/ http://amoffat.github.io/sh/
- codygman 13y agoAnd the Haskell equivalent for a performance and type safety boost: https://github.com/yesodweb/Shelly.hs https://github.com/yesodweb/Shelly.hs
- kamaal 13y agoIts not about having function to call shell commands. That way I might as well use C or C++ or Java. Its about how such a feature interplays with rest of the language. Frankly speaking in Python it looks like added after a lot after thought and a lot of reluctance. Same with regular expressions.
- _delirium 13y agoYeah, it's not just about shelling out, but about being able to write Perl that works sort of like an awk script, just with more of a real language attached to it. Functions that implicitly work on the current line, lightweight regex syntax, the <FILE> magic, bash-style file tests (-e/-r/-d/-f), etc.
- PuercoPop 13y agoPerl has reader macros and a meta-object protocol upon the object system is built with. Ruby and Python don't have either AFAIK. That is an example of what the OP is saying with Perl is an extensible language.
- banachtarski 13y agoYou should learn Ruby.
- systems 13y agoit seems that Ruby doesnt have a MOP http://codefol.io/posts/Does-Ruby-Have-a-Metaobject-Protocol http://codefol.io/posts/Does-Ruby-Have-a-Metaobject-Protocol
- einhverfr 13y ago> Perl has reader macros and a meta-object protocol upon the object system is built with. More specifically, Perl has advanced features with which meta-object protocols can be built with. See Class::MOP on which Moose is built. > That is an example of what the OP is saying with Perl is an extensible language. I think the difficulty with Ruby and Python is that both are fully object-oriented, which means it is difficult to create something that is truly orthogonal to the object model.
- marcosdumay 13y agoPython is not fully object-oriented.
- rat87 13y agoIn what way?
- systems 13y agohow does Perl have reader macros, can you please point to a link if possible? i couldnt find this one simply searching online
- einhverfr 13y ago> Python and Ruby both have a much cleaner syntax Cleaner syntax than the declarative class mentioned in the article? > Since everything positive about Perl is also offered by alternative languages today, and those alternatives are themselves much better than Perl in some respects, Perl seems like a less and less enticing option each day. To my mind though the benefit is in mutability of the language. Yes, there are other languages in this category (rebol, red, lisp), Perl is somewhere between these and Python and Ruby. If I were to order them from most mutable to least, I would go lisp, rebol, red, perl, (python and ruby). This is a powerful thing and of course with great power comes the possibility of misuse.
- kamaal 13y ago>>But is that really unique to Perl these days? Yes. Scripting powers of Perl are unmatched. >>It may have been true in the mid-1990s, but things have changed since then. Hardly anything has changed. No language has taken scripting that seriously. You are likely confused between dynamic languages and scripting langauges. There is a big difference. If you haven't noticed, well then that's the whole point behind Perl. You really need to use it to see what it is. >>Python and Ruby both have a much cleaner syntax Its not about having a cleaner syntax. Making it easy to learn, only means the complexity is left to the programmer to handle now. Either way some one needs to handle the complexity, Its either the programmer or the language. If you make the language simpler, the complexity burden shifts to the programmer. >>yet still offer very comparable functionality, excellent portability, ample standard and third-party libraries, excellent documentation, supportive communities, great regex support, and basically everything else that Perl offers. Python takes great care to purposefully avoid offering every thing that Perl offers. >>Since everything positive about Perl is also offered by alternative languages today, and those alternatives are themselves much better than Perl in some respects You will have to substantiate that point with some evidence. >>Perl seems like a less and less enticing option each day. That is being told since what? 1988?
- danellis 13y ago> Yes. Scripting powers of Perl are unmatched. Can you offer any examples of how that is true?
- kamaal 13y agoThere is monumental material on this in sites like Perlmonks. I started writing a detailed reply, but half way down I realized it might become a booklet project[Which is a very good project idea by the way] I also realized I may not be able to justice to 3 decades of Perl history in one HN comment. So the best I can do is point you out to two links. http://hop.perl.plover.com/ http://hop.perl.plover.com/ and http://onyxneon.com/books/modern_perl/ http://onyxneon.com/books/modern_perl/
- skrebbel 13y ago
- davvid 13y agobasically everything else that Perl offers ...except for performance. The GIL is Python's achilles heel; if you throw threads at the problem Python gets slower while Perl actually uses all your cores. C.f. http://yaketyhack.blogspot.com/2010/07/threading-perl-vs-python.html http://yaketyhack.blogspot.com/2010/07/threading-perl-vs-pyt... BTW, I love Python.
- kbenson 13y agoPfft, that guy obviously doesn't know how to use code blocks. :D
- otterley 13y agoAlso, a good debugger. Perl's debugger is still far, far better than Python's or Ruby's.
- collyw 13y agoIs it? I generally use a graphical debugger in Eclipse. I have used Python and Perl, and can't see too much difference between them. Whats better about the Perl one?
- mst 13y agoEvery time I try and write python or ruby I get an hour or so in and find that I'm writing 5x as much code as I would in Moo/Moose just to express the object design I want. I've been known to say "perl5 is a lot like ruby except with usable OO" and it's very much a "ha ha only serious" sort of comment.
- smoyer 13y agoI used to sell software to very large corporations, and for enterprise-wide deployment. You won't sell them anything written in Perl, nor will you find them automating systems with it (there are domain specific languages for performing OAM&P on large numbers of systems. If you want "no questions asked" in this environment, you need to pick Java ... and as of JavaEE6/7, it's a much more efficient language. Granted that it's not as dense as Perl, but it's also type-safe and with good conventions, readable. If you're developing SaaS, use what you're most productive with (assuming you're not productive simply because you're creating crap). I've see people who can write in beautiful Perl, and I have no problem reading it. I've also seen people who write whole programs on one line just because they can ... and a couple months later, they can't read it either. Note that I've also seen bad Java, Python, etc programming.
- einhverfr 13y ago> Granted that it's not as dense as Perl, but it's also type-safe and with good conventions, readable. The argument for Java is that there is a wide developer base, and lots of libraries. Perl, with appropriate frameworks, can be remarkably typesafe too (see Moose, etc). It's still loosely typed under the surface, but you have good error handling of invalid type syntaxes as long as you don't break encapsulation. The big things I am looking at though are: 1. Maintenance and testing. 2. Readability You can write unreadable crap in any language. What Perl excels at is allowing you to improve readability and maintenance/testing by building mini-dsl's in your framework which reduce testing footprints.
- narrator 13y agoIt's really hard to write unreadable crap in Java. Even if you do, there's automated refactoring to fix it. That's the thing about Java. It makes it really hard for clever bad programmers to do a lot of damage to a project. With Perl the sky's the limit.
- einhverfr 13y agoAs long as function and variable names are arbitrary, you can write code that appears to do one thing and does something else. Far more damage can be done that way than by straight obfuscation.
- logicallee 13y agoparsing text files is literally the only thing Perl is the best tool for. Of course, every single person who needs to update it would have a 20 hour RTFM session before they could do so. (fairly conservative; this is 3 hours per day for 7 days from a standing start to maintaining Perl.) Perl has a ton of context, and that context is really hard to learn (just try writing a Perl parser/interpreter), and it applies best to text files and configuration scripts from 1987-1997. I am not saying it's not an appropriate tool for anything else. But as a tool to be learnt, it wouldn't be the 'best' tool for a new person to learn from scratch. Except for parsing text files :)
- heeen 13y agoperl unicode support is actually pretty good http://dheeb.files.wordpress.com/2011/07/gbu.pdf http://dheeb.files.wordpress.com/2011/07/gbu.pdf
- logicallee 13y agoupdated to remove refernece to unicode. the additional context involved with knowing Perl isn't enough IMHO to learn Perl just to parse text. I would do that with a 'more popular' language and its regex library, especially for new users.
- einhverfr 13y agoCareful though. There's a lot of parsing that folks want to use regexps for that don't do that well. Why Perl really shines for text file parsing is that you have a fairly large set of tools as appropriate, which fall into largely three categories: 1. regexps (great for some things, lousy for others. DO NOT use these for parsing HTML) 2. Recursive descent parsers. You could write an HTML parser in one of these if you need to. 3. Dedicated format parsers (CSV, XML, JSON, etc). It's the combination of the three that makes Perl a very good tool for parsing text files. One thing going for Perl is a strong community of people who can help point people to the right tool for the right job. For example, I am in the process of writing a library to do PostgreSQL tuple parsing and serialization. It is sort of like Text::CSV with some differences. In this case, regexps are the right tool. But if I was writing something else, I would probably go with recursive descent.
- lazyjones 13y ago> Also, it's not hard for a developper worth its salt to get productive in perl. Unfortunately, it's productivity gained at a very high cost, which becomes apparent once you try to debug and maintain that piece of software. Sure, Moose and other modern helpers will fix that to some extent, sometimes with other tradeoffs (performance). But the "malleability" of Perl feels silly at some point where you get a bloated, slow and lacking simulation of a type-safe language when you could use a much faster modern language with real static type checks and great maintainability (like Go) instead.
- BugBrother 13y ago>> [Perl is unmaintainable] You need coding standards for all languages. Most (afaik) Perl shops use Conway's "Perl Best Practices" with some local changes. Go read "Modern Perl" etc. Are you not aware of those developments? PBP isn't exactly new. I don't think there are references of these problems while following good practices? Considering all the trolls which show up when Perl is mentioned, I ought to have seen such a link a long time ago... But sure, we could assume without support (I don't know) that using Perl forces you to read a few more pages of coding standards. That is, as percentage of work time over a long project, not a problem. >> [Go preaching] Today, I don't see much practical difference among the usual scripting languages (they tend to port the successful stuff from each others). Also their niches are partly different compared to the niches for Go. So there is no need to preach. One big advantage with Perl is that I am not often embarrassed by fan boys and/or language war fanatics, as you find in some other environments... Edit: Readability.
- reality_czech 13y agoWhat's the point of programming in a language that has 100 ways to do something, and then banning all but 99 of them? Why would you use a language if you don't agree that the designers did a good job? That's like going to a burger joint and ordering a salad. Only someone hell-bent on maintaining an emotional connection to a worn-out old programming language, would even consider that. I've never seen a project that could enforce its coding standards in every case. Things always slipped through. Turns out, machines are much better at enforcing arbitrary coding standards than humans. Maybe we should let the machines do the machines' job, and the humans do the humans' job. Perl has all the problems of an old language. No commonly-agreed on coding style (you'll get flamed to a crisp in some parts for even talking about Modern Perl), no single object framework (Moose, Class::Accessor, Object::Tiny, Role::Tiny, and plain old "inside out object." References are confusing and unnecessary (neither Python nor Ruby needed to make an artifical distinction between references and non-references). All the various different ways that things can fail at runtime are a huge burden, especially when you combine them with the different modes that perl itself can be run in, like "use strict" versus not. Just about the only thing Perl did right was regular expressions. That, and avoiding the version hell that Python got itself into. Perl was fun in the early 90s, but it's time to let go. Only a masochist would use it today. Only a sadist would recommend it to newcomers.
- Sukotto 13y agoIf you're looking to expand your perl repertoire into functional programming, you might want to check out Higher Order Perl by Mark Dominus You can get it in dead tree from amazon or free (beer) from the author's website http://hop.perl.plover.com/ http://hop.perl.plover.com/