A Preliminary Study on specific DSL languages

Source: Internet
Author: User

Http://tech.ddvip.com/2008-12/1229654190101204.html

 

The basic idea of domain specific language/DSL is "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. DSL was originally and ultimately a dream for programmers, just as January 1. People have been talking about DSL since the beginning of the computer's invention. In the past few years, with the rapid popularity of Ruby on Rails, known as the "specialized language in Web development", DSL has once again become a hot topic for discussion. Many people think that DSL will be the "next big thing" of the software industry ". However, with the increasing popularity of DSL, there are many questions and misunderstandings around DSL, such as the following:

The target audience of DSL is non-programmers, sales personnel or end users.

In many people's minds, DSL is equivalent to "non-programmer programming language". Therefore, the ultimate audience of DSL should be non-programmers, all DSL that are not directly used by end users are not real DSL. It is just another boring technique that makes the Code look different from the code.

This is a very interesting point of view. In fact, in the history of the development of computing programming languages, there have indeed been "non-programmer programming languages", and they are also very famous. They are Fortran, the first generation of high-level languages such as COBOL. In that era, the main purpose of computer science was scientific computing, while programmers specifically focused on geek who played with switches, relays, tapes, and assembly languages. The main beneficiaries of computers are not programmers-that is, those scholars and researchers-who have to entrust these people to help them transform from mathematical formulas to machine instructions. Therefore, the main purpose of the first-generation advanced language is to shorten the gap between computing formulas and executable code (such as Fortran), or to simplify the daily work of information administrators (such as COBOL ). Interestingly, these "non-programmers" developed software development into a legitimate and decent career.

 

In fact, the "non-programmer Programming Language" in those years is quite similar to the DSL situation today. What's different is that enterprise-level information systems are more complex today, the focus of attention is gradually shifting from computing to data, and the physical processes of the business field and the computer do not have simple and direct mappings. Moreover, with the refined social division of labor, even through DSL, we are still unlikely to launch all the well-dressed HR, sales, and department managers into new programmers.

I still want to admit that the DSL with the end user as the target audience is a very interesting and interesting idea, but it is not realistic for a long period of time. Maybe we need new methods (such as lean) to coordinate IT and business departments, maybe we need new software engineering theories, or some very original ways of working. Who knows? predicting the future is always hard and thankless, but I think in the current situation, simply limiting the DSL audience to non-programmers, salesmen or end users, it is debatable.

DSL = neat code

This idea is the opposite of the previous one. It treats DSL as a programmer's game, and all the skills that can write code neatly and well-looking are summed up as DSL.

Although DSL and "clean code" both have concise and clear features, they cannot be easily classified as equivalent. In terms of concept, the programming process is to express problems in the business field through code or program model:

Because the computer program model is relatively simple (in the final view, computing and storage), even today, when object-oriented technology becomes the mainstream, computer programs are unlikely to be consistent with concepts in the business field, or have some intuition. This is precisely because the modification and maintainability of the software are not as easy as imagined. We must constantly convert concepts in the business field into corresponding code models and then modify them. This indirect nature directly causes software complexity.

The main purpose of DSL is to eliminate such complexity (or replace it with the complexity of constructing DSL). DSL is to construct software in a way close to the business field. Therefore, DSL conciseness is often a kind of thought conciseness, so that we don't have to spend too much effort to understand the business meaning of the Code.

 

From this we can see that DSL and "clean code" are fundamentally different. "clean code" is a general requirement that the code is concise and easy to understand, rather than concerned with whether it is close to the business field. For example, for a J2EE developer, Dao, DTO, formbean, and action are clear enough, but they are not associated with DSL. DSL focuses more on the use of business words, as close as possible to the business model to write code, so that there is a simple correspondence between the business model and the program model.

Therefore, we cannot equate DSL with "clean code". It can only be said that DSL is a "clean code.

DSL must appear in the form of text code

Domain specified language, as its name implies, is a language. Therefore, DSL must appear in the form of text code. It is not a DSL that is not described by text code.

We prefer to use text code because it is easy to modify and highly efficient to modify. Software Engineering practices over the years show that text code is the most efficient form of editing. However, for DSL, the problem is somewhat different.

As we have mentioned earlier, the primary purpose of DSL is to bring programs as close as possible to problems in the business field, so as to eliminate unnecessary indirect and complexity. For most business fields, once the form of text code is good enough, we can easily describe problems in the business field through text in specific formats. Then there are some special fields, in which text code is not the best form. To better align with the concept in the business field, we may use some graphical DSL. For example, a popular domain specific modeling tool gems (generic eclipse Modeling System) uses a large number of different graphical DSL to express different aspects of the system. Therefore, we cannot simply limit DSL to text format.

DSL syntax should be as close as possible to English or other natural languages

Since most DSL are descriptive, we should try to bring the DSL closer to the commonly used English or other natural languages, so as to enhance the performance of the DSL.

 

Business natural language is an important branch of DSL. It is based on the fact that most enterprise applications use natural language-like syntaxes and structures to construct DSL, it can promote and promote communication between business personnel and programmers. dsl of natural language is easier to reuse than other DSL forms. Because of these characteristics, bnl dsl is the most popular in DSL practice. I personally implemented bnl dsl in different fields in three different projects. I even modified and refined the Smalltalk syntax, A general syntax expression script language is obtained. It can be used to easily construct DSL.

Although BNL is the most practical and favorite DSL form, we still cannot regard it as the only DSL form through the analysis above. We must keep in mind that the primary purpose of DSL is to bring programs as close as possible to problems in the business field, so as to eliminate unnecessary indirect and complexity. Reasonable and appropriate selection of syntax forms is always the top priority for DSL construction.

 

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.