Live data from Hacker News

Why I’m Learning Perl 6

evanmiller.org

271–280 of 380 posts

Re: Why I’m Learning Perl 6

#271

Earlier quoted context omitted.

I hadn't heard of Tcl before but it looks awesome! What do you find its ideal use cases to be?

Tcl is pretty old. A lot of the territory it covered well is now better covered by other things. One of its great strengths was being extensible. It's pretty easy to bake some functionality into Tcl and provide a new shell with it. This is what expect ( http://expect.sourceforge.net/ ) is, for instance. Another early advantage of Tcl was Tk, which provided Tcl extended with GUI stuff. Tk was cross-platform and establ…

Not sure if it's lunch has been eaten, but TCL was great for embedding and pretty widely used. So, to mix metaphors, it definitely had a few great meals before losing the spotlight.

I've seen it embedded in load balancers and used for test harnesses for embedded devices.

https://devcentral.f5.com/articles/irules-101-01-introductio...

Re: Why I’m Learning Perl 6

#272
post #252

Earlier quoted context omitted.

Parrot was implemented in C, and to my recollection implemented various iterations of bytecode syntaxes, notably PBC PBC was the bytecode format, the human readable low-level syntax was called PASM and the slightly higher-level synax was called PIR. Besides PIR, other languages still close to the metal were NQP versions (though I don't remember the exact relationship between NQP/NQP-rx/parrot-nqp) and eventually Winx…

Ah, I figured that part was slightly off (since I knew PBC was bytecode and thus my waffling with "bytecode syntaxes"), but really didn't want to research the history I had already forgotten. Thanks for the correction. > Besides PIR, other languages still close to the metal were NQP versions (though I don't remember the exact relationship between NQP/NQP-rx/parrot-nqp) and eventually Winxed. I vaguely remember NQP/NQ…

Winxed was NotFound's brainchild, though I believe Whiteknight did push its usage.

The way I remember it, the issue was that later versions of NQP moved towards greater backend independence and no longer mapped directly to Parrot VM semantics (eg 6model), so Parrot had to rely on older NQP version, making Winxed an attractive alternative.

Re: Why I’m Learning Perl 6

#273

