Agile Expansion

The domain-specific language (DSL) plays an important role in modern software development because it is close to domain problems and can reduce the complexity of software development and maintenance. From a perspective of DSL implementation, the embedded DSL (eDSL) uses an existing general programming language as the host language and uses the language features provided by the host language to extend domain-oriented syntax. Compared with the implementation mode of independently constructing the DSL (dedicated syntax parsing, compilation optimization, and auxiliary tools), the eDSL has the following advantages:

  • The language features of the host language can be reused, and the expression capability is strong.
  • The auxiliary facilities of the host language (such as the library ecosystem, compilation tools, and development environment) can be reused, and the construction threshold is low.
  • Because the eDSL is seamlessly embedded into the host language project, data can be efficiently exchanged across domains.

Therefore, the eDSL is widely used in various domains, such as UI layout, database access, cloud infrastructure deployment, and script compilation. Accordingly, the Cangjie programming language provides rich language extension capabilities to support domain-oriented eDSL construction.

This section focuses on the language extension capabilities provided by the Cangjie language, including the extension capability based on the native syntax and the metaprogramming capability that allows developers to build new syntax. Finally, this section uses the declarative UI as an example to describe how to use the preceding capabilities and the effects.