14 ms·
Java annotations can support compile time validation (e.g. see micronaut or checker framework). DSLs don't.
by al_mandi 4y ago
Java annotations can support compile time validation (e.g. see micronaut or checker framework). DSLs don't.
- Banana699 4y ago> DSLs don't. DSL is a general name to any embedded language inside a host language. C++'s templates can be used to write DSLs, they are compile-time checked. Kotlin's lambda syntax can also create very convincing DSLs[1] to describe hierarchical structures\processes, and they are fully typed, compile-time checked constructs. There are far more to DSLs than hacky strings (regex) or chaining method calls at runtime (fluent APIs). It's a very general pattern. [1] Example from https://kotlinlang.org/docs/type-safe-builders.html https://kotlinlang.org/docs/type-safe-builders.html html { head { title {+"XML encoding with Kotlin"} } body { h1 {+"XML encoding with Kotlin"} p {+"this format can be used as an alternative markup to XML"} } }