Hacker Newsnew | past | comments | ask | show | jobs | submit | librasteve's commentslogin

embrace the brace, dude

well Raku has the Slangify module https://raku.land/zef:lizmat/Slangify

thought I’d try the showcase example in Raku (https://raku.org), so this Gleam

  import gleam/io

  pub fn main() {
    io.println("hello, friend!")
  }
becomes this Raku

  say “hello, friend!”
well maybe you really want to have a main() so you can pass in name from the command line

  #!/usr/bin/env raku

  sub MAIN($name) {
    say "hello, $name!”
  }

Oh God, they actually put that awful logo front and center.

I'd always thought it would be a go-like thing where the put the mascot away for everything except for the minor hero section or buried in the footer.

RIP Perl.


lol - I had the temerity to raise the "how about a new logo" topic last week and it's going to time time for me to (hopefully) convince the community of the need to let go

Raku looks sweet, but what is the point of this comparison? :)

I love coding in Raku - and I am sure that Gleam is nice too. But I get the feeling that Raku is underappreciated / dismissed by many due to the perl5 / perl6 history. So my thinking is, when I see a new language showcase an example on their website, presumably a carefully chosen snippet that showcases their language at its best, I like to see how Raku compares to that.

You know the take-aways from the comparison are quite instructive:

- do I need to import the io lib? (shouldn't this just be included)

- do I need a main() in every script? (does this rule out one liners like `> raku -e "say 'hi'"`)

- is `io.println` quite an awkward way to spell `print`?

I am not making the case that these are right or wrong language design decisions, but I do think that they are instructive of the goals of the designers. In the case of raku its "batteries included" and a push for "baby raku" to be as gentle on new coders as eg. Python.


The differences you mentioned are advantageous for Gleam depending on what you want. Like, having to namespace symbols instead of implicitly importing symbols makes it explicit where things come from which is good. Needing main, same thing. But the big differences are that Gleam is both functional, so everything is immutable, and fully typed safe. Completely the opposite of Perl/Haku so comparing these languages makes zero sense. If you don’t need types or functional programming you probably would just never use Gleam.

I think comparing 'printing hello world' programs isn't particularly useful, except that from how you describe it, Raku sounds more like a scripting language, which Gleam is not.

In comparison with Gleam, I would be more interested to see how good Raku is at helping the programmer prevent errors through static analysis, how easy it is to build with concurrency, how much value the language puts into being easy to understand and reason about, and whether it can run on the server as well as compile to JS.

I have no negative predisposition, I don't really care about the history of pearl or whatever, I have looked at Raku before but I find the syntax very foreign, and the fact that it seems to (maybe optionally?) incorporate glyphs that I can't easily type with a keyboard.

I love the butterfly though, so I'd love to get to know the language more.


> But I get the feeling that Raku is underappreciated / dismissed by many due to the perl5 / perl6 history.

Yes that would be me! If you like making these comparisons, can you write the following pattern matching in Raku?

    import gleam/io
    
    pub type Fish {
      Starfish(name: String, favourite_colour: String)
      Jellyfish(name: String, jiggly: Bool)
    }
    
    pub fn main() {
      handle_fish(Starfish("Lucy", "Pink"))
    }
    
    fn handle_fish(fish: Fish) {
      case fish {
        Starfish(_, favourite_colour) -> io.println(favourite_colour)
        Jellyfish(name, ..) -> io.println(name)
      }
    }

sure...

  role Fish { has Str $.name }

  class Starfish  does Fish { has Str $.favourite-colour; }
  class Jellyfish does Fish { has Bool $.jiggly }

  sub handle-fish(Fish $fish) {
    given $fish {
      when Starfish  { say .favourite-colour }
      when Jellyfish { say .name }
    }   
  }

  handle-fish Starfish.new: :name("Lucy"), :favourite-colour("Pink");
I would probably reach for multi-dispatch...

  role Fish { has Str $.name }

  class Starfish  does Fish { has Str $.favourite-colour; }
  class Jellyfish does Fish { has Bool $.jiggly }

  multi sub handle-fish(Starfish  $fish) { say $fish.favourite-colour }
  multi sub handle-fish(Jellyfish $fish) { say $fish.name }

  handle-fish Starfish.new: :name("Lucy"), :favourite-colour("Pink");

Here's the other Gleam concurrency example in Raku for good measure:

  my @promises;

  sub MAIN() {
    # Run loads of green threads, no problem
    for ^200_000 {
      spawn-greeter($++);
    }

    await Promise.allof(@promises);
  }

  sub spawn-greeter($i) {
    @promises.push: start {
      say "Hello from $i";
    }
  }

mobile phones are primarily a military technology

I made a website in HTMX (https://raku.org) to celebrate that I can use my preferred language on the server side. It’s no frills, generally static and HTMX is just to goose up some of the UX dynamism. It was a very nice experience and I recommend https://htmx.org/examples for the kind of cool things you can do. otoh, I would not build Google Maps with this tool :-)

And most users will have no idea. They just know that it's a super clean, easy to read page that conveys the message you have about Raku.

Yet the biggest benefit is for you; in 3 months or 3 years you'll return to this web site and make some changes, and you'll instantly know what's up. No super complex React / TypeScript / Node app that won't even build.


hell yes


I have started gathering DSL specific content over on https://reddit.com/r/domainspecificlangs … there are several definitions over there. Personally I would distinguish between a drop down DSL and a full blown independent language.

Well, maybe. The problem is that mature languages and ecosystems are mature and new features have to be shoehorned in. Raku (https://raku.org) on the other hand is intentionally designed as a braid of sub languages (slangs) for quoting, regex, PEG, etc and you can easily make your own slang with eg. https://raku.land/zef:lizmat/Slangify so you get your DSL as a drop down language in a general PL setting.

There's so many languages out there, I reject Raku out-of-hand simply since IMO the type should follow the variable name.

You mean like:

    my $a of Int = 42;
    say $a;  # 42
or

    my $a of Int = "foo";'       
    # Type check failed in assignment to $a; expected Int but got Str ("foo")

?

hmmm Raku is C style

  int number;

 … you choose Pascal style

  number : Integer;

Very good, I wrote Pascal many years ago, but I was thinking more Kotlin/Scala (right?) vs Java.

Suggest you take a look at https://raku.org for a strongly (but gradual) typed scripting language.

that's just perl with a new coat of paint

Perl 5 does not have types, as far as I know.

I’m taking the GP seriously instead of dismissing it. Raku looks like more fun than nushell tbh.



    print 42 + 99;          # 141
    print &print.file ;     # ...src/core.c/io_operators.rakumod
    print &infix:<+>.file;  # ...src/core.c/Numeric.rakumod
    print ?CORE::<&print>;  # True 
I barely understood these four example lines.

It has. They are just poorly supported and disliked.

Lead paint with asbestos sprinkles and radium racing stripes! ;)

it is so much slower to start than perl, that you don't want to run it for quick one-off tasks

well waiting for Raku (formerly perl6) to be built was like watching paint dry

They should have named it Godot. ;) But now that name is taken.

waiting for a MacBook Vapour

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: