HNHacker News
TopNewBestAskShowJobs

lizmat

1,154 karma · joined January 23, 2018

submissionscomments
lizmat··on Raku: A language for gremlins
> Lists are given to the reader in angle brackets and printed in parentheses, or at least that's how it looks. I suppose the other possibility is that these are actually different types

They are different types:

[1,2,3] is an array with mutable elements that can be expanded, shortened (1,2,3) is a list with immutable elements of fixed length

> find an example of anyone actually using it

A common example of signature introspection is when a routine accepts a lambda as a parameter, and adapts its function depending on the number of arguments the lambda expects (the arity: &foo.signature.arity, see https://docs.raku.org/syntax/Arity).

Two examples:

The "sort" function optionally accepts a lambda: if that takes one argument, then a Schwarztian transform will be done under the hood. If it takes two, then the lambda will be used as the comparator.

The "map" function expects a lambda. Depending on the number of arguments it takes, it will take that many arguments each time from the iterator it runs on.

say (1..12).map( -> $a, $b, $c { $a - $b * $c } ) # (-5 -26 -65 -122)

lizmat··on Raku: A language for gremlins
Perhaps. But that will become very difficult indeed.

Because in Raku, grammars are just a different way to write code. Grammars are really just specialized classes. And tokens / rules / regexes are just specialized methods. It all compiles down to bytecode, rather than something you can feed a statemachine.

This has several advantages: if a grammar doesn't provide functionality you need, you can write it in Raku code as part of the grammar.

It also means that when you improve execution of the bytecode, you will also improve the performance of grammars and regexes.

Finally: Raku grammars are very powerful. They are used to parse the Raku language itself. Which is a testament to its power. But also brings a whole set of challenges for the core developers :-)

lizmat··on Raku: A language for gremlins
`INIT $RAT-OVERFLOW = CX::Warn` will produce a warning whenever a switch to Num happens.

`INIT $RAT-OVERFLOW = Exception` will throw an exception whenever a switch to Num would happen.

If you want to define your own behaviour, you can. For instance:

class ZeroOrInf { method UPGRADE-RAT(Int $nu, Int $de) { $nu > $de ?? Inf !! 0 } } INIT $*RAT-OVERFLOW = ZeroOrInf

would either convert the value to `Inf`if too large, or to `0` if too small.

lizmat··on Raku: A language for gremlins
And for 1.5 years now, you can have the FatRat behaviour by simply adding `INIT $*RAT-OVERFLOW = FatRat` to your program.
lizmat··on Raku: A language for gremlins
Newer versions of Rakudo allow you to tune this behaviour dynamically through the $*RAT-OVERFLOW dynamic variable (which defaults to Num for the described behaviour).

See: https://docs.raku.org/language/variables#$*RAT-OVERFLOW*

