9 ms·
Half My Life with Perl
- kamaal 2y agoPerl is one of those power tools(as recommended in Let Over Lambda, together with vim and Lisp), if you learn it well enough to be good at it, and early enough in your career- You really have a mad productivity work horse. Its really one of those things which save tons of time and effort. A bit like O(1) hack of the productivity world. Perhaps at the core of this just how many what we called regular programming tasks are just knowing how to work with text and unixy operating system. Perl is just unbelievably awesome at this. Another big edge of Perl is commitment to backwards compatibility, most people who learned Perl early in their careers decades back can use it on-demand basis. Its universally installed, fast and scripts written from the earliest days continue to run with 0 changes, despite endless OS upgrades. Early enough in the timeline Perl was full unix hackers, and you learned a lot from them, this culture further bolsters Perl's productivity credentials. Not a week passes, that I have to whip up a Perl script to do something for someone has a 2 people and a month budget to do. And they are often amazed it can be done this quickly. CPAN is another big edge Perl has. No other language apart from JS/npm ecosystem has anything close, and these are basically competing in very different domains so to that end CPAN really doesn't have a competition till date. If you are looking to build using Perl do checkout the Camel book and HOP by mjd.
- alfiedotwtf 2y agoSadly I think Node and Python have long taken over CPAN. But apart from that, I was nodding through your whole comment… Perl really is a super power. POSIX at your fingertips!
- kamaal 2y agoNode/NPM definitely is on-par with CPAN. But pip isn't even close. The real deal with Perl is you not only get bleeding stuff, you get all kind of obscure and rare libraries. Its not that you can't do that in Python. Its just that the culture in Python world isn't made up of people who think about those problems or even in that dimension. Its a great language for writing all variety of apps. Perl is the og hacker's language. Python is awesome too, but its not really what Perl is. Most of the bad rep Perl gets is because programmers who only interact with http endpoints and databases tend to not understand where else it could be useful. Like even the regexes. They sound like a pain, until you have to do non trivial string manipulation tasks. Then you discover, regexes do it a lot better than cutting and slicing strings some 100s of times.
- canvascritic 2y agoI'll be frank: I think this idea that ${faveLang} is for misunderstood geniuses who truly understand computers where mainstream languages like Python are for dunces who only know how to glue together APIs is a large part of why such languages as Perl are nearing extinction. It turns out that there are people working on challenging problems in domains you've never heard of in Python -- and pretty much every other language. Give it a rest In the real world, the ability of a lone genius to cobble together a script in an hour is actually not that much of an edge -- it is more important for people to write something that others can understand and maintain. If you can do that in Perl, great, and if writing Perl makes you happy: also great. But beware that smug elitism turns people off, it kills communities and also tends to signal a pathological inversion of priorities. All this should be in service to people, after all
- kamaal 2y ago>>In the real world, the ability of a lone genius to cobble together a script in an hour is actually not that much of an edge Any macro/multiplier is that way. You don't miss it, until some one shows you how to do it. In the last six months alone the scenarios where I had to call upon Perl to help slam dunk a thing insanely laborious are dozens in number. Its just that if you don't know this, or don't know it exists, you grow up being comfortable doing manual work with comfort. Sheer amount of times, I have seen some one spend like half a day doing things which can be done using a vim macro in like seconds is beyond counting at this point.
- stouset 2y agoThe superpower here is a scripting language, not Perl specifically.
- kamaal 2y agoSometimes a language/tool gets to evolve with the operating system right at their birth. The relationship with between Unix, vim, and Perl is that way. This is a unique combination, which I don't think will ever change. Unless of course we move away from Unixy operating systems to something entire new.
- liontwist 2y agoI’m into lisp and vim. I did one small project with Perl but wasn’t excited. I was hoping for bash 2.0 but the shell integration wasn’t great. Seems like python is a similar feature set, less exotic, and has great libraries. Anyway? What did I miss? anything I should take a second look at?
- dartos 2y agoRaku is basically perl 6 and has some features that blew my mind when I tried it a few years back. Never really did much with it, but it was enjoyable to learn.
- kjs3 2y agoThis encapsulates every conversation I have ever had with someone who tried Perl 6: Tried it, was blown away with [some aspect of it], never found anything practical to do with it, never used it again.
- RandalSchwartz 2y agoI think I even reference that in the talk... Dart is everything I wanted from Perl 6, which is why I'm happy to be coding in Dart now.
- kqr 2y agoIf you're into Lisp you're probably not missing that much. The main reason I use Perl over Lisp is that Perl is preinstalled nearly everywhere, whereas Lisp is not.
- BoingBoomTschak 2y agoYou should really look at Tcl if coming from Lisp and wanting a bash successor. Tcl (8.5) is also preinstalled on MacOS.
- dismalaf 2y agoJust curious, what does Perl give you over Ruby if anything? I learned Ruby first, always heard it was strongly inspired by Perl (as well as Smalltalk), and it provides all the benefits you mentioned, I think.
- kamaal 2y agoMostly because Ruby isn't as ubiquitous and its not closer to C, the way Perl is. Ruby really is competing with Python in problem domain space not Perl.
- stouset 2y agoFrankly nothing. Ruby is a strict improvement over Perl in almost every way. I cut my teeth on Perl and I still remember it fondly. But there is no reason to learn Perl (5) over Ruby. Maybe Perl 6 is a different story though.
- RandalSchwartz 2y agoI believe Perl got Unicode to a usable state long before Ruby. Ironic, given Ruby's origins.
- deleted 2y ago[deleted]
- stakhanov 2y agoIt's not a race. Perl got there fast by basically not giving a damn about anything. Perl (talking about Perl 5, don't know anything about Raku, don't want to know anything about Raku) simply treats strings as sequences of numbers without requiring numbers to be in the 8-bit range. This makes it easy to say that those numbers could in principle be Unicode codepoints. The problem is that the actual assumptions about what those numbers represent are implicit in programmers' minds, and not explicit in the language, much less enforced in any way. The assumptions shift as strings are passed between different libraries, and sometimes different programmers working on the same codebases have different ideas. Perl will happily do things like encode an already-encoded string, or decode an already-decoded string, or concatenate an encoded string with an unencoded string, or reverse a utf-8 string by reversing the encoded byte sequence, etc. etc. So it's easier in Perl than in any other language I've ever used to end up with byte salad. It'll take you, let's say, the first few years of your Perl career, involving painstaking testing of everything you do with nontrivial characters, to truly grok all of that. But the problem is: You're not alone in the world. If you work on a nontrivially-sized project in the real world that heavily utilizes Perl, then byte-salad will be what you will get as input. And byte-salad will be what you will produce as output. It is frustrating as hell. Unicode was a pretty painful matter in the transition from Python 2 to Python 3, but Python's approach means that the Python ecosystem is now pretty usable with Unicode. This is not the case with Perl at all.
- jjav 2y ago> You really have a mad productivity work horse. I'm not aware of anything that can be as effective at text processing as perl. While I don't do much perl anymore, if I have to wrangle text files in all kinds of ways, there is no comparison, perl rules.
- BiteCode_dev 2y agoYou don't need to learn it now anymore. LLM do Perl well enough, and since 90% of productivity with Perl is earned through small snippets or one-liners (anything bigger is better served with uv init --script), you can just ask the bit you want when you need it. You can even ask the AI to explain the hieroglyphs. Same with bash, awk or powershell.
- creer 2y agoKeep Higher Order Perl for later. It's great but far too much for a 2nd book when getting started. The camel book Programming Perl is still a great start which adheres to the layered aspect. Don't read all of it, just a few parts as needed. I recommend to add Perl Cookbook early, to look things up as you go - it gives idiomatic-ish ideas of how you might do X in Perl. Perl comes with a mountain of very complete and useful man pages: you start with looking things up in the camel book, then transition to looking them up in the man pages.
- classichasclass 2y agoI learned Perl 4.036 for a university course (computational linguistics, appropriately enough) in 1996. That's ... more than half my life away.
- wodenokoto 2y agoI’m about to turn 40 and have been thinking if I should learn Perl or AWK or go with a “modern” solution for text wrangling on the command line. The general advice here seems to be “learn Perl while young”
- kamaal 2y agoPerl is a super set of all things. So go with Perl. >>The general advice here seems to be “learn Perl while young” Best time to a plant a tree was 20 years back, Next best time is now. - A Chinese Saying.
- treve 2y agoOn the origin of that phrase: https://english.stackexchange.com/questions/603690/origins-of-the-phrase-the-best-time-to-plant-a-tree-was-30-years-ago-the-secon https://english.stackexchange.com/questions/603690/origins-o... Seems like it _may_ not be Chinese. I've often seen it attributed as Chinese. Funny how that sticks.
- edoceo 2y agoI thought it was Uncle Iroh.
- wruza 2y agoPerl was 1 line vs. 100 lines in everything else, in text processing. Now it is 1 line vs. 2-3 lines that are clearer and have stricter semantics. It also has support for running oneliners straight from cli. You probably don’t want to learn it today, as it won’t make that big of a difference.
- wodenokoto 2y agoWhat's the 2-3 line alternative to perl you are referring to? I find piping into python to be a lot more than 2-3 lines before I'm even ready to do any manipulation of input, which again can get quite verbose. So I'm guessing it is not python.
- romanobro56 2y agoI can relate, I learned Perl when I was three and now I’m six.
- temporallobe 2y agoPerl is my first love, and I still whip it out from time to time to do system tasks (anything in the linux world). It is literally installed on any *nix OS, macOS included. Python is fine, but it’s not as universal as Perl. I also feel like Perl is more “batteries included” as many times I can be productive without “use”ing any libraries. It’s has been my secret weapon over the years. I’ve also noticed that most younger engineers don’t know it, and if they know any scripting language at all, it’s of course python.
- kqr 2y agoIndeed. As a younger engineer I learned Perl during a brief stint as manager (because I didn't have time to do real programming, but I still needed to automate things). I have no regrets. It is one of the most useful languages I know, transcending what I do for a living.
- znpy 2y agoMy experience with Perl is that often the batteries are rotting. Not a strong opinion though, i haven’t been writing perl in a while.
- ykonstant 2y agoCan you give a specific example?
- doublerabbit 2y agoI can't recall what modules my boss created but he had heart attack and passed away. So his modules are now left unmaintained. Fortunately, new version realises of perl don't break CPAN modules that much. But there have been a decrease and of programmers that have either moved on or are passing away. Without a younger audience not to maintain they're left to rot. Python will encounter the same when a new language hits the block in years to come.
- pkphilip 2y ago
- wruza 2y agoTbh, for me it was a source of regex knowledge, in retrospect. Remove regexes from perl, what’s left? I can name: dynamic scoping, implicit filehandles, implicit $_, strange contexts, keyword-like list functions. That’s basically it, and while it sounds fun, it doesn’t do much in a sense of code reduction. $. $? $$ etc, well you can split lines with .split('\n'), get status as a part of result, call os.getpid(). <>, you can open() or createReadStream(). $_ is just a kids toy. “print if /…/“. Cool. Lots of global modes under dynamic scoping is questionable. Value semantics and corresponding sigils are horrible, really. Bless is ugh. Subs are meh. It’s all just regex. Add regex as a language construct and you get the power of perl in it. /…/.test(s), s.match(/…/), s.replace(/…/, '$&') that’s 90% of Perl. Regex saves most lines of code, everything else is just esoteric extra that doesn’t do much. Also no GC.
- akoboldfrying 2y agoI use Perl for one-liners all the time -- nothing can top it there. But when the task at hand grows just slightly bigger, to the point where I know I'll need to pass filehandles to/from my own functions, my skin starts to literally itch because of how bad the filehandle situation is. It's not plain "open F, ..." any more... Is it "*F"? Is it "\*F"? Are those the same thing? (What the hell is a "typeglob"?) Wait, can't I just use "open my $f" and everything works the way it obviously should? Well, kinda, unless you want to be able to store an existing filehandle like STDIN in there, then you have to do something different again... Do I need IO::Handle instead? (Why does that need to exist...?)
- deleted 2y ago[deleted]
- mst 2y agoPlain perl: open my $fh, '<', $filename or die "Couldn't open ${filename}: $!"; Nicer: use File::Open qw(fopen); ... my $fh = fopen $filename; (and File::Open is simple pure perl code so if I need to distribute the script to random machines I throw App::FatPacker at it to produce a bundled version)
- jwilk 2y agoDirect link to the talk: https://www.youtube.com/watch?v=fffJnNTcLog https://www.youtube.com/watch?v=fffJnNTcLog
- oniony 2y agoMy first experience with Perl was back in 1999. I was fresh out of university working at a dot-com start-up web agency and was asked to take ownership of a project after the developer had left the company. It was pretty straightforward CGI project, with some functions that aligned one-to-one with the database tables. Quite clean code. I made the changes I needed to make easily enough for the first couple of bug fixes or features. But then I had to change the code behind a different database table and the function that backed it did not exist in the codebase. I found the code that called the function, but the function definition itself was nowhere. I was literally stumped and spent hours thinking our versioning system (Source Safe) had failed, or that I had been given the wrong codebase or that there was some library being called into, to no avail. (We were using TextPad back then, no IDE.) And then I found it: AUTOLOAD. If you're not familiar, if you call a function that does not exist in Perl, then Perl will call a sub-routine called AUTOLOAD if you define one. In there you can do whatever you want and the developer who had written this particular system was parsing the function name to identify the database table and fields. So something like `set_customer_name` would set the `name` column of the `customer` table. It was both genius and horrifying.
- bruce343434 2y agoA procedural/imperative ORM, quite neat actually
- pif 2y ago> It was both genius and horrifying. No, it was just stupid and horrifying. Something like `set_db("customer", "name")` would have yielded the same functionality with no obfuscation.
- tyingq 2y agoPython has import hooks, which you can use to do the same madness. I imagine many languages have some form of lazy loading to do roughly the same thing. I suppose it's more the culture of the language than the capabilities driving whether someone actually uses something weird like that.
- petesergeant 2y agoI’m 42, and learned Perl at 14. I’ve worked with some very large Perl systems, and love it. Yes, there’s bad Perl, but I’ve never really understood the hate for it. The testing ecosystem and culture and documentation culture are first rate. The tooling like Mojolicious, DBIx::Class, etc are super well done. These days I write TypeScript full-time, which I like, and there’s a lot I miss about Perl, while absolutely loving the types in TS. The few months I spent writing Python professionally didn’t convince me it was any simpler or better than Perl, and I quit that job to go back to writing in TS.
- mst 2y agoI can't cope with python because of the lack of 'use strict' - I continue to be sad that 'explicit is better than implicit' is supposed to be a rule of python except apparently not for variable declarations (also I want block based lexical scoping damnit). With the addition of 'let' - which to my brain is just "how javascript decided to spell 'my'" - I'm actually really quite enjoying it. (and the javascript proposal for 'match' is written expecting the proposal for 'do BLOCK' to happen, and 'do BLOCK' is going to make me a _very_ happy mst)
- pjmlp 2y agoDespite being famous for being a cryptic language, in most cases in UNIX world, the safest way to code was to do userspace stuff in Perl, and only if it really mattered, rewrite in C. This was more approachable in Perl, than Tcl or later Python, as Perl does expose most of UNIX API on its standard library in a more C like fashion. My Perl 5 camel book got a fair use back in the day.
- deleted 2y ago[deleted]
- dmd 2y agoMy then-girlfriend and I, kicking it O'Reilly style, 1996: https://i.imgur.com/PPmZs9P.jpeg https://i.imgur.com/PPmZs9P.jpeg
- kjs3 2y agoNerdy, and sweet. I needed something positive this morning.
- RandalSchwartz 2y agoI had quite a few of those animal shirts, along with many Stonehenge party shirts. Gave most of them away since I wear collared shirts now that I'm a grown-up.
- replwoacause 2y agoAny good reasons not to build web apps and API backends with Perl these days?
- BiteCode_dev 2y agoThe ecosystem of PHP/Ruby/Python is miles ahead so if you need anything ranging from auth to validation, you will have to do 10 times the work. In fact, even modern JS frameworks with features that have no equivalent in Laravel/RoR/Django see their appeal diminished because those old school frameworks do the basic so well they are productivity cheat code for essentials. It's so easy to find people delighting in beautiful hot reload yet struggling for days making Oauth work or having to pay a saas for image resizing while 20 years old tech have that part nailed down.
- oalders 2y agoThe Mojolicious framework can do a lot of heavy lifting for you. It's not that hard to do interesting things while writing minimal code: https://www.mojolicious.org/ https://www.mojolicious.org/
- BiteCode_dev 2y agoThat's actually making my point, this is riduculously limited compared to the tools I mentioned. Django's admin alone is richer in feature than this whole framework.
- renewedrebecca 2y agoIt's not fashionable.
- ei8ths 2y agoUse what you are comfortable with, I write Perl backends in Mojolicious, its great.
- weare138 2y agoI do. I've worked with other languages over the years but I always come back to Perl. There's a few good options for web apps/APIs. Web frameworks: https://www.dancer.pm https://www.dancer.pm https://mojolicious.org https://mojolicious.org http://catalyst.perl.org http://catalyst.perl.org https://metacpan.org/pod/Kelp https://metacpan.org/pod/Kelp https://metacpan.org/pod/Net::API::REST https://metacpan.org/pod/Net::API::REST Middleware: https://plackperl.org https://plackperl.org https://github.com/miyagawa/Starman https://github.com/miyagawa/Starman Some other useful stuff... OO Frameworks: https://zydeco.toby.ink https://zydeco.toby.ink https://metacpan.org/pod/Moose https://metacpan.org/pod/Moose https://metacpan.org/pod/Moo https://metacpan.org/pod/Moo Type system: https://typetiny.toby.ink https://typetiny.toby.ink https://metacpan.org/pod/Function::Parameters https://metacpan.org/pod/Function::Parameters https://metacpan.org/pod/Function::Return https://metacpan.org/pod/Function::Return Coroutines/multithreading: https://metacpan.org/dist/Coro/view/Coro/Intro.pod https://metacpan.org/dist/Coro/view/Coro/Intro.pod Async: https://metacpan.org/pod/Future https://metacpan.org/pod/Future https://metacpan.org/pod/Promises https://metacpan.org/pod/Promises https://metacpan.org/pod/IO::Async https://metacpan.org/pod/IO::Async https://metacpan.org/pod/AnyEvent https://metacpan.org/pod/AnyEvent https://metacpan.org/pod/EV https://metacpan.org/pod/EV
- dpb001 2y agoBack in the 90’s Perl was about the only scripting platform that gave you access to host commands and info as well as the ability to connect to databases running on that host. Part of bringing up a Solaris host for Oracle always started with a visit to sunfreeware.com to get a version of Perl compatible with the latest DBI/DBD and enhanced email CPAN modules. I abused the backtick feature heavily.
- marcrosoft 2y agoI always think of Randal shwartz when I think of people saying, “I’m an X language programmer”. You don’t want to be the last guy on earth that’s the expert in a dead language.
- bm98 2y agoThat was a great talk! Notice how his entire career got launched from an internship at Tektronix. I love the bit about how he found his own troff macros in use at O'Reilly because a coworker had taken his code there years before -- and he appreciated that! One might say that the same kind of "80's hacker ethic" is what got him into trouble at Intel. The Camel book was so well-written. It was my introduction to Perl, which became my "superpower" in the 90's and far longer into the 2000's than I tend to admit. I eventually switched to Python because it's the closest thing that is considered an acceptable "modern" choice. I really enjoy Python too, but the obligatory XKCD about Python[1] rang true for me about Perl first. For me the #1 superpower strength of both languages is the first-class treatment and syntactic sugar for associative arrays (a.k.a. hashes, dictionaries). Perl did the same for regexes and file I/O; Python did not. I have come to appreciate Perl's backwards compatibility -- that old scripts still run unchanged -- though maybe that's largely because Perl 5 has been in maintenance mode for so long. [1] https://imgs.xkcd.com/comics/python.png https://imgs.xkcd.com/comics/python.png
- creer 2y ago> Perl 5 has been in maintenance mode for so long Perl 5 has been adding features consistently over the years, not just fixing bugs. Many people just ignore the new features, but you don't have to.
- cafard 2y agoI came here to say: not just text processing. Thirty-odd years ago I worked on a government contract supporting users of Data General minicomputers. From time to time we needed to inspect the logs, but the log reading utility was not fast. The log format was thoroughly documented, though, and it proved to be much faster to ship a log over to a Sun box and pick it apart with Perl using unpack.
- mikeInAlaska 2y agoI love perl. I work with it every day still, 25 years later. I recently rewrote a cellular provisioning API in it to be fully object oriented. I do not write it to win an obfuscation contest. I like it to be read as easily as possible. It is a joy to watch the core objects of the system work together so cleanly.
- artemave 2y agoMy brain inadvertently changed the title to My Perl Half Life
- RandalSchwartz 2y agoI reference that in the talk that as I was composing the slide deck, I kept bouncing back to "My Half-life With Perl".