> Concurrency is hard and if you want M:N thread multiplexing (i.e. WEB SCALE CODE, where application threads aren’t pinned to pthreads) your options today are precisely Erlang, Go, .NET, and Perl 6. Putting aside the "web scale" jokes ( http://www.mongodb-is-web-scale.com/ ), this statement is still absurd. Every major language, or at least the ones that matter for backend development, has support for thread multipl…

Pretty sure the ALL CAPS on WEB SCALE CODE indicates the author is in on the joke.

Re: Why I’m Learning Perl 6

#274

Earlier quoted context omitted.

Ehh... I don't really understand the impulse to "call out" downvotes, or ask people to explain why they're downvoting something that you wrote or agree with. Sometimes there is some really weird voting dynamic here and it would be interesting to know what goes on. For a lack of a better word you can call it intellectual curiosity or something.

I can't remember the last time I saw a reasonable comment more than a half hour or so old greyed out. But I often see highly-voted comment with an old greyed-out reply saying "why is this being downvoted". All that's happening is that the sample size of votes is too small early on to be meaningful.

But I still often wonder about the motivation for those early downvoters.

And I'll still hold that this is acceptable curiosity.

Re: Why I’m Learning Perl 6

#275

Earlier quoted context omitted.

> 10 different ways of doing the same thing Mostly an urban myth. Where it isn't, at least 8 of those ways are actually important. Exercise: write a python program that prints Python's quoting documentation, without external files, without editing the documentation. Spoiler alert: it's impossible.

So, how exactly these different ways of getting sub arguments are useful? sub add1 { my ($arg1, $arg2) = @_; $arg1 + $arg2; } sub add2 { my $arg1 = shift; # possibly two screens of dense code here, then my $arg2 = shift; $arg1 + $arg2; } sub add3 { $_[0] + $_[1] } # There may be some other ways to extract arguments # that I am not aware of. # It's possible to combine any of the methods! And this is just argument acce…

The significant part of argument handling in Perl5 is that @_ is a list of aliases to the arguments. You usually see add1 or add2 style argument processing because nice named arguments that are a copies of the function parameters.

add3 shows how to access the aliased arguments directly.

  # break the aliasing of @_ and make undef into 0.
  sub undef_to_zero { @_ = map { $_ // 0 } @_; }

  sub math_stuff {
    # call with identical @_
    &undef_to_zero;
    # Do math without undef warnings.
    my $sum = 0;
    $sum += $_ for @_;
  }

  # Alter all arguments in calls by repeating them
  sub fatten {
    $_ = "$_" x 2 for @_;
  }

  $foo = "abc";
  @bar = ( 1, 2, 4 );
  foo($foo, @bar);
  say $foo; # abcabc
  say for @bar # 11
               # 22
               # 44

Re: Why I’m Learning Perl 6

#276

Maybe it's because I'm old, but I don't see the appeal of M:N multiplexing in a programming language (i.e. 'green threads' or some other user-level context switching) For long-running tasks, if they are I/O bound you can use non-blocking I/O and event loops. If they are CPU bound, then use threads or separate processes. The two techniques can be combined to scale well across multiple cores. The OS is designed to sche…

> For long-running tasks, if they are I/O bound you can use non-blocking I/O and event loops. If they are CPU bound, then use threads or separate processes. The two techniques can be combined to scale well across multiple cores. One might suppose this to be the case, but to my knowledge only network IO is truly non blocking, although there are async io api's in some languages for disk reads/writes, they're still bloc…

Perl6 (with the MoarVM backend at least) should have proper async IO on both network and file IO.

jnthn (one of the primary contributors to MoarVM) has a write up about recent work done to improve the system here: https://6guts.wordpress.com/2017/06/08/sorting-out-synchrono...

Re: Why I’m Learning Perl 6

#277

Earlier quoted context omitted.

> 10 different ways of doing the same thing Mostly an urban myth. Where it isn't, at least 8 of those ways are actually important. Exercise: write a python program that prints Python's quoting documentation, without external files, without editing the documentation. Spoiler alert: it's impossible.

So, how exactly these different ways of getting sub arguments are useful? sub add1 { my ($arg1, $arg2) = @_; $arg1 + $arg2; } sub add2 { my $arg1 = shift; # possibly two screens of dense code here, then my $arg2 = shift; $arg1 + $arg2; } sub add3 { $_[0] + $_[1] } # There may be some other ways to extract arguments # that I am not aware of. # It's possible to combine any of the methods! And this is just argument acce…

you'll be happy to know that the sigils (@) don't change in perl6 for access.

Re: Why I’m Learning Perl 6

#278
post #196

Earlier quoted context omitted.

You aren't really showing off different ways to get arguments in any of those examples. In all of them, you get the arguments in a list called @_; you're just showing off three different ways to get values out of a list, which Python has plenty of ways to do as well. Translating your examples into Python: def add1(*_): _ = list(_) arg1, arg2 = _ return arg1 + arg2 def add2(*_): _ = list(_) arg1 = _.pop(0) arg2 = _.po…

That does not change the fact that in Python everybody writes def add(x, y): return x + y whereas the Perl codebase that I work with has every possible combination of these methods.

Come up with a style guide and stick to it. Failure to do that with any language, no matter how restrictive, leads to messy code.

It doesn't matter which way you unpack your args unless you are trying to do something fancy (the sub 1% cases). Just pick one.

Hell, it's easy enough to make a script to rewrite multiple shifts into destructured list assignment or vice versa.

Re: Why I’m Learning Perl 6

#279
post #272

Earlier quoted context omitted.

Ah, I figured that part was slightly off (since I knew PBC was bytecode and thus my waffling with "bytecode syntaxes"), but really didn't want to research the history I had already forgotten. Thanks for the correction. > Besides PIR, other languages still close to the metal were NQP versions (though I don't remember the exact relationship between NQP/NQP-rx/parrot-nqp) and eventually Winxed. I vaguely remember NQP/NQ…

Winxed was NotFound's brainchild, though I believe Whiteknight did push its usage. The way I remember it, the issue was that later versions of NQP moved towards greater backend independence and no longer mapped directly to Parrot VM semantics (eg 6model), so Parrot had to rely on older NQP version, making Winxed an attractive alternative.

> Winxed was NotFound's brainchild, though I believe Whiteknight did push its usage.

That's interesting. I'm not sure why I remembered it so strongly as Whiteknight's invention, but it probably has to do with how much he talked about it, and that my initial exposure to it was through his blog.

> The way I remember it, the issue was that later versions of NQP moved towards greater backend independence and no longer mapped directly to Parrot VM semantics (eg 6model), so Parrot had to rely on older NQP version, making Winxed an attractive alternaive.

That sounds likely. The whole situation was a clusterfuck. To my knowledge, some people are still really upset about it and how it played out (but at this point I don't really see how it could have gone any other way).

Re: Why I’m Learning Perl 6

#280

> Concurrency is hard and if you want M:N thread multiplexing (i.e. WEB SCALE CODE, where application threads aren’t pinned to pthreads) your options today are precisely Erlang, Go, .NET, and Perl 6. Putting aside the "web scale" jokes ( http://www.mongodb-is-web-scale.com/ ), this statement is still absurd. Every major language, or at least the ones that matter for backend development, has support for thread multipl…

I'd like to know why people are downvoting this.

I'd like to know why people are downvoting this.

Because for some people, it's not enough to think of others as misinformed, or not so well-spoken.

They need to be thought of as blundering idiots, and castigated accordingly.

Post reply on HN