June 21, 2019

The difference between a Domain specific language and a library


On the first look it seems, that both are similar. If somebody would like to realize a game he needs some kind of game library for painting lines to the screen. And if he likes he can call the library a Domain specific language (DSL) which contains the same functions. But there is large difference which can be explained in the programming game “Karel the robot”. Karel is a robot in a maze which has to be programmed, and Karel works with a domain specific language. The interesting point is, that the script which controls Karel runs inside the main program. Which means, that first the environment is started and then the karel1-scripts gets startet which moves the robot 4 steps upwards and 2 steps sidewards. The Karel script is executed by an abstract machine.
As a consequence a DSL is a something which runs in a box separate from the main program. The question is if Karel the robot can be realized as a library? The problem would be that the Karel program can't stopped independent from the game simulator, both are connected together. In most implementations, Karel runs as a thread independent from the main program. The working thesis is, that a DSL is equal to a subthread which runs in a program.

No comments:

Post a Comment