- 出版社: Manning Publications; Pap/Psc (2011年1月27日)
- 平装: 375页
- 语种： 英语
- ISBN: 1935182455
- 条形码: 9781935182450
- 商品尺寸: 18.7 x 1.9 x 23.5 cm
- 商品重量: 630 g
- ASIN: 1935182455
- 用户评分: 分享我的评价
- 亚马逊热销商品排名: 图书商品里排第2,278,946名 (查看图书商品销售排行榜)
DSLs in Action (英语) 平装 – 2011年1月27日
Debasish Ghosh, Chief Technology Evangelist at Anshinsoft, is passionate about programming languages and cooperative polyglotism. He has developed systems using multiple JVM languages and has designed DSLs using Java, Ruby, and Scala. Debasish is a senior member of the ACM and an active blogger on programming techniques and languages.
Once you implement a domain model in your favorite programming language, it no longer speaks the dialect that the domain expert can understand. If your implementation doesn't conform exactly to the specifications you agreed on with the domain user there's no way it can be verified by the person who understands the domain rules.
DSLs in Action addresses this by suggesting a DSL-driven application development model. Design your domain APIs around the syntax and semantics that the domain user understands. Then, even during the development of the code base, the user can do incremental verifications of the domain rule implementations. If your code speaks the language of the domain, it becomes clearer to the person who develops it, to the one who maintains it, and to a nonprogrammer domain expert who understands the business.
You will learn how to design and implement DSLs using the modern languages Ruby, Groovy, Scala, Clojure and Java. In addition, discussions of the strengths and weaknesses of these languages when designing a DSL are included.
Admittedly, not everyone will be familiar with all the programming languages used to implement the DSL structures in this book so the author has included short reference cards (or cheat sheets) for the languages in the appendixes. More thorough references are provided to complete texts to supplement them. The source code for all examples in this book is available from Manning's website, [...].
The author, Debasish Ghosh (@debasishg on Twitter), is the chief technology evangelist at Anshinsoft ([...]). He's a senior member of the ACM and his blog is at Ruminations of a Programmer ([...]).
Summary of Contents
Part 1: Using DSLs
Chapter 1: Learning to Speak the Language of the Domain
What a DSL actually is and the benefits it can provide start this chapter. The structure of a DSL is covered. The chapter concludes by tying in appendix A and discussing what makes a well-designed abstraction.
Chapter 2: The DSL in the Wild
Here you create your first DSL using Java. Groovy is introduced to demonstrate how to make the DSL more Expressive. DSL implementation patterns are introduced and how to choose a DSL type is presented.
Chapter 3: DSL-driven Application Development
Integrating internal and external DSLs in an application is the main topic of this chapter. Once this topic is completed, error and exception management is discussed and performance optimization is covered.
Part 2: Implementing DSLs
Chapter 4: Internal DSL Implementation Patterns
The author demonstrates how to build a programmer's toolbox of architectural patterns that can be used to implement DSLs. The use of metaprogramming to aid in the construction is extensively covered.
Chapter 5: Internal DSL Design in Ruby, Groovy and Clojure
The running application typical of Manning books, in this case a stock trading processor, is introduced here. The initial implementation is in Ruby and then it is improved with Groovy. Clojure is introduced to demonstrate how one must think a little differently with this language. A discussion of the pitfalls of each of these languages concluded the chapter,
Chapter 6: Internal DSL Design in Scala
This chapter is dedicated to Scala to which the author gives a good introduction. Developing an internal DSL with Scala is then covered. A discussion of monadic structures rounds out the chapter.
Chapter 7: External DSL Implementation Artifacts
This chapter is dedicated to the tools used to generate an external DSL. Parsers are discussed along with ANTLR, the Eclipse Modeling Framework and Xtext.
Chapter 8: Designing External DSLs using Scala Parser Combinators
Beginning with a discussion of exactly what parser combinators are this chapter continues with the Scala parser combinator library. A discussion of packrat parsers follows and then a dive into Scala DSL design with the combinators finishes up.
Part 3: Future trends in DSL development
Chapter 9: DSL Design: Looking Forward
The main thrust of this chapter is to touch base on developing trends in the DSL world. DSL workbenches are canvassed. The important topic of DSL versioning and practices that you can adopt to ensure a smooth evolution of your DSL's syntax rounds out the book.
Not for beginners. At first this book comes at you so fast that it can seem overwhelming but hold on it does get better. Although this reviewer would not call this a 'Magnum Opus' it is as close as you get without being one. It becomes immediately clear that the author knows what he is doing and does this sort of thing everyday.
Ruby, Groovy, Clojure and Scala along with Java are used in the examples and this reviewer and the author are willing to bet that the reader is fluent in at least one of those languages. The good thing here, as the author says, is all of the code is understandable regardless of whether you have experience with one of them or not. It should also convince readers to do what they've said they were going to do for the last three years and learn a new programming language. One excellent side effect of so many languages in such a small space is that you will learn how each of them makes you think about and approach a problem differently.
The book contains excellent discussions of domain cognizance with topics such as accidental complexity and minimalism in coding followed with a great review/introduction of the differences, strengths and weaknesses of Internal DSLs versus External DSLs. There is even a chapter dedicated to designing external DSLs via Scala parser combinators.
It is an exhaustively wide and deep coverage of the subject. By the time you've finished reading the book, you'll have a thorough understanding of the concepts that you need to master in order to design domain abstractions that your users can understand and appreciate. This will bring much added business value to any project.
Five languages with no trivial examples all in one book, highly recommended.
On internal DSLs this is absolutely the most pragmatic and complete resource I had ever read.
On external DSLs the author introduce the important concepts and provide an example using Xtext (in my opinion the best technology to use right now).
I also appreciated the chapter on the future trends. I think it gives some ideas about what we should expect from DSLs and analyzing the trend towards more expressivity. The concept of DSL workbench is also introduced.
Finally seven appendixes add value to book: we have cheat sheet for [Ruby|Scala|Groovy|Clojure]'s DSL-friendly features, notes on polyglot programming, an appendix on metaprogramming.
In my opinion this book is definitely worthy the money, there is a lot of value on it so take a look to it.
They have their strengths and weaknesses but most of them are things you might already know or with ANTLR, content you can look-up online. The books seem dry and not interesting. You have to force yourself to go through them. And even if you go through them you aren't interested in actually taking the time to go through the example.
DSLs in Action was a fun book to read. It a wide range detail from some of the theory to the case studies to useful examples. It was a solid book that really kept me interested in the material. I have been hoping that a book would cover, Scala and Lisp and Ruby. This book touches on some of the subjects.
Author started from common description of DSLs, show different approaches to they building (for both internal, and external DSLs), and provided a lot of examples in different languages (Groovy, Ruby, Clojure, and Scala (his favorite).
So, after reading this book, you'll able to design and create your own DSLs.
P.S. there is also great philosophical appendix on designing "good" programs - it really worth to read it to many peoples.
Examples of DSLs include such things as: The CScript langauge used in the torque game engine, the mod scripting interfaces exposed in games such as WoW, Eve Online and Neverwinter Nights. The R language for statistical computation. The Prolog language could "almost" be called a DSL, because even though it was intended as a high-level GPL, it turns out that it is truly suited for developing expert systems (more efficiently than any other GPL) and less suited to most other general programming tasks. LOGO is another great DSL - and language meant to teach children programming concepts, but useful for problem solving almost exclusively in the domain of drawing pictures on a screen.
This book does seem to be an interesting book for those interested in understanding common concepts and differences in general purpose languages that are targeted to a VM, such as JVM/.Net - that adopt different programming styles, such as traditional static typed OO, dynamic OO, and functional paradigms.
I wish I could get past the complete misuse of the core concept enough to value it on that level.