Live data from Hacker News

Why I’m Learning Perl 6

evanmiller.org

241–250 of 380 posts

Re: Why I’m Learning Perl 6

#241

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…

Perl 6 is designed to be a large, feature rich language that can be learned and used incrementally. The intent is that, like users of natural languages, Perl 6 practitioners gain fluency and nuance in their expression over time.

So, if you want to learn Perl6, don't worry about writing "baby talk" Perl 6. Write something that works and solves your problem. Later on you may learn that there are multiple other ways to express the same ideas you wrote already. Maybe one of them better expresses the heart of your algorithm, then you update your code.

Now, you may think, how the heck am I going to maintain code written by a bunch of people at different phases of learning Perl6?

The Perl community has responded to this challenge by putting a huge amount of work into writing excellent documentation. Perl6 docs are readily searchable and carefully indexed. It's a big, new language with lots to write about, so the docs are not yet complete, but they are already fantastic and keep getting better.

So, please, just pick a problem to solve and jump on in. The water's fine.

Re: Why I’m Learning Perl 6

#242
post #132

Earlier quoted context omitted.

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

Maybe not quite there yet?

https://lwn.net/Articles/724198/ (May 30, 2017)

In truth, an AIO operation can block in the kernel for a number of reasons, making AIO difficult to use in situations where the calling thread truly cannot afford to block. A longstanding patch set aiming to improve this situation would appear to be nearing completion, but it is more of a step in the right direction than a true solution to the problem.

In other words, AIO seems likely to remain useful only for the handful of applications that perform direct I/O to files.

Re: Why I’m Learning Perl 6

#243

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…

True, but combining them can be a pain. My current codebase in C++ has both posix threads (std::thread) and libuv event-driven code. They're both fine, but it's a nuisance whenever they intersect. I can't drop libuv, because there's a nodejs VM inside. I can't drop std::thread, because some other libraries that do IO run synchronously.

A universal M:N threading system with coroutines underlying everything means that both styles of code can happily coexist.

Re: Why I’m Learning Perl 6

#244
post #67

Earlier quoted context omitted.

I wish Linux distros shipped with more recent language versions, e.g. Python 3.6 and Perl 6 in addition to just 3.4/5 and 5. I understand that it's not their job to try and push people to update their language skills, but it'd be nice to have access to them right off the bat if they feel like it.

The difference between Python minor versions (e.g. 3.4 to 3.6) is tiny compared to the difference between Perl 5 and 6. From what I've seen, the difference between Python 2.x and 3.x is tiny compared to the Perl 5/6 change.

I think the difference between Perl 5.10 (2007) and 5.26 (2017) is bigger than difference between the Python 2 of 2007, and Python 3 of 2017

The difference between Perl 5 and Perl 6 is probably about 10x the difference between Perl 5.10 and 5.26

I like to explain it this way:

Perl 4 is to C

as Perl 5 is to C++

as Perl 6 is to Haskell/Smalltalk/C#/Swift/Julia…

Re: Why I’m Learning Perl 6

#245
Even though this could more properly be called, "Why having language support for M:N thread multiplexing is important", I thought it was a refreshing article on why I might actually use a bit of perl6.

Last year I attended a conference and saw Larry Wall speak. It was an overview of Perl 6 and I was completely underwhelmed. Larry spent about half the time talking about unicode support. It wasn't a boring talk, but I never felt a moment when I said, "Awesome! This is a pain point in some other languages and I would pick up perl6 if this ever happened again."

I don't want to write perl6 completely off, but I have found that perl6 advocates have not done a great job on why you would actually want to use it. It's hard to justify learning "different" syntax just because someone says, "hey, it's fun!".

Re: Why I’m Learning Perl 6

#246
post #18

Can anyone recommend a good book on Perl 6? Are there any (even bad ones)? Right now I feel the major reason that keeps me from investing time in Perl 6 - besides adoption by distros - is the lack of a good book, like the Lama and the Camel book for Perl 5. It's kind of frustrating after having waited so long.

Think Perl6 is already out and free to download...very well written!

Perl 6 is the spec tests, and is open-source

Rakudo is the only currently supported implementation (ignoring several specialized partial implementations), it is also open-source.

Re: Why I’m Learning Perl 6

#247
post #191

Earlier quoted context omitted.

> I highly recommend that you try out a language with good support for option/maybe types Right. Like Perl 6. > Very often, your error handling through a chain of operations will be to use a slightly different operator (say '?.' Instead of '.') and any errors will be automatically propagated to the end of that section of code where you can handle them all in one place. P6 does this stuff particularly well. It makes o…

How is "opt-out option types" different from, say, Java, where everything is nullable and all the problems that come with that? Honest question, as I haven't had a chance to look into P6 as much as I would like. It looks pretty cool in a lot of ways, but I'm worried that all of the options available would create a confusing mess. > Note that the author of the OP is well known in the Erlang community. Yeah, my comment…

> How is "opt-out option types" different from, say, Java, where everything is nullable and all the problems that come with that?

Aiui the Java compiler and language constructs generally don't know the difference.

The P6 Nothing isn't a null, it's a "type object" with memory- and type- safe behavior.

There's a tiny bit more about this at: https://en.wikipedia.org/wiki/Option_type#Perl_6

Re: Why I’m Learning Perl 6

#248
post #58
post #9

> Why is this important? 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. I guess the author doesn't know about Haskell? The concurrency story for Haskell is great, and using the right library, you can literally just define types for the routes for your backend and then…

By "right library" do you mean Servant? (I'm interested.)

Here's an overview I wrote a while back.

https://news.ycombinator.com/item?id=14149200

Re: Why I’m Learning Perl 6

#249

Earlier quoted context omitted.

Does Haskell have thread multiplexing?

Yes, as well as excellent abstractions for putting those threads to work. See [parallel]( https://hackage.haskell.org/package/parallel ), [async]( https://hackage.haskell.org/package/async ), and [monad-par]( https://hackage.haskell.org/package/monad-par ) for a few examples. If you just need a web server [Warp]( https://hackage.haskell.org/package/warp ) is extremely competitive.

HN doesn't support full Markdown. :(

Re: Why I’m Learning Perl 6

#250
post #202

Earlier quoted context omitted.

Writing a purely functional function like, say, factorial, or the Ackermann function, was no problem at all. Writing a "purely" side effect-based one, say, read a string from stdin, parse an age, and say, "What, you are %d years old?!?! Wow, you're old!" completely eluded me. Maybe it was just that all the tutorials I encountered sucked. Maybe I am just too dumb for Haskell. Given that I currently really love Go, I k…

So yeah, I definitely get that. I'm no Haskell master, but I found that my code progressed this way (assuming I was trying to do what you mentioned": main :: IO () main = do putStrLn "Please input your age:" age = 40) (putStrLn "..." ++ (show age)) But as you get more comfortable, you get something like: type Age = Int -- Imagine there are constants here for youngAgeMessage, middleAgeMessage, and oldAgeMessage, -- fo…

This is a great comment outlining some of Haskell's strengths. Definitely, ADTs should exist in every language claiming their static type system as a feature.

Just one thing that stands out to me:

> "Anything can be anything or sometimes nil" is a hard pill to swallow once you've used Haskell.

In a language like Java yes, nearly every type is inhabited by null. In fairness, a similar problem exists in Haskell: every type is inhabited by "bottom" which is the computation that never terminates. This is a side effect of being lazy by default.

Post reply on HN