4 ms·
There are so many stories from people that used Perl long ago but have since moved on to better languages. My story is the opposite. I tried Perl ages ago and c
by bachmeier 6y ago
There are so many stories from people that used Perl long ago but have since moved on to better languages. My story is the opposite. I tried Perl ages ago and couldn't understand why anyone would use it for anything. A couple years ago I decided to give it a try (it was the best fit for unimportant reasons). What I found was a solid language that was great for working with text, highly performant, a good replacement for Bash, and everything just worked so easily, including CPAN packages.
A few days ago, I returned to modify something I wrote last year. I was surprised at how easy it was to read and understand the code. The $ and @ that folks complain about are pretty handy tools to convey what the variable holds. Though I won't be moving most of my code to Perl, I think it's great for what it was originally intended to do.
- cogman10 6y agoPerl is great because it makes text processing and CLI tool development really stupid simple. The language was built for that sort of thing. Perl suffers for the same reason. It's early prioritization of text manipulation makes it not great at general purpose programming.
- bachmeier 6y ago> It's early prioritization of text manipulation makes it not great at general purpose programming. Exactly, and that's where I went wrong the first time I looked at Perl. You can tell the language was designed by someone that knew a lot about text manipulation. That means it's really good at solving those problems. Unfortunately I wasn't using it for text manipulation at that time.
- wott 6y ago> The $ and @ that folks complain about are pretty handy tools to convey what the variable holds. It doesn't convey much. $scalar or @array, that's all. An array is always an array of scalars. Scalar can be almost anything: any kind of number, a string, a reference (often a reference to... an array or a hash, since you can't have arrays of arrays or array of hashes, only arrays of scalars).
- bachmeier 6y ago> It doesn't convey much. $scalar or @array, that's all. It's useful when you have a healthy mix of arrays and scalars scattered throughout your code. Static typing would be better, but $ and @ are better than tracking the information manually.
- bmn__ 6y ago> It doesn't convey much. $scalar or @array, that's all. You're vastly underinformed. It conveys the mode of access. It shows at one glance if the expression is singular or list or pairs. … of an array … of a hash the whole @a %h one particular $a[0] $h{foo} values slice @a[5,3,7] @h{qw(bar foo quux)} key/value pairs %a[5,3,7] %h{qw(bar foo quux)}
- wvenable 6y agoI have the opposite experience to you; I was required to use Perl ages ago and built enough software in it to actually like it. I understand why some people are big Perl lovers. But of all the programming languages that I know (and it's a long list) Perl is the only one that I can't just jump back into. I've forgotten all the esoteric things about it. Unlike most languages, you can't get far in Perl without knowing those esoteric things.
- citrin_ru 6y ago> people that used Perl long ago but have since moved on to better languages For tasks where Perl is a good fit I moved to Python, but cannot say that it is better (or worse). It is much more fashionable, which is an advantage on its own though - more people will be able to read code written in Python, there are more libraries which are actively maintained. Many years ago I used Pascal and now work with software written in C. In my opinion Pascal is much better language than C, but Pascal is mostly the thing of the past and C is still very much alive. Sometimes we have to move to languages which are worse or at best - not much better.
- erik_seaberg 6y agoPython has safer defaults. If you want lexical scoping, or errors when you make mistakes, you have to ask for it in Perl.
- harry8 6y agoIf perl had use strict; and -w (warnings enabled) by default so that you had to switch them off if you didn't want them I doubt python would have gained such traction as being "easier" and "more readable." The power of perl would have been better tempered by some responsibility. I liked perl and kinda miss it sometimes but I guess I'm not too unhappy about moving to python. Python is fine. I am pleased to find out how wrong I was about significant whitespace. Having the shape of the code reflecting its content and meaning is actually a great thing. You can think, this shape looks (un)pleasant before understanding the code in detail. Better yet is never, ever having yet another goddamn argument in a team meeting about python bracing style. Python's success makes it impossible to argue that people won't accept a mandatory indenting policy as part of the semantics of the language anymore. It's an open choice for all future languages to adopt if they deem it worthwhile, not refuse to entertain because "the users will revolt." With Perl's demise we still wait for the lisp of mass appeal for all perl as a lisp lacked uniform syntax.
- rswail 6y agoDo you use 2 spaces or 4 or 8 to indent? Leading tabs or spaces? /s
- hnick 6y agoThe sigils are very useful in a language which doesn't play well with IDEs. They're redundant for something like C# but Perl has always struggled with IDEs and is notoriously resistant to static analysis so even good ones will have gaps. I personally have never enjoyed using one with Perl. It does get a bit messy with coercion like (%{$hash->{$key}}) but I believe recent versions have made that a little nicer. I'm stuck on a decade old one though.
- eythian 6y agoYep, in a newer perl you can say: $hash->{$key}->%* to do the same thing. And you can replace the * with stuff to do slicing or whatever if you like.