It is the job of modern programming languages to be amenable to abstractions. It should be easy for users to take a little bundle of functionality and

Thoughts on DuckDB's Grammar Patching Thing

submited by
Style Pass
2024-12-24 01:30:15

It is the job of modern programming languages to be amenable to abstractions. It should be easy for users to take a little bundle of functionality and reuse it, or build something more complex on top of it, or give it to someone else to use. A good programming language gives you a set of primitives and tools to combine them into more complex functionality.

is not something you should want to do! The development of programming languages over the past few decades has been, at least in part, a debate on how best to allow users to express ways of building new functionality out of the semantics that the language provides: functions, generics, modules.

What are you supposed to do, though, when you have a language (SQL) that is incredibly popular, unkillable, and complete hostile to abstraction? You go down dark, demonic pathways like "users should be able to change the syntax of the language at runtime." This DuckDB blog post and associated paper propose that you give extensions (written in a language that is not SQL) an abstraction that lets them rewrite the way the language itself is parsed.

I think this is...basically a good idea? Particularly for analytics queries which are much more likely to be one-offs and don't need active maintenance, it's actually sort of appealing to be able to syntactically extend the query language to express some new idea or to interface with some external tool.

Leave a Comment