top | item 47166359

(no title)

itishappy | 3 days ago

Love this take! Unison is exactly this, and it's awesome!

Here's a quote from one of the creators:

> But here's the super cool thing about our language! Since we don't store your code in a text/source code representation, and instead as a typechecked AST, we have the freedom to change the surface syntax of the language very easily, which is something we've done several times in the past. We have this unique possibility that other languages don't have, in that we could have more than one "surface syntax" for the language. We could have our current syntax, but also a javascript-like syntax, or a python-like syntax.

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

discuss

order

fuzztester|3 days ago

Can Raku do something like this? I was lightly exploring it recently, and I thought I saw that something like this may be possible with it.

itishappy|3 days ago

I'm not super familiar with Raku, but if RakuAST is what you had in mind it looks a bit different:

    use experimental :rakuast;
    
    my $ast = RakuAST::Call::Name.new(
      name => RakuAST::Name.from-identifier("say"),
      args => RakuAST::ArgList.new(
        RakuAST::StrLiteral.new("Hello world")
      )
    );
Looks more like "low-level programming an AST" (which I believe other languages offer as well), rather than using a bidirectional transform. I don't know how you'd get Raku code back out, for example.

Edit: I should have looked deeper, `DEPARSE` does exactly this:

https://docs.raku.org/type/RakuAST

Neat!