Live data from Hacker News

Why I’m Learning Perl 6

evanmiller.org

231–240 of 380 posts

Re: Why I’m Learning Perl 6

#231

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

Ruby also has JRuby, which has true parallelism & concurrency and does not suffer from the global interpreter lock like vanilla ruby/python.

Re: Why I’m Learning Perl 6

#232
post #149

Earlier quoted context omitted.

i.e. SIMD i.e. something like: @array = 1, 2 ... 1,000,000 ; @array>>++ ; where the `>>++` operation increments each of a million integers with the workload distributed across multiple real CPUs?

Yes, or perhaps more generally, any loop where the compiler/runtime can infer that each iteration of the loop is independent of the others, and so they could theoretically run on multiple cores. It's SIMD, exactly as you say, but potentially on much larger blocks of code than single arithmetic operations. A compiler that can pick where to use SIMD is doing the same kind of analysis. The difficulty in doing it at comp…

Right.

In P6 (potential) parallelism is explicit. You have to use an explicit construct such as the `>` meta operators.

I used a simple arithmetic operation but it can be any code. Of course, it had better be parallel safe.

The code-gen at compile time makes an AOT call on whether to attempt parallelization. If the JIT thinks that's not working out during a particular run it may decide to de-optimize.

> more generally, any loop where ... each iteration of the loop is independent of the others

Right. The `>` meta operators aren't the only relevant features. For example there's a `.race` method that not only (potentially) parallelizes a map, grep or whatever, but provides further explicit control such as batching size.

Re: Why I’m Learning Perl 6

#233
post #65

I hate perl6. I hate it because I tried to get involved in the project early on, and it led me down the Haskell rathole. I don't know what Haskell looks like today, but a decade or more ago it was the hardest language to pick up that I had ever experienced. It was as if I had a solid background in latin languages and I was trying to pick up Chinese based on a handful of tutorials written by a tourist on the back of a…

Perl6 is no longer implemented in Haskell on the backend. I think the old parrot VM was, but MoarVM is in C. On the bright side, a lot of cool FP concepts made it into P6 as a result of the original Haskell backend, so useful cross polination happened. Even better, you can do FP stuff in a much easier to understand way and you can also mix in OO when needed or relevant.

[deleted]

Re: Why I’m Learning Perl 6

#234
post #190

Earlier quoted context omitted.

How did parrot write arrays from multiple threads without a lock somewhere in there?

You deferred updates to the owner via scheduler, with high prio, and continue. parrot threads are lock free but not wait free. The NQP compiler needed to know about threaded writes and schedule the update, with a semaphore, while the other threads continue. What MoarVM got better was everything else. The GC, the calling convention, the OO (6model), the jit. I was on my way to fix all the parrot damage done from the p…

I fail to see how using a semaphore to schedule work in another thread is "lock-free."

Re: Why I’m Learning Perl 6

#235

For some reason, when I started my software engineering career I got it into my head that I needed to learn as much as I could about programming languages. I learned ruby, perl5, python, lisp, forth, ml, ocaml, scheme, haskell, r, c#, java, lua, c++, factor, idris, asm, erlang, prolog, rust, d. But that wasn't quite enough because haskell and idris kept on talking about complicated type theory stuff. So I also learne…

That's understandable; if you look at the slides and see all of the integrated features in one big blast, you're going to think "holy moly this was not meant for mortal men". In a way that's correct, because ultimately Perl6 is designed as the ultimate "kitchen sink" language; it has all the little features you could think of already baked in, which will include a lot of features you won't use. The main reason for th…

Another way to look at it is that it's designed to be a great "babytalk" language, the idea that everyone should be able to relatively easily learn enough of the language to easily get done what they need to easily get done. I'm not saying it's there yet -- doc is critical -- but that's part of the idea.

Conversely, whereas the P5 motto was TIMTOWTDI, the P6 motto is closer to TIMTOWTDIBSCINABTE, so there's usually relatively few idiomatic ways to do something.

Re: Why I’m Learning Perl 6

#236

Thing that really gets me about perl is the syntax, it's horrendous. No other reason, that's all. Just the syntax.

It's _different_. But working for a few years with Perl 5, it really grew on me. It could use a good "Perl: The Good Parts" book, I guess. I haven't looked at Perl 6 yet, don't know if that's better or worse. Too many other things to do, and I don't think I'll ever work with Perl professionally again, that ship has probably sailed.

The Perl 5 equivalent is Damian Conway's Perl Best Practices

Re: Why I’m Learning Perl 6

#237
post #132

Earlier quoted context omitted.

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

I'm not an expert, but I think you're right for POSIX. Windows does apparently offer the necessary building blocks; this is the most relevant HN sub-discussion: https://news.ycombinator.com/item?id=9584269

aio - POSIX asynchronous I/O overview

http://man7.org/linux/man-pages/man7/aio.7.html

Re: Why I’m Learning Perl 6

#238
post #36

I like writing bash scripts a lot and perl is a natural step-up with powerful libraries to use. As others have said, the major obstacle for me has been the lack of great literature.

There's lots of literature out there for Perl 5 (like the so-called "Camel Book"). Perl 6 literature is pretty scarce, though.

There is 2 out now and many in development. So really not that bad.

Re: Why I’m Learning Perl 6

#239
post #219

Earlier quoted context omitted.

> Coroutines are lower-level [than M:N threading] Not sure I understand what you're trying to say here, this sounds exactly backwards to my reading. A green threading library can be written in assembly language with no reference to anything but the hardware ISA specification and the ABI that defines the relevant calling convention. It's as "low level" as a software construct can be. The only lower level implementatio…

> Not sure I understand what you're trying to say here The exact sense of the phrase you excerpted is explained in the next clause of the same sentence of the comment.

OK, then that's backwards, sorry. The fact that A is hard to implement in terms of B doesn't mean that A is a "lower level" (or even "higher level") construct in the sense people usually use those terms. It just means that the two metaphors are incompatible.

Honestly I was asking the question because I thought you had some deeper point in mind I couldn't see. But you just had it backwards.

Re: Why I’m Learning Perl 6

#240
post #165

Best argument to use Perl 6 is that it's fun. Like really fun. Whatever language you are using is boring. Perl 6 is just damn fun. It's like your favorite language but with dollar signs, and funner.

Perl5 is also fun. Until you have to work with others' people code, or even your own older code.

Many P5 folk claim that it remains fun if the P5 code is well written.

But regardless, having fun with P6, which is specifically designed to be readable, maintainable, composable, refactorable, etc. is fundamentally different from having fun with a language like P5.

Post reply on HN