Why Did I Choose Perl When Building Crowdtilt?
dsog.info
dsog.info
Why did I choose to build X with Y?
The generic answer is usually:
Because it is what I know.
The extended answer may include particular features of the language or environment or it may include the support provided by a particular cloud infrastructure.
As an example, the stuff I am personally working on now, I mostly use Python because I know it well and the ecosystem for webapps is pretty mature. 7 or so years ago, Python (in particular) mod python wasn't even close to modphp, so I went with PHP. Today, if I was adamant about building on Azure, I'd choose NodeJS (thus JavaScript) or C# because they are first class citizens of the platform.
In other words, choice of language can take on many facets. Good to see PERL mentioned again.
In the post I don't bash any other languages at all. In fact, I encourage people to learn other languages too. At the end of the day, it'll help you evolve your thinking process and extend your skill set.
Thank you for your comment :)
What I liked about the post - it didn't focus on hype, like that around NodeJS (it's badass rock star tech); additionally it brought up a language no so en vogue.
Keep up the good work.
In the HN echo chamber, it seems like everyone who's anyone has moved on to ruby, rails, python, django, etc. Look into the every-web. My god, it's full of perl.
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.
It is so hard to know that @ means array and % means a hash (key/value pair) haha.
Also, it means one doesn't have to dodge keywords in naming their variables. Doesn't count for a lot but is nice.
Agreed. However, working for a company with more than one developer...
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?
print "I ate a $fruit for $meal"
Or
printf 'I ate a %s for %s', $fruit, $meal
> '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.
my $x = 1;
say "$x + 1 = @{[ $x + 1 ]}";
sub plus1 { $_[0] + 1 }
say "$x + 1 = ${\plus1($x)}";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)
- Bjarne Stroustrup
CPAN is more than just a repository of modules: it's a tool-chain of software. When you upload a module you get a tonne of feedback about which platforms and versions of Perl the tests fail on, you get reports from CPAN Testers about your library in the wild, and when new Perls come out you get notifications if your library gets broken.
The ability for the language to evolve, I think, has been a big reason why Perl is still around. It's able to adopt new features and simultaneously remain backwards compatible for long periods of time (for the most part).
I don't use perl most of the time, but when I do I like it.
That being said, I don't feel that any of the reasons given in this post are in any way leading to the conclusion 'Use Perl'. In fact I think all of those points apply to just about every major high-level language today. CPAN is definitely a very high-quality system, but I think nearly every language I use has something functionally similar. The same sort of argument works on the other points, or so it seems to me.
The one exception is the ease of extending the language. I'm not familiar with that functionality of Perl, but I can say that extensibility of the core language is by far my favorite feature of Scheme. If Perl has a similar ability, then I will absolutely concede that that is a powerful feature indeed.
Checkout these modules: Test::Class::Sugar MooseX::Declare
Thank you for your feedback.
Python has rich meta-programming. Ruby has (almost) single-handedly super-hyped and re-invented the idea of domain specific languages (DSLs). Lisp is of course all about this (as is Forth).
Javascript builds on the ideas from Smalltalk and (especially) Self to allow you to crazy stuff with how objects work...
Java can't do much of this, but the JVM has been bent in surprising ways by efforts like Clojure and Scala...
While it is great that you know and like perl -- That particular point in the post (and this comment) seems rather poorly researched.
I'm very much on the burnt-by-crazy-old-nasty-perl-legacy-crap side of the fence -- but I can't deny that I see some of the reasons why people would like to use perl -- it's just not for me. The statement "Perl evolves in a ... manner that makes the language always fresh" makes me want to hide under the bed -- if I have to deal with someone else's code in production ;-)
Still -- it's a bit strange to see the claim that perl is somehow much more flexible than other comparable languages.
I am very familiar with all of the languages that you mention. They are all great languages in their own right. My comment however was about Perl's ability to easily evolve the core language via contributions from its community, as opposed to other languages that require a lenghty process performed by the core maintainers of the language. This allows Perl to evolve at a much faster pace than other languages. A lot of your points do not seem relevant in that context.
"Python has rich meta-programming."
Who cares? So do most modern languages.
"Ruby has (almost) single-handedly super-hyped and re-invented the idea of domain specific languages (DSLs)."
The Perl community has been writing DSL's since before most people had heard of Ruby. Real DSL's. Not just invoking functions without parens and labeling it a DSL, as is often done in the Ruby community. Ruby in no way invented or re-invented anything having to do with DSL's.
"Lisp is of course all about this (as is Forth)."
Agreed. Lisp macros are very powerful. Lisp is a great example of a language that can do this.
"I'm very much on the burnt-by-crazy-old-nasty-perl-legacy-crap side of the fence -- but I can't deny that I see some of the reasons why people would like to use perl -- it's just not for me."
This is a common complaint. People have had to deal with Perl code that they do not understand. It may have been poorly written, or it may have been perfectly written Perl code. If you do not take the time to learn Perl, you would not know the difference. The most common reaction is to blame the language.
"Still -- it's a bit strange to see the claim that perl is somehow much more flexible than other comparable languages."
It may be strange to you because you are not very familiar with Perl.
The problem is that Perl's TIMTOWDI culture and the inconsistent evolution of the core language make learning "enough" Perl harder than learning e.g. "enough" Python.
Perl has a very rich and powerful and expressive grammar. It takes a good bit of effort to learn all of it. Python has opted for a grammer that is much more simple. That definitely has its benefits. For me personally, I feel constrained when writing Python code due to its lack of expressiveness.
I'm perfectly aware this is a subjective opinion: I don't like perl very much. I never claimed everyone else should dislike perl -- in fact I stated the opposite -- I see why it appeals to some people.
> My comment however was about Perl's ability to easily evolve the core language via contributions from its community, as opposed to other languages that require a lenghty process performed by the core maintainers of the language.
> "Python has rich meta-programming." >> Who cares? So do most modern languages.
Well, your claim is that perl has strong meta programming, and that perl programmers use it -- implying that eg: python programmers choose not to, and rather sit on their hands waiting for Guido to bless their new data structure or syntactic sugar for improving arrays?
See eg: http://www.python.org/dev/peps/pep-0218/
I suppose this your "lengthy process" ? But the set module was available before it became part of the core language, so if you were the programmer that needed a new datatype nothing stopped you from implementing it and uploading it to the package index? (Although I don't remember quite how well the package index worked back in 2000 -- CPAN certainly has a long and solid history behind it :-)
For another example (again python):
http://kashif.razzaqui.com/30414548 "Javascript's Prototype Inheritance in Python"
As for ruby, note I said "super-hyped". Maybe I should've said "re-introduced", or "introduced to a new generation of programmers", rather than "re-invented".
> It may be strange to you because you are not very familiar with Perl.
Perhaps. I would be very much interested in some examples of the DSLs you speak of. I guess perls regex-handling would lend itself to be used as a poor man's Standard MetaLanguage?
http://www.catalyzed.org/2009/05/dawn-of-a-new-age-in-perl-h...
Now, while power obviously is power -- I don't see many immediate uses for that, that can't be done better within in python via magic methods etc.
But in case others are interested, here's a couple of links I also came across:
http://stackoverflow.com/questions/214881/can-you-add-new-st...
http://eli.thegreenplace.net/2010/06/30/python-internals-add... (Most definitely in the "don't do that"-category from a python point of view :)
If this (writing a new language) is really what you want, you would probably be better off playing with pypy and its restricted python, though:
https://bitbucket.org/brownan/pypy-tutorial/src/8cfb3cd72515... (Tutorial for writing your own interpreter with rpython)
https://bitbucket.org/cfbolz/pyrolog/src/aa127d31df0c/prolog... Working implementation of Prolog, built with pypy/rpython
I don't think you have been paying attention to what I have been saying. You keep mentioning that python has strong meta-programming. I never said anything about meta-programming. Perl, python, ruby, everybody can do meta-programming. I said that Perl lets you easily modify the core language grammar via 3rd party modules. This is an extremely powerful feature, if you took a second to think about it.
However, if someone wants to do something similar in Python, here are how you would (have) to do it. I didn't mean to say that it was the same - or as straightforward.
This is also why I linked to the r(estricted)python examples with pypy -- because they give you more of the power to define a whole language -- but that also isn't the same as being able to do it within the language itself.
As for meta-programming, I have always meant that in the sense of lisp macros, not simply chaining some cleverly named functions.
I'm still not convinced it's a feature I would want in Perl -- but then again, I don't particularly like Perl, and I don't use it -- so clearly what I think of it doesn't matter: I'm not the target audience for Perl features.
Thankfully we don't all prefer the same tools :-)
https://metacpan.org/module/MooseX::Declare https://metacpan.org/module/Test::Class::Sugar
Just look at the SYNOPSIS section for example code. If you know some Perl, you will notice that the code would normally not be valid syntax. Yet simply by using a module, you can define classes (MooseX::Declare) or describe tests (Test::Class::Sugar) in a brand new way.
At that time there were already quite a lot of movement within eg: python with improvements being made to the language, in the language itself.
So, yes, I guess I'm sticking to my guns.
When I first started here I asked the same question: "Why?" - and I got essentially the same answer as this article.
In the end, as long as the development team is comfortable with it, and it works, and there is still a community of supporters, I suppose it doesn't really matter what it is written in.
Hey - at least it isn't PHP!
Ummm... What?!
There's a long tradition creating DSLs in the Ruby community. Lisp/Scheme/Clojure have macros. OCaml has campl4. I'm sure there are many others.
I don't know anything like "MooseX", but that might be because Ruby actually has a somewhat working object system.
One could, in theory, build something like Lisp macros using it, but I don't think that anyone has.
5. Perl code is fun to write.
If you are comfortable in your environment, then moving fast comes naturally and you have far more opportunities to succeed.
As a grad student I found myself using it quite a lot for writing quick and dirty scripts for data manipulation until I finally decided to move to python. Since then, I never look back :-)
Moose's support and flexibility as an OOP layer is second to very few.
This is basically what Modern Perl and CPAN modules are all about. Checkout Perl Dancer as a web framework for example and you'll see simplicity.
Unless you're talking exclusively to language/stack zealots, the best guys are evolving the tools, and the next-best are evolving with them. That's not to say that all things old are bad and all things new are good, but we do tend to get better at different classes of problems.
As the author suggests, though, Perl has this incredible longevity and extensibility. I really like it whenever I work with it, and it wouldn't be a turn-off if I was considering working there. But if someone came to me and said, "I want you to develop a To-Do web app in C++," I'd probably pass.
Perl was one of the first mainstream advanced scripting languages to run the Web, so the amount of folks out there that cut their teeth on CGI/Perl is pretty wide and deep.
For me, I started writing my first Web apps in Perl, and moved over to PHP.
So far hiring hasn't been a problem for us. However, we don't focus on hiring Perl hackers, but outstanding hackers instead. They grow to enjoy Perl after a few hours and sometimes during the interview ;) haha
Getting attention because you didn't use Node or Clojure or Erlang or Ruby or Python or Java is trickier.
(I've been at this long enough to remember hearing from VCs "Your product has a Perl backend and a Python frontend? Oh... would you consider rewriting it all in Java? Java has more buzz.")
Because I'm in the job market at the moment I figured I'd take a closer look at Python and Ruby, so I'm concurrently reading two python/ruby books. To be honest, I don't see much in it. If I were to chose one I think I'd have to go with python, because Ruby looks to me, just like perl but with a different set of weird symbols to remember, and a slightly different set of downsides.
Python on the other hand looks like a sufficiently different take on the dynamic language problem, so as to be more interesting.
PHP I'm not bothering with right now. It's just like perl only with most, if not all of the design intelligence removed.
That said: The do what I mean paragraph kind of reminded me of the Stripe CTF. One of the levels (5?) was vulnerable to pass parameters to a POST handler via query string. In other words: In level 5 in that CTF, if you followed one possible solution, you abused this flexibility.
So .. maybe it's not always a good thing? Including this particular reference in the article?
Thanks for the feedback :).
Edit to add: I know why this sounded familiar! I had forgotten I wrote about it recently:
http://www.modernperlbooks.com/mt/2012/08/why-i-use-perl-tes...
Do you really know about this?
I've done a bit of Python lately. The infrastructure isn't close (see e.g. Perl Testers, chromatic had a blog post about it quite recently). Also, CPAN is much richer than pypi.
See this comment on an old Perl thread for some pointers
Another difference: In the Perl world, you can find and have dependency trees with dozens to hundreds of modules installed from cpan -- and you expect it to work, particularly since the module tests by default are run at install. (It is a bit painful with too many dependencies, but it works if you need it.)
http://wiki.python.org/moin/PythonTestingToolsTaxonomy
Also, as far as SQL, and even Object Relational Mappers goes, there's SQL Alchemy.
You can verify they are present here, in PyPi: http://pypi.python.org/pypi
See http://search.cpan.org/~rehsack/SQL-Statement/
It contains a parser and evaluates SQL expressions on lots of data sources(!).
The testing tools on Perl use a common infrastructure and can work with each others in a plugin fashion.
Perhaps how popular a solution for the web is depends also on free or easy hosting options where people can experiment ?
i. I've been using for 20 years or so, since Perl 4. By the time I check back to verify some point of Python syntax or library use, I will have written the code in Perl.
ii. CPAN. It is unusual for me to go there and not find something that I can use for a task.
I like Python and do use it a good deal, largely on Windows. Yet some months ago, I ended up writing a few longish scripts to run on Windows, with ActivePerl.
In fact, I think if anything Perl would speed up the time it'll take to train a dev and get him/her to have an impact on the product from day one due to how easy is it to learn.
Which will be negated by how hard real-world perl code is to read and maintain.
package Point;
use Moose; # automatically turns on strict and warnings
has 'x' => (is => 'rw', isa => 'Int');
has 'y' => (is => 'rw', isa => 'Int');
sub clear { my $self = shift; $self->$_(0) for qw/x y/}
1; class Point {
has Int $.x is rw;
has Int $.y is rw;
method clear() { $.x = 0; $.y = 0; }
}
:) use mop;
class Point {
has $x = 0;
has $y = 0;
method clear { ($x, $y) = (0, 0) }
}
ref: https://github.com/stevan/p5-mop/blob/master/t/000-examples/...Moo/Moose (and Mo and Mouse if you must) are on the other hand game changers.
I definitely recommend reading "Modern Perl". It is a game changer.
You don't even need to know how to write code to understand the code written at Crowdtilt or any other company that really uses Modern Perl and have good practices.
Comparing the readability of python vs perl/c-like languages show it clearly. In python the readability come as a natural idiom, it is part of their zen!.
I found that when I develop in python/delphi/pascal the code is readable by default, but in ANY c-derived language could become messy fast. Something as simply as how align a IF clause. In C-like language I could go wild (and I see a LOT of code that look different, from person to person) and in contrast I read almost any python code as if I was write by myself.
Superficial readability, perhaps.
Neither PEP 8 nor PEP 20 get into interesting questions about maintainability like:
* How long should individual compilation units be?
* How do I factor my code?
* What metaphors do I use to name components?
* How do I know when to break apart components?
* How do I know when to merge components?
* How do I write effective documentation?
* Is this API easy to use?
* Have I sufficiently encapsulated this component?
* How easy is this code to test?
* Does this code match local style?
* Does this code follow the idioms and express the necessary elements of the problem domain effectively?
* Is it easy to misuse this API?
* Have I made too much information public?
* Have I made too little information public?
* Does this code make potential bugs screechingly obvious?
* Do I handle potential error conditions sensibly and completely?
* How much work do I face enhancing this code in the future?
PEP 8 concerns itself with far less interesting things, like why vertical alignment is annoying. In my experience, that's one of the least substantial elements contributing to maintainability.As for readability, it doesn't really matter if someone who doesn't know the language can't read it.
PEP 8, on the other hand, is to get these good developers to agree on the less interesting things, such that they can use it as a stepping stone to the more interesting ones. PEP 8 requires strict compliance, because if different developer ignore different portion of PEP 8, you end up with nothing.
In short, if you have long lines of code crammed together with no spacing, get them to look pretty based on PEP 8 first before we talk about how easy is this code to test.
It's just easier to write bad Perl, and most Perl is set it and forget it in scope.
Use Ruby and/or Python. Other competing scripting might be good (like lua) but I haven't used them. I do know however Ruby and Python are better.
see https://sites.google.com/site/steveyegge2/ancient-languages-...
90% still holds true. This guy knows more than 99% of the Perl advocates on this thread (he's also smarter than me). Do another search on other famous programmers (like Rob Pike) and almost always you'll find negative comments about Perl. There a reason companies like google use Python and universities (like MIT) teach in Python.
For crying out loud Perl has pointers in it. Perl doesn't do basic parameter checking in functions. Perl doesn't come with a decent repl. The Perl repl doesn't work with readlines. Perl doesn't do sane type checking. print "abc" + 1; prints 1. It isn't a syntax error (like in Ruby or Python). Do some basic google searching. wantarray is one of most horrible things I've seen a programming language thats unique to Perl. You how know generally side effects are bad in functions? Well, I don't want to get into it... but just google it.
Perl has a weird cult culture to it. There are a few smart people who are really into it but it isn't because of the languages merits. This is well described by one of perl most famous developers: http://www.perl.com/pub/2000/12/advocacy.html No one with a OPEN mind who isn't lazy wouldn't move onto Python or Ruby.
Remember too at the end of the day it is how good or bad code theoretically is. Is what you see out in the wild. What you work with. The chances are you won't be looking at chromatic's code. Perl code is about the ugliest, most unreadable code you'll find on average. I recently saw something Brain D Foy (a Perl expert) acknowledging this. The average code is what counts.
Anyhow those are my 2 cents. I have to go to sleep.
> For crying out loud Perl has pointers in it.
It does? Do you mean references? You'll need to use reference syntax when using nested data structures, but this is the same syntax that you'll find in Python and Ruby - you could think of those languages as using references by default instead of having array or list types.
> Perl doesn't do basic parameter checking in functions.
This is true - you'll need to deconstruct `@_` yourself. It is a shame. There is Params::Validate and Method::Signatures to fix this.
> Perl doesn't come with a decent repl.
Yeah, this is annoying. Get Devel::REPL and use that.
> Perl doesn't do sane type checking. print "abc" + 1; prints 1. It isn't a syntax error (like in Ruby or Python).
This throws a lot of people off, when they expect it to work like Python or Ruby and it doesn't. "abc" and 1 are actually the same type - scalars. A scalar can be a number or a string behind the scenes, and they're automatically converted, so you can just read data from a file and not have to worry about that. You want to use the dot operator, `print "abc" . 1;`, which prints "abc1" (which is what I think you want).
In those languages, it throws a type error, not a syntax error, which is an important distinction. Intergalactic law states that you're not allowed to complain about Perl if you don't know this.
> wantarray is one of most horrible things I've seen a programming language
Having list flattening means you can dump all kinds of data into a function and not have to worry about where it came from. Recently I wrote the line of code `highlight qr/regex/, @colours, @more_colours`, where I just dumped values from arrays into the function and didn't have to worry about destructuring them. If I wanted to pass the arrays, I'd put a backslash before them. It's sort of the opposite of Ruby's unary * operator.
Perl has warts just like any other language. Its warts are just more infamous (because Perl is used so much, a lot of people are having to maintain old codebases) and more visible (Perl has a culture of using the CPAN to fix things with the language (MooseX, Modern::Perl) whereas other languages' users tend to just put up with it).
I disagree that the average code is what counts. When I helped out on a Python cause, the lecturer barely knew Python, and taught it as though it were C (the students learned while loops first, then for loops, and never actually learned about generators. Yeah, I know). The code they wrote was definitely below-average. But not once did they turn to the Internet to see what proper Python code was like - they just followed the course, and did what it told them. If you learn Perl from a book, the amount of sub-par Perl code in the wild isn't going to affect you. Or, to put it another way: how can someone else make my language a worse one merely by writing in it?
I do agree that Perl is a bad choice for your first language: the choices it gives you and the amount it leaves up to you could get confusing when you're trying to learn it by yourself. Perl is a language for when you're a better programmer, and you've learnt to code at a higher level.
Yes, Perl does have pointers in it. The term 'References' (in Perl) is marketing cover up you fell victim to. Run this: my $x = [1, 2, 3]; print $x; It prints ARRAY(0x206a998) on my machine. There's a address and a type, that's a pointer. Please read the Steve Yeggie I posted above (he explains it quite well) and then reply back (if you are so inclined).
>It does? Do you mean references? You'll need to use reference syntax when using nested data structures, but this is the same syntax that you'll find in Python and Ruby - you could think of those languages as using references by default instead of having array or list types.
So I have include 2 modules do something incredibly basic and fundamential to all programming languages. What a joke. C has been doing this SANE behavor since the 80s (maybe seventies). Along those lines (sorry, I'm being sarcastic to get my point across) why don't we have all scalars get random wrong values (after you assign something to them)? Then you can include a module Variables::UseRealValues so it behaves correctly. Then Perl fanatics can tell me how other languages are less flexible and Perl via TIMTOWTDI is better.
> This is true - you'll need to deconstruct `@_` yourself. It is a shame. There is Params::Validate and Method::Signatures to fix this.
Fair enough, I meant type error. I know what scalar is.
> Perl doesn't do sane type checking. print "abc" + 1; prints 1. It isn't a syntax error (like in Ruby or Python). This throws a lot of people off, when they expect it to work like Python or Ruby and it doesn't. "abc" and 1 are actually the same type - scalars. A scalar can be a number or a string behind the scenes, and they're automatically converted, so you can just read data from a file and not have to worry about that. You want to use the dot operator, `print "abc" . 1;`, which prints "abc1" (which is what I think you want). In those languages, it throws a type error, not a syntax error, which is an important distinction. Intergalactic law states that you're not allowed to complain about Perl if you don't know this.
Yes other languages have warts. Perl just has more of them.
>Perl has warts just like any other language. Its warts are just more infamous (because Perl is used so much, a lot of people are having to maintain old codebases) and more visible (Perl has a culture of using the CPAN to fix things with the language (MooseX, Modern::Perl) whereas other languages' users tend to just put up with it).
But people don't just learn from books. All of us google how to do a particular task when we doing it (especially under time constraints). With Perl's unwieldy syntax you're likely to copy something wrong (I don't just even mean cutting and pasting, but concepts). Someone will probably have to read this code later. So 'on paper' it doesn't make you're language worse (as you question below) but in practice (and that's what really matters) Perl's lots of wrong ways to do it really shoots you in the shoot.
> If you learn Perl from a book, the amount of sub-par Perl code in the wild isn't going to affect you. Or, to put it another way: how can someone else make my language a worse one merely by writing in it?
I find it slightly annoying all these 'why I use Perl' links on hacker news. Advocacy is lame. With Python or Ruby you'll see more links on a new library or a tutorial (like math library on the front page). Rarely do you see a 'why I use Ruby' or 'why I use Ruby' link.
One final thing, for all my Perl critism I find the community intelligent and very helpful. I just think the language is poor and they should move on alreay to Ruby or Python. It's a shame they waste on their talents on Perl.
If you can't do math on it to access other parts of memory, it's not a pointer in the C sense.
Are you familiar with the distinction between "pass by reference" and "pass by value"? If you call everything which behaves in the former way a pointer, I think you confuse an implementation strategy with a language construct and you lose an important feature of C pointers.
What you see in Perl (and Ruby) is a unique identifier that happens to be a memory address. It could be anything else, but the memory address is an identifier that's essentially free to generate. That's it. It's otherwise irrelevant. You have to write code in a language which has pointers to do anything with that information, and even then you have to cast it to a real pointer to do so.
We could discuss Perl 5's dereferencing syntax (it's ugly, no argument there) but that's a syntax issue and not an implementation concern.
> Are you familiar with the distinction between "pass by reference" and "pass by value"? If you call everything which behaves in the former way a pointer, I think you confuse an implementation strategy with a language construct and you lose an important feature of C pointers.
I don't understand why you keep saying that. They're not addresses.
From the language side of things, they're first class scalar entities just like strings and numbers. From Perl 5 they have nothing to do with memory addresses. (You might as well suggest that a nested data structure in any language without pointers is "dereferencing addresses", or that accessing object attributes is "dereferencing addresses".)
You can't write in Perl something like:
my $reference = 'ARRAY(0x1234abcd)';
... and expect to access the array at that point in memory even if you stringified an array reference and saw that its stringification included that hex address. References are not pointers. They don't dereference addresses.From the internals side, they're SVs, just like all other scalars in Perl 5. An SV is a C structure. Yes, the internals use pointers, but so does any other virtual machine implementation.
(Okay, you can write code like I said above, but to make that work correctly, you have to write C to do it, because C allows direct access to memory by address.)
Consider: my $x = [1,2,3]; print "@$x\n";
In the second line I consider "$" dereferencing the "address" that points to an array. I don't know anything about the internals of Perl virtual machine and what that "address" really means. But to the common programmer it seems like you have to do the same work you would have do in C dereferencing pointers. Python and Ruby have no such operator, right? This unnecessary work is what I'm complaining about (and all the associated extra syntax).
Though I probably wouldn't recommend Perl as a first language for everybody either, that's some pretty weak arguments. Appeal to authority of other Perl haters only proves Perl haters exist.
For crying out loud, Perl doesn't have exposed pointers. Perl doesn't prevent the programmer from doing basic parameter checking in functions. Decent REPLs are available for Perl. How could "the Perl REPL" not work with readline if he just said there wasn't a Perl REPL in the previous sentence? Perl doesn't have the same opinion as him as to what sane typing is. Doing stupid stuff results in undefined (to him, at least) behavior. It's possible to implement action-at-a-distance in Perl.
Python and Ruby have their warts too, they're just not exposed in this thread because there's no hater around to quote out-of-context lists of surprising behavior.
Arguing not to learn Perl because the average Perl out there is ugly? Non sequitur. No one with an open mind blah blah blah? I've got opposing data points. (not to mention the true scotsman)
Particularly ironic to quote that MJD text from almost twelve years ago. All of the behavior he described, I can now mostly observe from Python self-appointed champions.
And now on HN as well.
(I'm not saying you have to use Perl. I'm just saying dismissing it for the "reasons" listed in parent post doesn't make sense.)
Good article, especially the praise towards CPAN. It seems to get lost in the hustle and bustle of the cutting-edge discussions, undeservedly so.
If you are willing to have some discipline up front (and the expense of some amount of velocity), it can save your bacon later.
What with all the fancy compiler/interpreter technology going into things like V8, Nitro, pypy, cpy, etc, would be interesting to see how perl is keeping up in terms of speed.
#!/usr/bin/env perl
use warnings;
use strict;
use Regexp::Assemble;
my $ra = Regexp::Assemble->new;
while (<>) {
chomp;
$ra->add($_);
}
print $ra->re . "\n"; my $re = join "|", @list;
my (@matches) = $txt =~ /$re/g;
Quicker and faster...Maybe he's worried because someone else might have to read the code someday and they might wonder why it's Perl.
What's needed is a way to store code in an "intermediate" form that can easily be translated into whatever scripting language is desired.