lizmat··on Our Plan for Python 3.13
FWIW, the JVM is one of the supported backends of the Raku Programming Language. Has been for quite some time actually. It was the first additional backend supported after Parrot, and provided a template for supporting the MoarVM and Javascript backends since then.
lizmat··on Why Perl?
Raku (https://raku.org). But then I'm biased :-)
lizmat··on Why Perl?
Indeed. The original plan envisioned Perl being a slang in the Raku Programming Language. That plan failed because Perl is largely dependent on C-code plugins that are used whenever Perl is considered to be too slow (which is often). So being able to support Perl syntax in Raku, would only allow use of Perl-only modules from CPAN (of which there are way too few).

To counter that, Inline::Perl5 (https://raku.land/cpan:NINE/Inline::Perl5) was developed. It gives you access to 99.9% of Perl's functionality transparently, such as being able to subclass Perl classes in Raku, and vice-versa.

lizmat··on The Coolest Programming Language Features
> Larry Wall was so angry about closed java classes that he wanted them open and slow. On the other hand, Damian Conway, the perl6 designer, wanted them closed by default. You have to look at the current raku design if they are still open or closed.

You don't have to look at the design. You can look at the implementation. And in the implementation, they are closed. However, you can open them, but that invalidates any optimizations done so far. So generally, people don't do that, unless it is at compile time.

> One of the many reasons why raku is so slow.

Hi Reini, still the same grumpy person, eh?

At least Raku is NOT a language that is hooked on needing C extensions whenever it gets too slow. And judging by the amount of modules with C extensions on CPAN, that is quite often. This addiction will prevent it from ever moving forward.

lizmat··on Why Perl?
> Perl6 wasn't meant as replacement for Perl 5, v5 was meant to stay forever, maybe to be improved when possible. And that we have.

Sorry, but originally it was meant as the replacement (and I was physically present at its announcement at OSCON in 2000). It wasn't until 2008 when the "sister language meme" was generally accepted, that the paths diverged instead of being sequential.

lizmat··on Why Perl?
Saying that the Raku Programming Language is a flub, indicates to me that you do not know it at all. Getting Unicode support right by itself should be an indication that it is better than Python 3 in that respect. And let's not start about the fact that the Raku Programming Language does not have a GIL, allowing true multi-processing features and event handling.

https://raku.org

lizmat··on Why Perl?
I think it's a credit to the hard work many people are doing on the Raku Programming Language.
lizmat··on Why Perl?
Completely biased opinion: try Raku. It is easier to get into.
lizmat··on My 20 year career is technical debt or deprecated
In 2019 to be precise: https://raku.org
lizmat··on Ligatures in programming fonts: hell no (2019)
Note that the Raku Programming Language has pure ASCII equivalents for all operators as well, for the Unicode challenged. E.g. ≠ vs !=, ≤ vs <=, ≥ vs >= etc. etc.
lizmat··on Ask HN: What is new in algorithms and data structures these days?
subset OneToTen of Int where 1..10;

Why make it more complicated? :-)

The secret is that given values are smartmatched against the given object. And the values 1 through 10 will return True if smartmatched against the 1..10 Range object. The `of Int' ensures that only integer values are allowed, otherwise 3.14 would also match. Unless of course, that is what you intended. In which case you can omit the "of Int".

lizmat··on Why Janet?
$_ is generally referred to as "the topic" in documentation and Raku parlance.
lizmat··on K: We need to talk about group
No.

In the Raku Programming Language there are several non-ASCII operators, although each of them has a pure ASCII equivalent. Some examples: ≤ vs <=, ≠ vs !=, ∈ vs (elem), etc.

The full list: https://docs.raku.org/language/unicode_ascii.html

lizmat··on Will Carbon Replace C++?
Well, performance has been improved by several orders of magnitude since the first release. So maybe it's time to look at https://raku.org again (or first have a look at its new documentation site https://docs.raku.org)
lizmat··on Will Carbon Replace C++?
> It has avoided the missteps of Raku (Perl 6)

It is unclear to me what missteps you are referring to?

lizmat··on Why does 0.1 and 0.2 = 0.30000000000000004?
Actually, the limited precision is the default (caused by the numerator as well as the denominator having to fit in a 64-bit integer).

By default, when it not longer fits, it will convert to floating point (called Num in Raku). But this behaviour can be set: another alternative is for the numerator and denominator both being big integers. This gives you infinite precision rational numbers, at the expense of potentially needing infinite CPU and/or RAM.

lizmat··on CamelCase vs. underscores revisited (2013)
The rule for kebab-case (regardless of whether or not it has a sigil) in Raku is:

- each part of the identifier must start with an alpha character

- cannot end with -

So, "foo-bar" would be legal, "foo-" would not, "foo-4" would be considered "foo" - 4. If you want to substract two sigilless identifiers, you *must* have whitespace between them. So "foo - bar" instead of "foo-bar".

lizmat··on Microfeatures I'd like to see in more languages
That works, but isn't necessary in Raku. As long as the right side of the hyphen does not start with an alphabetic character, you're good:

my $a = 45; say $a-3; # 42

lizmat··on Pomsky – A portable, modern regular expression language
For a Raku Grammar tutorial, see https://docs.raku.org/language/grammar_tutorial
lizmat··on Pomsky – A portable, modern regular expression language
For those interested: https://docs.raku.org/language/grammar_tutorial
lizmat··on Ask HN: What are you excited about working on in 2023?
> if setup & battery installation isn't annoying

If you're on linux, it's only an apt-get (or similar) away: https://nxadm.github.io/rakudo-pkg/

lizmat··on Actually Portable Perl
https://raku.org
lizmat··on Tcl is faster than Python for database benchmarking
Indeed, Raku does not have a GIL
lizmat··on Eierlegende Wollmilchsau (2011)
Please Reini, stop being funny like this. It does not become you.

To everybody else: if you would like to see what the Raku Programming Language is about, check out an introduction https://raku.guide , or check out the weekly blog https://rakudoweekly.blog

lizmat··on A Review of the Art of the Metaobject Protocol (2010) [pdf]
> ... it doesn’t really look original, but more like a polishing of Perl.

Sure, Raku has its roots in Perl. But if multiple dispatch is the big thing for Julia, why wouldn't it be for Raku?

Other things Raku has that Perl doesn't have: - grammars built in, in fact Raku itself uses a Raku grammar to parse itself - a sane and genuine async / multi-thread / event model - Rational arithmetic, big integers and complex numbers by default - lazy lists: say (1..Inf)[42] won't hang - Junctions; a == 42 | 666 | 314 - Gradual typing and coercions

> I am not familiar with Raku, but

Perhaps it's time to familiarize yourself a bit more with Raku :-)

← PreviousPage 3 of 16Next →