Domain languages ​​and compilers

I looked at the last contents of Martin Fowler's book - Domain Languages ​​and I noticed some example of ANTLR - it made me think that compiling compilers would become more and more popular as people on this issue would increase.

So, will the theory of the compiler be as arid (being subjective here) as it was until now, or is there any chance that we will get more applied materials oriented to programmers?

+4
source share
5 answers

Despite the fact that DSLs can provide more opportunities for creating new compilers, I do not think that they will complicate the work with the compiler. You can use compiler tools like yacc to generate code to handle dsl syntax, or you can manually cut your own parser to improve internal efficiency than what yacc generators produce.

In any case, you must have sufficient knowledge of how to define and manipulate the language of the language in order to work with DSL and to avoid loopholes and problems that may arise from this.

Spiffy tools help implement the solution, but they do not solve the problem for you. To quote my chemistry teacher in high school: “Sure, bring your calculators to class! Calculators will help you get the wrong answer faster!”

+3
source

So, will the theory of the compiler be as arid (being subjective here) as it was until now, or is there any chance that we will get more applied materials oriented to programmers?

I would say that the compiler theory is actually quite rich, but may not focus on C-style languages. If you want to look at some powerful tools commonly used by academic language designers, I suggest you familiarize yourself with functional programming languages ​​(ML, Scheme, LISP, Haskell, OCaml, Scala, Clojure, etc.). Personally, I prefer Haskell with Parsec, but there are many options. I believe that the general consensus is that the structure of these languages ​​is more favorable for language design and implementation, at least in a theoretical sense.

As Christopher said, programmers do not necessarily create the best language designers. I saw some really cool DSLs and I saw some pretty terrible ones (my opinion, of course, is YMMV). Knowledge of linguistic concepts is mandatory for the design of any language, DSL or otherwise (type theory, category theory, various code analyzes, machine optimization, etc.). Not to mention that if you are developing a DSL, you should have a fairly thorough knowledge of the domain you are targeting.

Tools from the shelf, such as yacc, ANTLR, flex, and cup, can make assembling your compiler easier than buying wood from a logging factory to build your house easier than heading into the woods and cutting down trees. Both give you material for the structure, but you still need to know how to build a house. We will definitely see more DSL in the near future, and these tools will help. However, will DSL be used or even used? The tools here will not make any difference, at least in my opinion. There are many real computer sciences and / or mathematics in language design. Good language designers should at least be familiar with both, and good language developers should be familiar with language development tools.

+3
source

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

  • Choosing a good problem domain for DSL. It should be wide enough to attract more than the author, and narrow enough to have good solutions (C # is not taken into account).

  • DSL implementation. Many people seem to think that if they have a parser, they are done. In fact, you need a lot of technologies: parsing, analysis, code generation, ... (see DMS Software Reengineering Toolkit for an engine that contains what I think is necessary for the efficient creation of DSL)

  • Adoption of the DSL by the community. Its amazing number of people insists on coding only in a programming language that they know, and nothing more.

+2
source

In the 70s and 80s there was an explosion of programming languages. Then Java appeared and killed everything. Now we are at a different stage when people invent many languages. So, I would say that this is cyclical, and in fact, nothing new is happening.

However, one aspect that remains constant is that most programmers are not very fluent in languages. Tools such as yacc and ANTLR make some of them easier, but they do not make potential language designers better at developing the language.

+1
source

There are already some useful tools, take a look at Xtext, EMFText, Jetbrains MPS, Intentional Domain Workbench, and Microsoft's previous OSLO project with the M language. All of these tools make it easy to identify languages, although it has its own costs, but for DSL you may have some other requirements than for common general-purpose programming languages.

0
source

Source: https://habr.com/ru/post/1308410/


All Articles