tags:

views:

116

answers:

5

I was looking over Martin Fowler's recent book contents - Domain Specific Languages and I noticed some ANTLR example - that got me thinking that writing compilers will become more and more popular since people needs in this matter will increase.

So, will the compiler theory still be as arid (being subjective here) as it was until now or are there any chances that we'll get more applied, programmer oriented materials ?

+3  A: 

Even though DSLs may seem to create more opportunities for creating new compilers, I don't think they will make the challenges of writing a compiler any easier. You can either use compiler tools like yacc to generate code to handle your dsl syntax, or you can hand carve your own parser with an eye towards better internal efficiency than what the yacc generators spit out.

Either way, you have to have sufficient knowledge of how to define and manipulate a language grammar to make your DSL work and to avoid loopholes and can't-get-there-from-here problems.

Spiffy tools help to implement the solution, but they don't solve the problem for you. To quote my high school chemistry teacher: "Sure! Bring your calculators to class! Calculators only help you get the wrong answer faster!"

dthorpe
Right, so one would still need to go through all that hairy theory before actually getting a chance to code.
hyperboreean
Right. If you don't go through it formally with a guide, you'll stumble through it on your own as you run into problems.
dthorpe
Yacc is a so-called "compiler tool"... but it is not. Yacc (and its family of friends) are *parser* generator tools. They help you parse the code. But generating code from a DSL ("compiling") requires a lot more than parsing: the code generator has to understand how the elements of the DSL interact, how to generate code for the general case, how to generate code for common special cases... consequently only a small part of a compiler is concerned with just parsing. So you need "hairy theory" just for parsing, and you've hardly started.
Ira Baxter
+1  A: 

There was an explosion of programming languages in the 70's and 80's. Then Java came along and killed everything off. Now we are in another phase of people inventing lots of languages. So, I'd say it is cyclical, and there is really nothing "new" going on.

However, one aspect that remains constant is that most programmers aren't very good at designing languages. Tools like yacc and ANTLR make some of the implementation easier, but they don't make would-be language designers any better at language design.

Kristopher Johnson
They do make it possible for the good designers to actually do something.
Ira Baxter
A: 

There already are some useful tools, look for Xtext, EMFText, Jetbrains MPS, Intentional Domain Workbench and Microsofts former OSLO project with the M language. All these tools make defining languages easier, although it has its cost, however for a DSL you might have a bit other requirements than for regular general purpose programming languages.

Gabriel Ščerbák
+1  A: 

As high-quality DSLs get easier to build, we are more likely to see more of them. There are several obstacles:

  • Choosing a good problem domain for a DSL. It has to broad enough to have appeal to more than the author, and narrow enough to have good solutions (C# doesn't count).

  • Implementing a DSL well. Lots of people seem to think if they have a parser they are done. Actually, you need a lot of technology: parsing, analysis, code generation, ... (See DMS Software Reengineering Toolkit for an engine that contains what I think is needed to produce DSLs effectively)

  • Acceptance of the DSL by the community. Its amazing how many people insist on coding in just the programming language they know, and nothing else.

Ira Baxter
The domain is the most important part of DSL, I would say that you have to choose from the top-down design problem space domain and you should implement it using bottom-up design solution space framework. This means, that you have to choose a domain and undestand it, maybe implement in metamodel. You have also to search for reusable parts in solutions, which will be used for code generation. If you have those bot, transformation between them is easy and IMHO that is the main benefit of DSLs.
Gabriel Ščerbák
Tools I mentionned do all what you mentioned, in external DSLs we are far from the "just parser" mindset. Just search for "DSL workbench".
Gabriel Ščerbák
IMHO DSL should be so easy and productive, that they will not need advertisiment and I do not think DSL should become "de facto" standards (different DSLs for different domains). I would say the interoperability is more important and when DSLs become really productive and interoperable, there will be almost no problem with the adoption.
Gabriel Ščerbák
+3  A: 

So, will the compiler theory still be as arid (being subjective here) as it was until now or are there any chances that we'll get more applied, programmer oriented materials ?

I'd say that compiler theory is actually pretty rich, but may not centered around C style languages. If you want to look at some powerful tools commonly used by academic language designers, I suggest that you check out functional programming languages (ML, Scheme, LISP, Haskell, OCaml, Scala, Clojure, etc.). Personally I prefer Haskell with Parsec, but there are many options. I think the common consensus is that the structure of these languages is more conducive to language design and implementation, at least in a theoretical sense.

Like Kristopher said above, programmers don't necessarily make the best language designers. I've seen some really cool DSL's and I've seen some pretty awful ones (my opinion, of course, YMMV). Knowledge of language concepts is a must for designing any language, DSL or otherwise (Type theory, category theory, various code analyses, machine optimization, etc). Not to mention, if you're designing a DSL, you have to have a fairly intimate knowledge of the domain you're targeting.

Tools off the shelf like yacc, ANTLR, flex, and cup can make building your compiler easier like buying wood from a lumberyard to build your house is easier than going off into the woods and cutting down trees. Both get you the material for the structure, but you still have to know how to build the house. We will definitely see more DSLs in the near future and these tools will help. Will the DSLs be worth using or even useable, however? The tools won't make a difference here, at least in my opinion. Language design employs a lot of real computer science and/or mathematics. Good language designers will have to at least be familiar with both, and good language implementers must be familiar with language design tools.

thegravian