3 ms·
I thought it would be interesting to try the showcase examples in Raku (since I am always saying how good Raku's imitation of Ruby is)... - https://glot.io/s
by librasteve 10mo ago
I thought it would be interesting to try the showcase examples in Raku (since I am always saying how good Raku's imitation of Ruby is)...
- https://glot.io/snippets/he42jpfm27
- https://glot.io/snippets/he42trx6w6
- https://glot.io/snippets/he434b6ryj
Obviously Raku leans more to `{}` and `my $var` than Ruby - but otherwise I think it does a credible job. Obviously these are carefully chosen Ruby snippets to highlit its unique abilities in strings, "array math" and classes. On the string interpolation, I would say that Raku has the slight edge (and has the whole Q-slang for a lot of fine grained control). On the array math, I had to apply the (built in) Raku set diff operator ... so I guess that Ruby is a little more natural for this (rather quirky) feature. On the class stuff, again very close. Raku has much more powerful OO under the hood ... multi-inheritance, role-composition, punning, mixins, MOP, and yet is a delight to use in this lightweight way.
- christophilus 10mo agoMan. Haven’t thought about Raku for a while. Does it have a good web framework these days?
- yawaramin 10mo agoSee https://rakujourney.wordpress.com/2025/03/30/the-harc-stack/ https://rakujourney.wordpress.com/2025/03/30/the-harc-stack/
- librasteve 10mo agoThe leading web framework for Raku is Cro (https://cro.raku.org https://cro.raku.org) . Cro has deep support for distributed architectures and middleware pipes and a nice templating language. my Cro $service; # geddit? There are others, notably the more lightweight Humming-Bird https://raku.land/zef:rawleyfowler/Humming-Bird https://raku.land/zef:rawleyfowler/Humming-Bird Also, if you want a more opinionated, HTMX centric web application library, then https://harcstack.org https://harcstack.org was used to make the new https://raku.org https://raku.org site
- librasteve 10mo agothat’s a name I haven’t heard in a while
- yawaramin 10mo agoFor fun, I did the same for OCaml: Ex 1 let say = "I love OCaml" let () = print_endline say (* Requires linking in the 'str' library *) let say = Str.replace_first (Str.regexp {|\(.*\)love\(.*\)|}) {|\1*love*\2|} say;; let () = print_endline (String.uppercase_ascii say) let () = ignore |> Seq.init 5 |> Seq.iter (fun () -> print_endline say) Ex 2 module StringSet = Set.Make(String) let cities = StringSet.of_list [ "London"; "Oslo"; "Paris"; "Amsterdam"; "Berlin"; ] let visited = StringSet.of_list ["Berlin"; "Oslo"] (* Requires the 'fmt' library *) let string_set fmt v = Fmt.Dump.list Fmt.string fmt (StringSet.to_list v) let () = Format.printf "I still need to visit the following cities: %a\n" string_set (StringSet.diff cities visited) Ex 3 module Greeter : sig type t val make : string -> t val salute : t -> unit end = struct type t = { name : string } let make name = { name = String.uppercase_ascii name } let salute t = Format.printf "Hello %s\n" t.name end let g = Greeter.make "world" let () = Greeter.salute g Obviously, OCaml is a much lower-level language than Ruby or Raku–notably, regex support is not as great, and we have to explicitly tell it how to print values of custom types. Still, I find its lack of syntax sugar makes it easy to read nearly any OCaml code I come across in the wild!