Book Image

Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition

By : Lorenzo Bettini
4 (1)
Book Image

Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition

4 (1)
By: Lorenzo Bettini

Overview of this book

Xtext is an open source Eclipse framework for implementing domain-specific languages together with IDE functionalities. It lets you implement languages really quickly; most of all, it covers all aspects of a complete language infrastructure, including the parser, code generator, interpreter, and more. This book will enable you to implement Domain Specific Languages (DSL) efficiently, together with their IDE tooling, with Xtext and Xtend. Opening with brief coverage of Xtext features involved in DSL implementation, including integration in an IDE, the book will then introduce you to Xtend as this language will be used in all the examples throughout the book. You will then explore the typical programming development workflow with Xtext when we modify the grammar of the DSL. Further, the Xtend programming language (a fully-featured Java-like language tightly integrated with Java) will be introduced. We then explain the main concepts of Xtext, such as validation, code generation, and customizations of runtime and UI aspects. You will have learned how to test a DSL implemented in Xtext with JUnit and will progress to advanced concepts such as type checking and scoping. You will then integrate the typical Continuous Integration systems built in to Xtext DSLs and familiarize yourself with Xbase. By the end of the book, you will manually maintain the EMF model for an Xtext DSL and will see how an Xtext DSL can also be used in IntelliJ.
Table of Contents (25 chapters)
Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition
Credits
Foreword
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Preface to the second edition
14
Conclusions
Bibliography
Index

Preface to the second edition

Since the very beginning, Xtext has always been a continuously evolving software. Each new version of Xtext comes with many new features and bugfixes.

When I wrote the first edition of the book, which was published in August 2013, Xtext 2.4.0 had been recently released. Since then, all the features introduced in each new release of Xtext aimed at making DSL implementation easier and at improving the user experience.

All these things came with a small price though—the contents of the book were getting stale in time, and they did not respect the features of Xtext in the new releases anymore.

In all these years, Xtext has always been my daily framework since my research is based on programming language design, theory, and most of all, implementation. I've been implementing lots of DSLs since the first edition of the book and doing that I've also learned many more aspects of Xtext and new best practices. I've also started to contribute more actively to the Xtext code base, and I can proudly announce that I recently became an Xtext committer.

Thus, at the end of 2015, I decided to propose to Packt a second edition of the book and they reacted very positively.

While working on this second edition, I updated all the contents of the previous edition in order to make them up to date with respect to what Xtext provides in the most recent release (at the time of writing, it is 2.10). All the examples have been rewritten from scratch. With respect to the examples of the first edition, many parts of the DSLs have been modified and improved, focusing on efficient implementation techniques and the best practices I learned in these years. Thus, while the features of most of the main example DSLs of the book is the same as in the first edition, their implementation is completely new. In the last chapters, many more examples are also introduced.

In particular, Chapter 11, Continuous Integration, which in the previous edition was called Building and Releasing, has been completely rewritten and it is now based on Maven/Tycho instead of Buckminster, since Xtext now provides a project wizard that also creates a Maven/Tycho build configuration for your Xtext DSL. This new chapter also briefly describes the new Xtext features that allow you to port your DSL editor on the web and also on IntelliJ. I also added a brand new chapter at the end of the book, Chapter 13, Advanced Topics, is loaded with much more advanced material and techniques that are useful when your DSL grows in size and features. For example, the chapter will show how to manually maintain the Ecore model for the AST of your DSL in several ways, including Xcore. This chapter also presents an example that extends Xbase, including the customization of its type system and compiler. An introduction to Xbase is still presented in Chapter 12, Xbase, as in the previous edition, but with more details.

As in the previous edition, the book fosters unit testing a lot. An entire chapter, Chapter 7, Testing, is devoted to testing all aspects of an Xtext DSL implementation. I also kept the same tutorial nature of most chapters as in the previous edition.

Summarizing, while the title and the subject of most chapters is still the same, their contents has been completely reviewed, extended, and hopefully, improved.

If you enjoyed the first edition of the book and found it useful, I hope you'll like this second edition even more.

Lorenzo Bettini