-
Notifications
You must be signed in to change notification settings - Fork 0
design_notes
Tuna lang is a project created to provide a problem, that we can then go and solve with a dsl. Many dsl's in fact, as a learning exercise. It is a contrived problem, built as an educational tool.
The problem is this: I want a way to describe what my cats eat and plan their meals.
In the Martin Fowler book 'Domain Specific Languages', he describes the process of creating a DSL as starting with a Semantic Model. This model is defined as a subset of a Domain Model. You can build a DSL to populate the Semantic Model. The Semantic Model is used to drive computational process.
In many examples, the Semantic Model is used to drive a State Machine. Fowler describes a State Machine as 'a particular kind of model whose population effectively acts as the program for the system'.
A State Machine is classified as a Computational Model, a subtype of Adaptive Model. You can contrast an Adaptive Model to the probably more familiar Imperative Model used in most modern programming languages. In an Imperative Model, code is organized, typically, in an object oriented way. This is a very powerful paradigm, but there are some particular problems where a different computational model fits the problem better.
There are other Computational Models. Fowler describes a few, such as Decision Table, Production Rule System, and Dependency Network.
I think it is possible to employ more than one Computational Model, to solve particular problems, and drive them from the same Semantic Model.
For example, consider a basic Semantic Model:
PET name type (cat) age weight activity level (active, moderate, sedentary)
FOOD type (raw, canned, dry)
This Semantic Model has only 2 entities, pet and food. You could construct a Decision Table from this, which would be like a spreadsheet, with the following columns:
name, weight, activity, food, serving
based on the inputs in the weight, activity and food columns, the serving would be calculated