5 ms·
I agree. It is a misconception that Perl is "dying". It powers a lot of the web. It had a bad rep a few years ago due to cryptic-looking codes that were writ
by knighthacker 14y ago
I agree. It is a misconception that Perl is "dying". It powers a lot of the web. It had a bad rep a few years ago due to cryptic-looking codes that were written as a throw away code and somehow spread all over the web :).
I was one of the skeptical developers at some point, but then I got hooked :).
Modern Perl changes the old rep alltogether. I encourage people to write well architected, maintainable, extensible code and follow design patterns regardless of the language of choice.
- ralph 14y agoRegardless of the structure of modern usage its syntax is still very noisy for the reader. It seems the majority prefer the cleaner syntax that doesn't use punctuation to define the type of access a la BASIC.
- jonathansizz 14y agoYes, the sigils can make Perl code look noisy, especially as Perl uses curly braces and semicolons too. However, they do have a couple of nice benefits: firstly, they make variable interpolation easier (and less noisy!) than in other languages like Ruby and Python. Secondly, sigils make it easy to see what kind of data you are dealing with, obviating the need to scroll through your program to the variable declaration.
- thecoffman 14y agoThe sigils make variable interpolation easier only in the most generic case "interpolate $me". Anything more sophisticated requires a temporary variable.
- raiph 14y agoI am not especially enamored of variable interpolation, but for those that are, Perl 6 does a much cleaner job than Perl 5 imo.
- draegtun 14y agoYou can avoid using temporary variables with the @{[...]} and ${\...} idioms: my $x = 1; say "$x + 1 = @{[ $x + 1 ]}"; sub plus1 { $_[0] + 1 } say "$x + 1 = ${\plus1($x)}";
- hobbified 14y agoWell... arguably they make it easier in the half-dozen simplest cases. Which just happen to be what's needed 90% of the time.
- encoderer 14y agoI've not touched Perl aside from modifying and using basic scripts for process automation and administration tasks. But since you called-out Python and Ruby, I'm curious what you meant. In Python, for example, interpolation would look like: print "I ate a %s for %s" % ('banana', 'lunch) (or the newer way with nominally more keystrokes) print "I ate a {0} for {1}".format('banana', 'lunch') I've done plenty of PHP work and I get that I can do "{$varhere}" but for strings of any length or complexity it was totally common to use sprintf() an I have to assume the same readability principles apply in Perl?
- ionforce 14y agoIn Perl you could write print "I ate a $fruit for $meal" Or printf 'I ate a %s for %s', $fruit, $meal
- e12e 14y ago"This is %(adjective)s readable Python in %(genetive)s opinion" % {"adjective":"more", "genetive":"my"} > 'This is more readable Python in my opinion' edit: variable names Also, I agree that for this simple case, perl (and other's) simple dollar substitution is nicer.
- e12e 14y agoSince there was a mention of extending the language in this thread, there's also: http://lfw.org/python/Itpl.html http://lfw.org/python/Itpl.html
- Someone 14y agoHuh? That will tell you wether foo is a hash or not, but not what kind of things it contains. So, as soon as you subscript you $foo or @foo or €foo, you are lost again. A good IDE would be of much more help (and strong typing makes writing such an IDE way easier, but that is a different issue)
- rhizome 14y agoAs a self-trained programmer who cut his chops on Perl, I find it a bit humorous that people complain about reading Perl, while every coding test at a job interview involves some five-way algorithm or other generally-arcane CS concept that CS people spend two years practicing and that the business will never use. Two forms of complexity, one valued much higher within the industry.
- knighthacker 14y ago+1 It is so hard to know that @ means array and % means a hash (key/value pair) haha.
- slurgfest 14y agoIt's not that hard to know the types of the variables you created without punctuation in the identifiers, either.
- prawks 14y ago>you created Agreed. However, working for a company with more than one developer...
- dllthomas 14y agoWell, it's not just the type of the variable but also how you're treating it - world's most concise cast... Also, it means one doesn't have to dodge keywords in naming their variables. Doesn't count for a lot but is nice.
- Ralith 14y agoWho cares about the syntax? The real problem is the weak typing.
- zby 14y agoIt might look noisy - but it is just easier to parse in your head when you know what is a variable and what is a function or a keyword. I have came to believe that much of the 'Perl is ugly' notion comes from the fact that the $ character does not have nice typefaces (http://perlalchemy.blogspot.com/2011/01/is-responsible-for-ugliness-of-perl.html http://perlalchemy.blogspot.com/2011/01/is-responsible-for-u...).
- cafard 14y agoAnd this would be why PHP is so popular?
- jjn1056 14y agoYou know Perl gets hassled because of the variable sigils, but when I've taught Perl to newcomers it didn't seem to be much on an issue. Maybe this is because Modern Perl tends to be more clean and OO, there's not the sigil busyness you might see in old Perl code used by admins in the mid 1990's. I think this is really just something people that use other languages are bothered by. I know we all have preferences. When I do Javascript I tend to miss the sigils a bit :)