Live data from Hacker News

Why I’m Learning Perl 6

evanmiller.org

371–380 of 380 posts

Re: Why I’m Learning Perl 6

#371
post #298
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…

I felt the same for a long time. At first glance something like import Text.Printf main :: IO () main = do age String formatAge age = printf "What, you are %d years old?!?!?! Wow, you are old" age might look nice and imperative. But then you realize it is just syntactic sugar for `main = readLn >>= printf ...`, which is incredibly confusing when coming from another language. And then you learn that libraries can just…

> The haskell book[1] is apparently really helpful with this but it also costs 60$ and is over a thousand pages so it's a pretty large investment in both time and money.

For a really good book on programming, I'll happily pay 60 bucks. I will put that on my Christmas wish list, and give it another try next year.

Re: Why I’m Learning Perl 6

#372
post #358
post #333

Perl 6 carries 2 pieces of baggage from its predecessor - prefixing variables with "my" to create lexical scope and the obligatory "use v6;" at the top of every script. Why can't an advanced language like Perl 6 scope variables without littering "my" everywhere? You don't see it in any other mainstream language I can think of.

How is this different than prefixing variables with var in JavaScript?

Just to be pedantic ;)

var creates variables that are function scoped. my creates variables that are block scoped.

let in JavaScript would be pretty much the same as my.

Both are good things as they prevent typos from being new variables.

Re: Why I’m Learning Perl 6

#373
post #161
post #121

Earlier quoted context omitted.

Nobody's using P6 for legacy code.

What kind of sane person who would use Perl ( 6 or older ) on a new project nowdays.

Lots of "sane" people would (at least for Perl 5). I know it's not "the new hotness", but Perl 5 is still an incredibly useful language that a lot of people know (present company included). There are extensive libraries available for doing a lot of things that need to be done in day-to-day business. There are plenty of perfectly legitimate places to use it in new development.

