8 ms·
I'm amazed that Perl is still around. I personally find it the least readable language that I've ever used, and that includes a lot of languages. But some peopl
by Upvoter33 7y ago
I'm amazed that Perl is still around. I personally find it the least readable language that I've ever used, and that includes a lot of languages. But some people really seem to love it, for reasons a bit beyond me.
- theonemind 7y agoI find programming perl fun inversely to program size and proportionally to the need to slice and dice text. I didn't learn perl until the perl 5 era, but from what I can tell, I would've been as satisfied with perl 4, before they bolted on OO and tried to expand the applicable problem domain of the language. I mostly just use it as a super-charged awk and bash replacement for scripting.
- tyingq 7y agoThe bolted on OO is really just one new function...bless(). The rest is package namespaces, which are also used for non OO purposes. I'm never sure what people don't like about OO Perl. There's a tiny bit of boilerplate in a constructor, other than that, it doesn't seem different from other OO script languages.
- kbenson 7y agoAgreed. Not to mention, from what I understand they just borrowed the OO system from Python, so it shouldn't be that foreign to most people.
- hnick 7y agoIt's not terrible to get working, but for many people a major point of OO is encapsulation and it doesn't work out of the box like that. You have to install another package or use the inside-out object model to prevent direct access to package variables and 'private' functions are usually by naming convention only. It's just another example of Perl's biggest strength and weakness. Total freedom to build something amazing or shoot yourself in the foot.
- jlokier 7y agoPython and Perl have almost exactly the same OO model, yet many people quite like Python's OO, so that can't be it surely... There's no private data or private methods in Python objects. All the properties are right there for anyone to read, protected only by convention. JavaScript and Perl have almost exactly the same OO model, yet many people quite like JavaScript's OO, so that can't be it, surely... There's no private data or private methods in JavaScript objects. All the properties are right there for anyone to read, protected only by convention. (It's closer than it looks. Perl's "bless" function means almost the same as JavaScript's ".__proto__ =", and inside-out data hiding is possible in JavaScript much the same as Perl, although hardly anyone uses it in either language.)
- hnick 7y agoI'm not necessarily a fan of the OO in those either :) I try to use OO sparingly when possible, and in Perl that generally just means I've been using a hash and decide it'd be more convenient that it keep some functions to itself rather than pass it around to other functions. I will say in Perl's defense, the bare implementation really made me appreciate what OO actually is under the hood. I felt like I understood it much better, especially since it takes a mixed approach (rather than 'everything must be an object, including Program.cs' which I never really enjoyed).
- Grinnz 7y agoIt does make it very clear that it is just a data structure (state) associated with a class (behavior).
- tyingq 7y agoIt's also pretty neat that you can bless any type as an object. People use the hash most often for obvious reasons, but you can use a scalar/string, array, etc, if you wish.
- tyingq 7y agoThat's fair, though as mentioned, not much different from other scripting languages with OO. The _private convention seems to work ok in practice, if not in theory.
- deleted 7y ago[deleted]
- Shoop 7y agoEven if you never want to write any Perl code, I definitely recommend checking out some of the features of Raku. As someone who is interested in language design but never has (or likely will) use Perl for a project, I still found reading about Raku's feature set super interesting. Here's a whimsical slide deck that introduces a lot of the most interesting features: [0]. Even if you find yourself shaking your head at all the craziness, you at least have to admire Raku's success at fulfilling its goals of being a post-modern language optimized for fun (-Ofun). [0] http://tpm2016.zoffix.com/#/ http://tpm2016.zoffix.com/#/
- pmoriarty 7y agoHow familiar are you with Perl, and how much have you used it? Most of the anti-Perl comments I've heard have been from people who really didn't know it very well, if at all. Some of them might have glanced at some Perl code and saw a dense regex and dismissed it as "line noise". Well, yeah, if you don't know regexes you would be forgiven for thinking it was line noise, but if you did know regexes it should look no more like line noise than a similarly dense regex in any other language. For a long time now, Perl has allowed regexes to be commented. Commenting dense regexes and splitting them up in to short regexes assigned to judiciously named variables is just good style in any language, and has been the norm in Perl for a long time. Furthermore, modern Perl style guidelines advise code to be written with verbose, English words instead of ancient Perl one-character special variable names. So setting aside both dense, uncommented regexes and ancient single-letter special variable names, both of which have been recognized as poor style in Perl for decades now, I'm really not sure what the complaints about Perl readability are about. To me it looks really no uglier than any other mainstream language, and one could easily make the argument that any other mainstream language you care to name is uglier in some of its own ways. If you include non-mainstream languages, some languages which have a lot of fans here on HN are arguably a lot less readable than Perl to someone only familiar with traditional Algol-style languages. In particular, I'm thinking of Forth and Haskell. Yet you rarely hear complaints on here about their readability.
- lilSebastian 7y ago> Most of the anti-Perl comments I've heard have been from people who really didn't know it very well, if at all. Indeed, I hope this thread gets picked up by http://n-gate.com/ http://n-gate.com/
- AlexCoventry 7y agoYou are violating the prime directive. http://n-gate.com/hackernews/2017/08/22/0/ http://n-gate.com/hackernews/2017/08/22/0/
- j9461701 7y ago>How familiar are you with Perl, and how much have you used it? It's what my company's entire code base is written in. So every hour of every work day for the past 6 months. >To me it looks really no uglier than any other mainstream language, and one could easily make the argument that any other mainstream language you care to name is uglier in some of its own ways. It's no one thing, but a bunch of little things that compound on top of each other. Until you get something like this: while (<>) { ($h{$_}++ == 1) && push (@outputarray, $_); }; Mostly though it's how it's used. It can technically do anything, so a lot of the times it is asked to do everything. Until one day you wake up to find you have hundreds of perl files, all tens of thousands of lines long, that all interconnect in an insane Object Oriented hierarchy soup stretching across every conceivable programming space - from database control to money processing to security to web site design.
- eruci 7y agoJust because you can't read it, is not a good reason to hate it. But, as Larry says, "It is better to be hated by those who don't know you, than by those who do"
- WheelsAtLarge 7y agoTrue, it's very easy to make your code unreadable but other languages have the same drawback too. I would never pick it as the language for team projects. But with Perl you can really pack a lot of power into each line of code. It's hard to beat for scripting.
- cutler 7y agoI love Perl - the syntax, community, Larry Wall's writings and The Monastery. Occupationally I'm forced to write Ruby for a living these days but Perl's influence is there and enhances my appreciation or Ruby. I came into programming after reading in the Dreaweaver Bible that you could extend the search facility with regular expressions. Jeffrey Friedl's monumental Mastering Regular Expressions was listed for further reference and I was hooked. Perl was the natural language to learn if you were inspired by regexen and wanted to create dynamic websites back in the early 2000s so I sought-out Larry Wall's Programming Perl. That book is such a joy to read. I still dip into it today just for the quality of the writing ... and a little nostalgia. Take time to really grok Perl and you may find the soundbite swipes at Perl don't make sense any longer.
- h1d 7y agoSeems you've never used shell scripting.
- takeda 7y agoPerl gets a lot of flak, I am no fan of it, but frankly the least readable language IMO is bash.
- GuB-42 7y agoI also find it one of the least readable language. Or more precisely, the language that requires the most effort to be made readable. Every language can be made unreadable. But it is also one of the most writable language. In Perl, for most problems, there is a quick and dirty way of addressing it. It is especially true when it comes to processing text files, the thing that Perl is best known for. Many languages try to be clean and consistent, it is obviously good for readability, but it means that choices have to be made. Sometimes the best way is the "wrong" way and you have to fight against the language. Perl solved that problem by not having a "wrong" way of doing things, screw cleanliness and consistency. Also, first class regex are awesome for quick and dirty text processing.