Domain-Specific Languages

Domain-Specific Languages

Michael Hunger

WHENEVER YOU LiSTEN TO A DiSCUSSiON BY ExPERTS in any domain, be it chess players, kindergarten teachers, or insurance agents, you’ll notice that their vocabulary is quite different from everyday language. That’s part of what domain-specific languages (DSLs) are about: a specific domain has a specialized vocabulary to describe the things that are particular to that domain.

In the world of software, DSLs are about executable expressions in a language specific to a domain, employing a limited vocabulary and grammar that is readable, understandable, and—hopefully—writable by domain experts. DSLs targeted at software developers or scientists have been around for a long time. The Unix “little languages” found in configuration files and the languages cre- ated with the power of LISP macros are some of the older examples.

DSLs are commonly classified as either internal or external:

Internal DSLs

Are written in a general-purpose programming language whose syntax has been bent to look much more like natural language. This is easier for languages that offer more syntactic sugar and formatting possibilities (e.g., Ruby and Scala) than it is for others that do not (e.g., Java). Most internal DSLs wrap existing APIs, libraries, or business code and provide a wrap- per for less mind-bending access to the functionality. They are directly executable by just running them. Depending on the implementation and the domain, they are used to build data structures, define dependencies, run processes or tasks, communicate with other systems, or validate user input. The syntax of an internal DSL is constrained by the host language. There are many patterns—e.g., expression builder, method chaining, and annotation—that can help you to bend the host language to your DSL. If the host language doesn’t require recompilation, an internal DSL can be developed quite quickly working side by side with a domain expert.

??46

97 Things Every Programmer Should Know

?

???????????????External DSLs

Are textual or graphical expressions of the language—although textual DSLs tend to be more common than graphical ones. Textual expressions can be processed by a toolchain that includes lexer, parser, model transformer, gen- erators, and any other type of post-processing. External DSLs are mostly read into internal models that form the basis for further processing. It is helpful to define a grammar (e.g., in EBNF). A grammar provides the starting point for generating parts of the toolchain (e.g., editor, visualizer, parser generator). For simple DSLs, a handmade parser may be sufficient—using, for instance, regular expressions. Custom parsers can become unwieldy if too much is asked of them, so it makes sense to look at tools designed specifically for working with language grammars and DSLs—e.g., openArchitectureWare, ANTLR, SableCC, AndroMDA. Defining external DSLs as XML dialects is also quite common, although readability is often an issue—especially for nontechnical readers.

You must always take the target audience of your DSL into account. Are they developers, managers, business customers, or end users? You have to adapt the technical level of the language, the available tools, syntax help (e.g., IntelliSense), early validation, visualization, and representation to the intended audience. By hiding technical details, DSLs can empower users by giving them the abil- ity to adapt systems to their needs without requiring the help of developers. It can also speed up development because of the potential distribution of work after the initial language framework is in place. The language can be evolved gradually. There are also different migration paths for existing expressions and grammars available.

时间: 2024-10-14 11:59:45

Domain-Specific Languages的相关文章

Domain Specific Biases(Geographical influence)Updated Aug,11st

data used :foursquare NYC data, this code has not been finished yet.. here  is the link: https://github.com/FassyGit/LightFM_liu/blob/master/DomainBiases.py I have succeeded in calculating the distannces, there are some functions in the codes. I will

Domain Driven Design and Development In Practice--转载

原文地址:http://www.infoq.com/articles/ddd-in-practice Background Domain Driven Design (DDD) is about mapping business domain concepts into software artifacts. Most of the writings and articles on this topic have been based on Eric Evans' book "Domain Dr

计算机会议排名等级

http://blog.sina.com.cn/s/blog_9c411c310102vs2g.html 附件是计算机领域的学术会议等级排名情况,分为A+, A, B, C, L 共5个档次.其中A+属于顶级会议,基本是这个领域全世界大牛们参与和关注最多的会议.国内的研究者能在其中发表论文的话,是很值得骄傲的成就.A类也是非常好的会议了,尤其是一些热门的研究方向,A类的会议投稿多录用率低,部分A类会议影响力逐步逼近A+类会议.B类的会议分两种,一种称为盛会级,参与的人多,发表的论文也多,论文录用