The Perl 5 porters development list has a decent amount of traffic ( http://www.nntp.perl.org/group/perl.perl5.porters/2017.html ). And Perl 5 still has a good number of active contributors ( https://www.openhub.net/p/perl/contributors ). Also, The CPAN has plenty of modules with daily activity ( http://search.cpan.org/recent ).

Even if you would not choose to do new development in Perl 5 (because of other language preferences, or whatever), that does not mean it is unreasonable (or "insane") for others to do so.

Whether Perl 6 will ever catch on, I don't know. The language has a lot of features that look interesting, and I think it could also be very useful. I personally have not had time to look at it much yet, but probably will when I don't have higher priority things in life preventing me from doing so.

Re: Why I’m Learning Perl 6

#374
post #290

Earlier quoted context omitted.

Are you saying that Perl6 grammars are a replacement (maybe eventually) for Perl5 regexps?

partly, you still build Grammars out of "token", "regex" and "rule" definitions, but some things are more natural with one or the other. So, if you are doing "test if string has whitespace" you'd use a regex, while for "parse an apache log line" you'd probably use a grammar instead of a very nasty regex. IANA perl6 dev though, just a casual observer.

Thanks, riffraff and kbenson.

Re: Why I’m Learning Perl 6

#375
post #369
post #136

Earlier quoted context omitted.

FWIW, I, too, have tried learning Haskell and ended up banging my head against the wall over and over. With Lisp, I eventually "got it", but Haskell has evaded my attempts at understanding it with impressive stubbornness[1]. Disclaimer: I do not hate Haskell, I just don't "get it". If you love the language, fine, have as much fun with it as you possibly can. I for one have given up, at least for now. Maybe I'll try a…

I totally understand your frustration with Haskell. I understand the tutorials and have read though the books available, but when I try to use the language on a small real project, say a 2d barcode generator, I have trouble getting off the ground. Its not even clear to me which set of features are recommended for the language. It seems like different users program in different, incompatible, languages! Here is a list…

> It seems like different users program in different, incompatible, languages!

None of them are incompatible as far as I am aware. If they are, I'm sure it's in very minor ways that don't occur in practice.

Re: Why I’m Learning Perl 6

#376

Earlier quoted context omitted.

I have seen examples where the naive Perl 6 implementation is faster than the equivalent C code. (The one I'm thinking of is probably owing to Spesh and the JIT, but I forget what it was about) Here's an example where a naive Perl 6 version is going to beat the pants off of the naive version in another language: Find the sum of all integers from 10 to 1000000 inclusive. In Perl 6: say [+] 10 .. 1000000 the [+] is a l…

That's pretty cool! I started trying to learn perl6 and write my first interesting program. I have a copy of 'ray tracing in a weekend' and am trying to translate the basic ray tracer from c++ to perl6. It's remarkably slow right now.. It takes 1.5 minutes to generate an image. I tried to do the same thing in Julia and it takes 1.5 seconds. So I guess I must be doing something wrong!

Probably not wrong but quite possibly in a way that's not been optimised well. I'm sure people on Freenode IRC #perl6 would be interested in your work. Don't forget `perl6 --profile script.p6` gives nice profiler output out of the box!

Re: Why I’m Learning Perl 6

#377
post #375
post #369

Earlier quoted context omitted.

I totally understand your frustration with Haskell. I understand the tutorials and have read though the books available, but when I try to use the language on a small real project, say a 2d barcode generator, I have trouble getting off the ground. Its not even clear to me which set of features are recommended for the language. It seems like different users program in different, incompatible, languages! Here is a list…

> It seems like different users program in different, incompatible, languages! None of them are incompatible as far as I am aware. If they are, I'm sure it's in very minor ways that don't occur in practice.

I'm sorry, I don't understand or maybe I wasn't clear. These extensions change the meanings (semantics and syntax) of Haskell programs accepted by the compiler. A program which would normally terminate using Haskell's ordinary lazy semantics might not terminate when using the Strict extension that changes the default semantics to less lazy.

As far as I can tell from blogs like [1], the other language extensions also change the language in ways that are not forward and backward compatible with out-of-the-box Haskell.

[1] https://ocharles.org.uk/blog/

Re: Why I’m Learning Perl 6

#378
post #377
post #375

Earlier quoted context omitted.

> It seems like different users program in different, incompatible, languages! None of them are incompatible as far as I am aware. If they are, I'm sure it's in very minor ways that don't occur in practice.

I'm sorry, I don't understand or maybe I wasn't clear. These extensions change the meanings (semantics and syntax) of Haskell programs accepted by the compiler. A program which would normally terminate using Haskell's ordinary lazy semantics might not terminate when using the Strict extension that changes the default semantics to less lazy. As far as I can tell from blogs like [1], the other language extensions also…

You were perfectly clear, but just mostly incorrect, I think.

You are correct that Strict is a language extension that significantly changes the semantics of a Haskell program. It's a new extension so it didn't cross my mind. But besides Strict the number of extensions that change semantics of existing programs in a significant but non-forward and -backward compatible way is very, very small.

Basically, the summary of Haskell extensions is:

Around half of them are new features that should be in the language standard but aren't because a new standard hasn't been produced for years. Around half of them extend (not change) the language in powerful ways and are best avoided unless you really need them. Around Ɛ% are things that significantly change the semantics, and 0% are things that mean you're programming in a "different, incompatible, language" (all extensions are compatible across module boundaries).

Re: Why I’m Learning Perl 6

#379
post #378
post #377

Earlier quoted context omitted.

I'm sorry, I don't understand or maybe I wasn't clear. These extensions change the meanings (semantics and syntax) of Haskell programs accepted by the compiler. A program which would normally terminate using Haskell's ordinary lazy semantics might not terminate when using the Strict extension that changes the default semantics to less lazy. As far as I can tell from blogs like [1], the other language extensions also…

You were perfectly clear, but just mostly incorrect, I think. You are correct that Strict is a language extension that significantly changes the semantics of a Haskell program. It's a new extension so it didn't cross my mind. But besides Strict the number of extensions that change semantics of existing programs in a significant but non-forward and -backward compatible way is very, very small. Basically, the summary o…

Thanks, I won't give up on Haskell yet. You make a good point that should have been obvious to me: the extensions are confined to the module boundaries.

Re: Why I’m Learning Perl 6

#380
post #379
post #378

Earlier quoted context omitted.

You were perfectly clear, but just mostly incorrect, I think. You are correct that Strict is a language extension that significantly changes the semantics of a Haskell program. It's a new extension so it didn't cross my mind. But besides Strict the number of extensions that change semantics of existing programs in a significant but non-forward and -backward compatible way is very, very small. Basically, the summary o…

Thanks, I won't give up on Haskell yet. You make a good point that should have been obvious to me: the extensions are confined to the module boundaries.

Good luck on your Haskell journey! I hang out on https://www.reddit.com/r/haskell/ so feel free to come over there if you have any questions.

(And to add some precision, some extensions may be visible across boundaries, but almost all are not, and the extent to which they are is very small).

Post reply on HN