Building Domain Specific contexts using DSLs in Golang Go в продуктовой разработке
Founder/CTO @ Last9
DSL are common to almost all developer tools. They abstract the complexity of logic that developers need to repeat, and provide simple reusable functions to the consumer. At the same time, the datatypes, expressions, and statements can be limited and statically verified to prevent Latent Bugs that configuration languages have to suffer from.
In this session, I will take a small use case of building alerts against some queries a database. But rather than allow developers to send naked queries against my database, I would rather expose a DSL that transpiles the DSL to the appropriate queries to the data storage backend. This has multiple advantages:
* Developer doesn't have to worry about the underlying change in Implementation. It's like an API call, only as a system command.
* We have tight control of what queries need to be executed really. This is done to have control over the performance of the queries sent to the datastore
* Any complex set of inputs, do not have to be passed as long function / SDK arguments.
One such example is Terraform. It's a DSL that allows functions as well as some degree of expressions to wrap repeat tasks underneath.
The session's aim is to leave the audience with a framework and understanding of the ease of writing such DSLs. There is some code, some snippets and a use case to build a DSL for.
The job of the DSL doesn't end there, a good DSL nudges the developer to make less mistakes and catch as much as possible earlier. And occasionally add support for inbuilt more functions. The lifecycle of DSL is covered during the talk, accompanied with code samples.
The DSL, that will be demonstrated, is being used at Last9 to alert customers in real-time using a variety of data backends at a substantial concurrency.