Domain-specific language (DSL)

Source: Internet
Author: User
Tags new set
[Switch] domain-specific language (DSL)
The basic idea of domain specific language/DSL is "not seeking for specialization", which does not cover all software problems as the general target language does, it is a computer language dedicated to a specific problem. People have been talking about DSL since the beginning of computer invention.

The UNIX community is a community that frequently uses DSL. They are usually called mini languages or mini languages. (Eric Raymond's "Unix programming art" has a good discussion about this tradition .) To build a DSL, the most common UNIX-style approach is to first define its syntax and thenCodeThe generation technology converts DSL code into a common language code or writes an interpreter for this DSL. Unix has many tools to make it easier. I set a term for this type of DSL:"External DSL". Xml configuration files are another common form of external DSL.

DSL is also an important tradition of the lisp and smalltalk communities, but in different ways, they do not create a new set of languages, but make the general purpose language of Lisp or Smalltalk into DSL. (Paul Graham'sArticleThis is a wonderful story in "bottom-up programming .) ExploitationProgramming LanguageThe DSL defined by the built-in syntax structure is called"Internal DSL", Also called"Built-in DSL". This is a general strategy, not only applicable to lisp and smalltalk, but can be done in any language. When faced with problems, I always consider using this policy to define things with DSL functions to solve them, but lisp and smalltalkProgramThe progress is far-reaching.

There are further examples of these two kinds of DSL in my recent article "language workbench". I hope DSL can be used more widely, the advantages and disadvantages of these two styles are discussed in detail, and the latest development of language workbench tools is also introduced.

It was not until a character appeared that the DSL of internal and external traffic had moved towards an interesting convergence. He was pragdave. Following the tradition of UNIX, the pragmatic programmers has become a fan of DSL) the discussion on this topic in section 12th is fascinating-I simply call it "use the essentials 12 ). Dave said in a insightful interview that although code generation is his usual technique, it is rarely used in Ruby programming.

When I was designing, I often used the idea of building a DSL and so on-intentionally designing classes and methods into DSL. No matter what language I use, I try to do this. If I can't do it, I 'd be happy to switch to the code generation technology. Code Generation and similar technologies are widely used in larger systems of thoughtworks.

When do I need to draw a line between DSL and the main language? I think the answer to this question varies with the main language. When using Smalltalk, I almost never felt it necessary to separate a DSL, this requirement is very common when using C ++/Java/C.

Therefore, I think some languages are suitable for designing internal DSL, while others are not. It is suitable for the simple language of the "one path goes to the dark" style. In one aspect, they go farther and more purely than other traditional languages (for example, the functional style of lisp, smalltalk's "Object-message" idea). This is the conclusion I have drawn from the analysis of Lisp and smalltalk. Looking at Ruby, it is more conventional and larger than the first two, but it is still a good language for building internal DSL.

in this case, the language designer needs to make a good decision on the language's precision level, ensuring that regular content can be easily expressed, it also needs to provide comfortable syntax support for complicated things that are originally difficult to understand. In short, I think this is a very important point. I like smalltalk and Ruby to a much higher degree than I like Java or C #. The reason is that it is hard to say anything, the most common explanation is the difference between a static type and a dynamic type, but I don't think this statement is crucial, what is closer to the differences between the two is the difference in their degree of friendliness to build internal DSL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.