http://sculptorgenerator.org

Sculptor is an open source productivity tool that applies the concepts fromDomain-Driven Design and Domain Specific Languages for generating high quality Java code and configuration from a textual specification. Easy to learn, intuitive syntax of the

SCI&EI 英文PAPER投稿经验【转】

英文投稿的一点经验[转载] From: http://chl033.woku.com/article/2893317.html 1. 首先一定要注意杂志的发表范围, 超出范围的千万别投,要不就是浪费时间;另外,每个杂志都有他们的具体格式要求,一定要按照他们的要求把论文写好,免得浪费时间,前些时候,我的一个同事向一个著名的英文杂志投稿,由于格式问题,人家过两个星期就退回来了,而且说了很多难听的话,说投稿前首先就应该看清楚他们的格式要求:2. 论文写作一定要言简意赅,特别是摘要,引言和结论部分,特别

【转载】张逸--ThoughtWorks(中国)程序员读书雷达

原文地址:ThoughtWorks(中国)程序员读书雷达 软件业的特点是变化.若要提高软件开发的技能,就必须跟上技术发展的步伐.埋首醉心于项目开发与实战,固然能够锤炼自己的开发技巧,却难免受限于经验与学识.世界上并不存在速成的终南捷径,但阅读好的技术书籍,尤其是阅读大师们的经典著作,总能收到事半功倍之效.一位优秀的程序员,或许就是一名好的阅读者.好的阅读者,总是知道如何选择好的书籍.书海浩繁,良莠不齐.阅读技术好书,如与智者交谈,“与君一席话胜读十年书”:遭遇技术烂书,如被拐卖,“少小离家老大回

Android插件的Gradle基础

1.Gradle简介 查看Gradle最新版本2.13 查看Gradle User Guide Gradle是一个基于Java(JVM)平台的构建体系(build system),它的一些特性: Gradle核心是基于Groovy的领域特定语言(Domain Specific Languages,DSL),具有良好的扩展性,所以不管是简单的独立项目还是大型的多项目构建它都能高效的提高构建任务,尤其对多项目支持是非常好:Gradle还提供了局部构建功能,譬如构建一个单独子项目时它会构建这个子项目依

编程书籍推荐——按角色划分

一.软件工程师 Clean Code<代码整洁之道> Implementation Patterns<实现模式> Code Complete<代码大全> Refactoring: Improving the Design of Existing Code<重构——改善既有代码的设计> Effective Java(第二版) Head First Design Patterns<深入浅出设计模式> Agile Software Developmen

程序员读书雷达

ThoughtWorks(中国)程序员读书雷达 软件业的特点是变化.若要提高软件开发的技能,就必须跟上技术发展的步伐.埋首醉心于项目开发与实战,固然能够锤炼自己的开发技巧,却难免受限于经验与学识.世界上并不存在速成的终南捷径,但阅读好的技术书籍,尤其是阅读大师们的经典著作,总能收到事半功倍之效.一位优秀的程序员,或许就是一名好的阅读者.好的阅读者,总是知道如何选择好的书籍.书海浩繁,良莠不齐.阅读技术好书,如与智者交谈,“与君一席话胜读十年书”:遭遇技术烂书,如被拐卖,“少小离家老大回,乡音无改

Groovy安装配置

一.介绍 Groovy是可以运行在 Java 平台上进行动态语言,使用方式基本与使用 Java 的方式相同,Groovy和java基本是可以实现无缝整合,它有以下一些特性: 是一个基于Java虚拟机的敏捷动态语言. 构建在强大的Java语言之上并添加了从Python,Ruby和Smalltalk等语言中学到的诸多特征. 为Java开发者提供了现代最流行的编程语言特性,而且学习成本很低(几乎为零). 支持DSL(Domain Specific Languages领域定义语言)和其它简洁的语法,让你