49 pointsby ksec18 hours ago2 comments
  • vinceguidry15 hours ago
    This was amusing in a good way. I did write a few parsers in Ruby back in the day, the experience taught me that we already have the best syntax possible at our disposal, why not just lean on it. You get so much more when you don't have to leave Ruby. I find myself reaching for a DSL whenever I have to deal with a lot of less-expressive code / configuration.

    I'll write generators that take a DSL as input and spit out the mountain of boring stuff. Last time was to deal with keyd's[1] homegrown syntax, which is powerful, but not expressive. I made a gist for the curious.[2]

    Before finding keyd, I also took this approach with Xbindkeys config, and was on my way to wrapping Kubernetes in nice, friendly Ruby before I got canned.

    1. https://github.com/rvaiya/keyd

    2. https://gist.github.com/VinceGuidry/e85fa37e3e60f2dcb63c051c...

  • omneity13 hours ago
    A long time ago, I believed I wanted to implement a custom interpreter in Ruby. And then I discovered method_missing, and later on the rabbit hole that is Metaprogramming in Ruby, and that worked wonders to get the interpreter thought of my system, but not before implementing at least 3 DSLs of dubious value.

    While it worked great to gently expand my knowledge on what's possible in programming (I would have burned myself on a lisp, not for the lack of trying as I did with Haskell), it also taught me about the meaning of shooting oneself in the foot, and in a sense do not regret the absence of such powers in JS and Python, even if Proxy objects are dangerously close!