Live data from Hacker News

Unusual Raku Features

buttondown.com

151–160 of 166 posts

Re: Unusual Raku Features

#151
post #91
post #77

Earlier quoted context omitted.

I once heard of a merger between a company that used Java, and another one that used Perl. After that merger, both teams were required to make a similar change. If I remember right, the Perl team was done before the Java team finished the design phase. Or something like that. The best aspect of Java is that it is difficult to write extremely terrible code. The worst aspect is that it is difficult to write extremely a…

If this was about my former $work: The company using Perl was able to double its turnover in 3 weeks. The company using Java was still in the design phase. Companies choose their tools depending on their internal culture. The company using Perl at the time was simply more agile. FWIW, the company that was using Perl is now using Java mostly. And yes, the culture of the company has changed. Not sure about cause and ef…

The thing is you can chose to write perl in a way that doesn't suck. The problem with TMTOWTDI is that with 18 people in a code base.... well its best to have a set of conventions when writing perl. Let's all agree to use 5.x.x with these features for example

Re: Unusual Raku Features

#152
post #113
post #79

Earlier quoted context omitted.

This has nothing to do with the halting problem. And I have no idea why you think there would be 'terrible consequences'. 2, 4, 8 ... * The `...` operator only deduces arithmetic, or geometric changes for up-to the previous 3 values. Basically the above becomes 2, 4, 8, * × 2 ... * Since each value is just double the previous one, it can figure that out. If ... can't deduce the sequence, it will error out. 2, 4, 9 ..…

Programming is not just a matter of slinging syntax at a problem. Good programmers need to develop a mental model of how a language works. Needing to do geometric sequences as syntax like that is clearly a parlor trick, a marginal use case. What goes through a good programmer's mind, with experience of getting burned by such things over the years, is "If Raku implements this parlor trick, what other ones does it impl…

Raku has features that would appeal to mathematicians. It might seem like a parlour trick to you but that doesn't make it so for everyone.

Re: Unusual Raku Features

#153
post #113

Earlier quoted context omitted.

Programming is not just a matter of slinging syntax at a problem. Good programmers need to develop a mental model of how a language works. Needing to do geometric sequences as syntax like that is clearly a parlor trick, a marginal use case. What goes through a good programmer's mind, with experience of getting burned by such things over the years, is "If Raku implements this parlor trick, what other ones does it impl…

Raku has features that would appeal to mathematicians. It might seem like a parlour trick to you but that doesn't make it so for everyone.

It's a parlor trick because something like "1, * × 2 ..." is much more sensible. Heck, it isn't even longer, if we're talking about saving keystrokes. It's still more syntax than I'm looking for from a language, but "initial, update rule, continue infinitely" does not give me that immediate "oh wtf, what other magic is going to happen with other values?" reaction I describe from trying to divine update rules from raw numbers.

It is also immediately obvious how to use this for other patterns, immediately obvious how to compose it, and just generally experiences all the benefits things get from not being special cases.

Re: Unusual Raku Features

#154

Earlier quoted context omitted.

Very late to the thread, but I was wondering if you knew of a good example of Raku calling an API over https, polling the API until it returns a specific value?

