We are absolutely swimming in little languages. Consider these languages:<p>- The language of regular expressions<p>- SQL queries<p>- In web frameworks, the language of routes<p>- etc.<p>Unfortunately we embed a lot of these languages as strings. This is problematic because the language usually sees just opaque strings—we can't apply any of our lovely static analysis tools to these little embedded languages.<p>I'm doing some research in this area. We just got a paper published at ECOOP. The big idea is that, with a little bit of clever metaprogramming, we can help the type checker understand these little languages better and give us more helpful hints or execute more efficiently. This isn't a new idea, but no one has given it a name before. Here's the blog post version: <a href="https://lambdaland.org/posts/2024-07-15_type_tailoring/" rel="nofollow">https://lambdaland.org/posts/2024-07-15_type_tailoring/</a><p>(HN discussion): <a href="https://news.ycombinator.com/item?id=40990232">https://news.ycombinator.com/item?id=40990232</a>
I loved his articles in the ACM. They are collected in a book called Programming Pearls (<a href="https://www.amazon.com/Programming-Pearls-2nd-Jon-Bentley/dp/0201657880/" rel="nofollow">https://www.amazon.com/Programming-Pearls-2nd-Jon-Bentley/dp...</a>) I also liked his second book More:Programming Pearls (<a href="https://www.amazon.com/More-Programming-Pearls-Confessions-Coder/dp/0201118890/" rel="nofollow">https://www.amazon.com/More-Programming-Pearls-Confessions-C...</a>)<p>Some of the same articles, but with updates and added reader comments.<p>(I posted Amazon, but there is a ton on the used market)
Related:<p><i>“Little Languages” by Jon Bentley (1986) [pdf]</i> - <a href="https://news.ycombinator.com/item?id=17881705">https://news.ycombinator.com/item?id=17881705</a> - Aug 2018 (17 comments)
Building a language is too hard.<p>You need to create:<p>- Grammar, parser, compiler, interpreter (delete as appropriate)<p>- Editor plugins for nice syntax highlighting<p>- Language server<p>- Packages for common things<p>- Nice website (or no one will use it)<p>- etc...<p>So the pressure is always to shoe-horn a big existing language into you problem. Maybe you can build a nice library if your language has decent syntax (or little to no syntax). If you have an AST representation, you probably dump it to JSON etc.<p>I am curious if any projects are trying to make this easier.
Tcl was, or is, a nice way to add a language that's very flexible and customizable to a larger system. It's pretty easy to create your own DSL's with it.