from Hacker News

Lingo: A Go micro language framework for building Domain Specific Languages

by adityasaky on 10/24/24, 7:23 PM with 50 comments

  • by wahern on 10/24/24, 11:23 PM

    When I think of a DSL, I think of a language with specialized syntax, grammar, or constructs suited to the problem domain. Think SQL, AWK, or regular expressions. This is just a LISP variant with a typical host-side API for registering function names.

    I'll never get how merely having function names that reflect the use case, plus a stripped down or absent standard library, qualifies as a DSL. I know some people have long used "DSL" in this way, especially among LISP fans, but... I just don't get it. If I want a DSL it's because I want something that gives me, e.g., novel control flow constructs a la AWK, or highly specialized semantics a la regular expressions, that directly suit the problem domain. If I'm not getting that kind of power, why tie myself to some esoteric dependency? Either way you're adopting a tremendous maintenance burden; it better be worth your while.

    I'm a huge fan of Lua and have used it for many projects in different roles, but never once thought of any particular case as having created a DSL, even when stripping the environment to just a few, well-named, self-describing functions.

    I don't mean to criticize this particular project. Good code is good code. It's just the particular conceptualization (one shared by many others, to be fair) of what a "DSL" means that bugs me.

  • by bitexploder on 10/25/24, 1:20 AM

    Disclaimer: this is a neat project.

    DSLs are such a trap for most projects that think they need them. Use lua or something off the shelf for scripting.

    CEL exists for Go and (safely) solves many of the problems you might also want a DSL for.

    The case for DSLs is often hard to justify in a project that has to be maintained for years.

  • by bezkom on 10/25/24, 1:59 PM

    There is already programming language called Lingo, though probably nobody uses it anymore: https://en.wikipedia.org/wiki/Lingo_(programming_language)
  • by Mikhail_Edoshin on 10/26/24, 8:39 AM

    A generic structure is not a notation. XML or S-expressions are a generic structure. A good practical test that shows limitations of this approach would be to try to write something like a picture description similar to Pikchr (PIC). It is possible, but the result will be far more verbose and obtuse than what you get with a real grammar and parser in Pikchr.
  • by wejick on 10/25/24, 12:16 PM

    Unfortunately the given example doesn't give - mere mortal like me- idea on how this make sense to use. Instead of using whatever scripting language available, or just json.

    Or probably grule? [1] https://github.com/hyperjumptech/grule-rule-engine

  • by Lyngbakr on 10/24/24, 10:52 PM

        > Some popular DSLs most software developers use on a regular basis include Regular Expressions for pattern matching, AWK for text transformation or Standard Query Language for interacting with databases.
    
    Isn't it Structured Query Language? Or are both variants used?
  • by codetrotter on 10/25/24, 2:33 AM

    Not to be confused with the Lingo programming language that was used in Macromedia Director to create Shockwave content ;)

    https://en.wikipedia.org/wiki/Lingo_(programming_language)

    https://en.wikipedia.org/wiki/Adobe_Shockwave

    https://en.wikipedia.org/wiki/Adobe_Director

  • by allknowingfrog on 10/25/24, 2:59 PM

    This is a bit of a tangent, but this is how I would actually solve the problem in Ruby:

      #!/usr/bin/env ruby
    
      require "csv"
    
      puts CSV.foreach(ARGV[0], headers: true).sum { _1[1].to_f }.round(2)
  • by ofrzeta on 10/25/24, 6:18 AM

    I don't know. Last update two years ago when the project was first posted. Is it worth spending time on it?
  • by justinko on 10/25/24, 2:18 PM

    The verbosity of “fed through an LLM” articles are becoming unbearable to digest.
  • by Alifatisk on 10/24/24, 9:55 PM

    Regarding the Ruby example, why did they use Float("...") instead of #to_f?
  • by dlock17 on 10/24/24, 8:43 PM

    This seemed like nuclear overkill for most problems I can think of.

    And where it should be used, I can't imagine you can't find a pre existing language (Cuelang maybe) instead.

    I was expecting a section at the end where they demonstrate which services need a new language written just for it's configuration, but nope, just general examples.

    Also, this should have a (2022) in the title.