3 ms·
Doesn’t necessarily have to be the host language. Just any other existing language. If it’s static and declarative, just use yaml. (Yes it sucks, but you get i
by Too 3y ago
Doesn’t necessarily have to be the host language. Just any other existing language.
If it’s static and declarative, just use yaml. (Yes it sucks, but you get it point)
If it’s imperative, just use the host language.
Then you have some hybrid solutions. HCL allowing rich expression in an otherwise very declarative language. A big list of constant dataclasses in python is another quick way to define complex data structures without having to reinvent anything. This even gives you type safety for free.
Heck, MongoDB managed to build big business on a database whose only query language is super verbose json. This isn’t just negative, because by leveraging existing language, a lot of tooling around is ready to plug in on day one.
- valenterry 3y agoActually, I disagree. The _by far_ easiest way is to use the host language itself. Using _any_ other language, e.g. yaml, forces you to do a lot of things that you get for free when using the host language, including syntax, type-checking/linting, build-system if you need one and especially all the tooling that comes with it for free (e.g. autocomplete in IDEs). In fact, there is almost no benefit at all of using yaml _for DSLs_. (And yes, there is widely-available syntaxhighlighting for yaml and others, but that doesn't over anything specific for the DSL, or otherwise you will have to customize it)
- Too 3y agoHost language is rarely ever declarative. Declarative languages are often necessary because they don’t leave any escape hatches that tempt you into writing incorrect code. Build system dependency graphs one common example. It’s also needed to pass data between different systems without recompiling and to constrain the usage boundaries, especially around security. Imagine how absurd it would be if mongodb queries were written in the host language C++ instead of json. For in-house stuff agree. There is no point to make excessive config layers if only developers will touch it anyway.
- valenterry 3y ago> For in-house stuff agree. There is no point to make excessive config layers if only developers will touch it anyway. Yeah, I'm specifically talking about in-house DSLs or those that are only used by/from specific users. That doesn't have to be developers, but they should be using the host language as well - and in that case, an imperative host language can still make it able to use a declarative DSL. (in the most basic way for instance: generate a datastructure that essentially describes a json/yaml or whatever) For non-inhouse DSL, I agree that it is usually worthwhile to make them standalone.