Glish is a programming language used to write manuals that other programs can use to influence their behavior. In glish, you don't write a program; you write write a manual, which is a set of rules that another program can reference.
Imagine that you are making an ecommerce application and need to support some discounts for various situations:
- First-time buyers get a 10% discount.
- Any accessory is 50% off with the purchase of a protection plan.
- All accessories are on a 15% sale right now.
A glish manual to support these discounts might look like this:
Discount for an order from a first-time user:
take 10% from the grand total.
Discount for an order containing a protection plan and an accessory:
take 50% from the most expensive accessory in the order.
take 15% from each accessory in the order.
Glish probably does not look like any other programming language you've seen. The syntax is very prose-like, but under the hood this syntax precisely compiles to a specific implementation. In that example, each of the three sentences describes a rule. Breaking down the first sentence, we have:
In the first sentence, "Discount for an order from a first-time user" forms the preamble of the rule. The first part, "Discount for", says that the rule will live among the discount rules; and the second part, "an order from a first-time user", is a description of an order. This particular glish manual understands what orders and users are, as well as that orders are "from" a user, and that users can be "first-time" or not. The remainder of the first sentence forms the body of the rule, and this particular manual understands that it can "take" some amount "from the grand total".
The program that wants to reference the glish manual needs to provide definitions for concepts like "orders", or what it means to "take from the grand total", but once that has been done then any manual that uses these concepts can be referenced.
The main priorities for glish are:
- To provide rulebooks for other programs to use. Rulebooks can be used for things like validating inputs, or for applying effects in response to certain circumstances.
- To allow authors to describe complex rules easily. The condition under which a rule applies is built from simple pieces which can be composed together to express complex relationships.
- To allow non-technical users to read and understand the code. Glish source is very English-like, and glish provides tools to diagnose the exact behavior of programs.
Glish is ideal in situations where the complexity is in the relationship between things, rather than in the things themselves. In the ecommerce example above, the core concepts in the application are orders, users, and items. Glish enters the picture to bring those concepts together.
Glish draws very heavily from Inform7, a programming language for writing interactive fiction. I first learned about Inform7 from a blog post by Eric Lippert, and was struck by the expressivity of the descriptions in the rule definitions. Once I started to dig in, I realized that the concepts used in Inform7 are useful in a variety of other contexts, which is why I set out to create a more general-purpose version of it. Along the way, I added additional flexibility to the language and removed some constructs that were specific to interactive fiction, but the language is similar in spirit as well as in syntax.
The name "glish" comes from a joke my high school English teacher used to say when we made grammatical mistakes. "You're not even writing full English, just 'glish!" Since glish looks like English, but is a smaller, quirkier subset, I thought the name was appropriate.