← Back to context

Comment by librasteve

1 year ago

raku - the bastard child of functional and OO

  class MyTable is export {
    has @.data;
 
    multi method new(@data) {
      $.new: :@data;     
    }

    method render {
      table :border<1>,
        tbody do for @!data -> @row {
          tr do for @row -> $cell {
            td $cell              } };
    }
  }

Many languages like Ruby have sweet "Syntactic Sugar", but Raku has "Syntactic Syrup of Ipecac".

  • lol - thanks for adding to my vocab!

    [in defence of raku, while it truly is marmite wrt Ruby / Python, there is a very loyal core of smart people that love the freedom and expressiveness it offers]

    • > there is a very [tiny, very] loyal core of smart people

      FTFY ;) Honestly, I love Raku - it's almost like Racket of the non-sexp world - but the community is microscopic, and the development is slow. It's a shame because, solely based on features and in terms of design, it's a serious contender for the most powerful dynamic language out there. It's packed with interesting features (junctions, phasors, traits, quote/unquote macros (soon), typed variables and subsets, coercible types, augment, OO system with multiple inheritance, interfaces, generics, multi-subs and multi-methods everywhere, custom operators including circumfix, regexes and grammars, etc, etc...) out of the box and it's actually really impressive how all these features work together in a cohesive design.

      Unfortunately, the underlying implementation seems a bit chaotic; some features are either not fully implemented or specified, the performance could be better, and so on. So, while I love and still use Raku for almost all my scripting, if I were to start a serious project, I think I'd go with Common Lisp instead. CL has fewer features out of the box, but many of the missing ones are one `ql:quickload` away (or you can use CIEL), while the underlying implementation (SBCL in my case) is diamond-solid.

      ---

      Aside: that `render` method could be sweetened a lot! For example:

              tbody @!data.map: { tr .map(&td) } ==> table :border<1>
      

      or:

              tbody @!data.map(*.map(&td).&tr) ==> table :border<1>
      

      or finally (using the fact that hyper descends into subarrays):

              tbody @!data».&td.map(&tr) ==> table :border<1>
      

      (I think Raku is unrivaled in one-liners!)

      2 replies →