Live data from Hacker News

Why Did I Choose Perl When Building Crowdtilt?

dsog.info

121–130 of 143 posts

Re: Why Did I Choose Perl When Building Crowdtilt?

#121
post #71

Earlier quoted context omitted.

umm, verbosity? 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;

Verbosity. class Point { has Int $.x is rw; has Int $.y is rw; method clear() { $.x = 0; $.y = 0; } } :)

Perl 5.18 may have the following:

  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/...

Re: Why Did I Choose Perl When Building Crowdtilt?

#122
post #42

Earlier quoted context omitted.

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 cod…

Regardless 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.

And this would be why PHP is so popular?

Re: Why Did I Choose Perl When Building Crowdtilt?

#123
I reach for Perl frequently, primarily for two reasons:

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.

Re: Why Did I Choose Perl When Building Crowdtilt?

#124
post #108
post #102

I'm writing to beginner programmers. Please, please don't use Perl. 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…

Your post gets a number of things wrong about Perl. > 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…

Please don't make assumptions about my Perl knowledge as I don't make any assumptions about your technical knowledge. I'm actually a Perl Programmer full time.

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.

Re: Why Did I Choose Perl When Building Crowdtilt?

#125
post #124
post #108

Earlier quoted context omitted.

Your post gets a number of things wrong about Perl. > 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…

Please don't make assumptions about my Perl knowledge as I don't make any assumptions about your technical knowledge. I'm actually a Perl Programmer full time. 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…

In Ruby can write `puts Object.new.inspect` to get something like `#`. Does that mean Ruby has pointers?

If you can't do math on it to access other parts of memory, it's not a pointer in the C sense.

Re: Why Did I Choose Perl When Building Crowdtilt?

#126
post #119
post #114

Earlier quoted context omitted.

I didn't say I had to deal with perl code I didn't understand, just nasty perl code. Of course the coder in question is the problem, not the language as such -- I've just seen more obscure hacked together perl code than eg: python. 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…

Well, ok -- I guess (after a bit more googling) I see what you mean: 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…

The python example you linked to http://eli.thegreenplace.net/2010/06/30/python-internals-add..., which shows an example of adding an 'until' keyword, requires you to recompile the python interpreter. From your article: "After making all the changes and running make, we can run the newly compiled Python and try our new until statement". Of course you can extend any language by recompiling it and creating a new interpreter. That is exactly my point! Perl lets you achieve the same thing simply by using a module from CPAN.

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.

Re: Why Did I Choose Perl When Building Crowdtilt?

#127
post #124

Earlier quoted context omitted.

Please don't make assumptions about my Perl knowledge as I don't make any assumptions about your technical knowledge. I'm actually a Perl Programmer full time. 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…

In Ruby can write `puts Object.new.inspect` to get something like `# `. Does that mean Ruby has pointers? If you can't do math on it to access other parts of memory, it's not a pointer in the C sense.

But you deference the addresses just C. I'd say it's more a like a pointer than not. And this is where I have I issue. You don't deference addresses in Ruby or Python. When you are writing data structures in Perl you have constantly have to deal with extra syntax (and mental work). I'd say about 10% or so of my syntax errors come from this and it's completely unnecessary. It's a huge pain (to me atleast).

Re: Why Did I Choose Perl When Building Crowdtilt?

#128
post #94

Earlier quoted context omitted.

"As has been alluded to in another comment: Which other languages that compare to perl have you actually looked at?" 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…

"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 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.

Yes, I definitely agree that Perl is harder to learn than Python. My point was that people may not have the time or interest to learn Perl, and so when they see Perl code that they do not understand, they blame it on the language instead of their own lack of knowledge.

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.

Re: Why Did I Choose Perl When Building Crowdtilt?

#129
post #119
post #114

Earlier quoted context omitted.

I didn't say I had to deal with perl code I didn't understand, just nasty perl code. Of course the coder in question is the problem, not the language as such -- I've just seen more obscure hacked together perl code than eg: python. 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…

Well, ok -- I guess (after a bit more googling) I see what you mean: 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…

You had asked for some examples of Perl modules that extend the core language. As was stated by @knighthacker, MooseX::Declare and Test::Class::Sugar are excellent examples:

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.

Re: Why Did I Choose Perl When Building Crowdtilt?

#130
post #60

Does anyone have a good handle on how good perl interpreters are, or whether there are perl "compilers" that do something fancy, i.e. turn it into bytecode? 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.

Perl 5 has been around for a while and has seen quite a bit of optimization. It's fast.
Post reply on HN