Here is one way: use HTTP::UserAgent; use JSON::Fast; my $url = 'https://api.coindesk.com/v1/bpi/currentprice.json'; my $ua = HTTP::UserAgent.new; my $total-time = 0; loop { my $response = $ua.get($url); if $response.is-success { my $data = from-json $response.content; my $rate = $data ; say "Current chart name: $rate"; #last if $rate eq 'Bitcoin'; last if $total-time ≥ 16; } else { say "Failed to fetch data: {$respo…

Wow, huge thanks, that's super helpful :)

Re: Unusual Raku Features

#155
post #106

Speed is still a major issue with Raku. Parsing a log file with a regex is Perl's forte but the latest Raku still takes 6.5 times as long as Python 3.13 excluding startup time.

You'd need to qualify that with an example. In my experience some things are faster in Raku and some are slower, so declaring that "Raku takes 6.5 times as long as Python 3.13" is pretty meaningless without seeing what it's slower at.

I specified the use case so why "meaningless"? Here's the code:

    Raku
    for 'logs1.txt'.IO.lines -> $_ { .say if $_ ~~ />/; }

    Python
    from re import search
    with open('logs1.txt', 'r') as fh:
        for line in fh:
            if search(r'\b\w{15}\b', line): print(line, end='')

Re: Unusual Raku Features

#156

Earlier quoted context omitted.

Here is one way: use HTTP::UserAgent; use JSON::Fast; my $url = 'https://api.coindesk.com/v1/bpi/currentprice.json'; my $ua = HTTP::UserAgent.new; my $total-time = 0; loop { my $response = $ua.get($url); if $response.is-success { my $data = from-json $response.content; my $rate = $data ; say "Current chart name: $rate"; #last if $rate eq 'Bitcoin'; last if $total-time ≥ 16; } else { say "Failed to fetch data: {$respo…

Wow, huge thanks, that's super helpful :)

Sure, good luck!

Re: Unusual Raku Features

#157
post #80

Earlier quoted context omitted.

Yea, I think he has a knack for that. If you want some more I recommend a talk he gave a few years back called “Three Little Words” https://www.youtube.com/watch?v=e1T7WbKox6s >.

Damian is an excellent writer and communicator for sure. But I don't know if it answers the question of what you would use these features in Raku for. If one wanted to compute e to higher precision, I feel like one would use a DSL. But we also don't need to compute e presently.

No, we don’t need to compute e very often; it’s value is pretty well known. The article is just showing off Raku (or Perl 6 as it was then known) by writing a small program of moderate complexity that still manages to show off some of Raku’s interesting features. Computing approximations of e is merely an interesting exercise; it’s not the point.

The question that justinator asked was what good uses Raku’s indefinite series have. This article points out that different ways of approximating e grow at different rates, so it is appropriate to associate a different range of trial values with each of those methods. Dörrie's bounds uses powers of 10 as shown. Others use powers of 2. Newton’s method uses sequential trial values, since it grows really fast:

    #| Newton's series
    assess -> \k=0..∞ { sum (0..k)»!»⁻¹ }
And several methods compute approximations in a single step, so they don’t take a trial value at all:

    #| Castellano's coincidence
    assess { (π⁴ + π⁵) ** ⅙ }

    #| Sabey's digits
    assess { (1+2**(-3×(4+5)))**(.6×.7+8⁹) }

    #| Piskorowski's eight 9s
    assess { (9/9 + 9**-9**9) ** 9**9**9 }
These are a lot of fun, but of course they can also be profound:

    #| From Euler's Identity
    assess { (-1+0i) ** (π×i)⁻¹ }
For those who are interested, the article shows off a lot of obvious syntactic features like superscripts and hyperoperators, but there are also things like classes and roles and new operators as well. It really is a nice tour.

Re: Unusual Raku Features

#158
post #80

Earlier quoted context omitted.

Yea, I think he has a knack for that. If you want some more I recommend a talk he gave a few years back called “Three Little Words” https://www.youtube.com/watch?v=e1T7WbKox6s >.

Ha, Conway, once again. His talks during early perl6 days were brilliant.. thanks for sharing

You’re welcome.

Re: Unusual Raku Features

#159
post #91

Earlier quoted context omitted.

If this was about my former $work: The company using Perl was able to double its turnover in 3 weeks. The company using Java was still in the design phase. Companies choose their tools depending on their internal culture. The company using Perl at the time was simply more agile. FWIW, the company that was using Perl is now using Java mostly. And yes, the culture of the company has changed. Not sure about cause and ef…

The thing is you can chose to write perl in a way that doesn't suck. The problem with TMTOWTDI is that with 18 people in a code base.... well its best to have a set of conventions when writing perl. Let's all agree to use 5.x.x with these features for example

These days you can TMTOWTDI in Python as well though.

The TMTOWTDI argument was valid in very early stages of Perl vs Python debate, like some what between 2000 - 2006 etc.

These days Python is just Perl with mandatory tab indentation. Python is no longer that small language, with small set of syntactical features. C++/Java etc in the meanwhile have gotten even more TMTOWTDI heavy over the years.

Re: Unusual Raku Features

#160
post #143

Earlier quoted context omitted.

Why are they called regular expressions if they can parse non-regular languages?

The word 'regular' comes from the mathematical roots of automata and finite state machines.

Which have a one to one correspondence with regular languages, so this isn’t actually an answer to the question.
Post reply on HN