Photo by Franck V. on Unsplash

start:

display "Hi, I'm bento."

What is bento?

https://github.com/elliotchance/bento

bento is a forth-generation programming language that is English-based. It is designed to separate orchestration from implementation as to provide a generic, self-documenting DSL that can be managed by non-technical individuals.

Wow, what a mouthful… That’s a bunch of fancy talk that means that the developers/engineers can setup the complex tasks and make them easily implementable by non-technical people through (almost) plain English.

The project is still very young, but it has a primary goal for each half of its intended audience:

For the developer/engineer: Programs can be written in any language (called a backend) and easily exposed through a set of specific DSLs called sentences.

For the user: An English-based language that avoids most nuances and complex grammar that non-technical people would find difficult to understand. The language only contains a handful of special words required for control flow. Whitespace and capitalization do not matter.

What Does bento Look Like?

It is possible to write programs that are entirely within the bento language (not using any backends, explained shortly). Here is an example in the file hello.bento :

Start:

Say hello to "Jane"

Say hello to "David"



Say hello to persons-name (persons-name is text):

If it is the afternoon,

display "Good afternoon, " persons-name "!",

otherwise display "Good morning, " persons-name "!"



It is the afternoon?

Declare am-or-pm is text

Run system command "printf `date +'%p'`" output into am-or-pm

If am-or-pm = "PM", yes

Let’s run it:

$ bento hello.bento

Good afternoon, Jane!

Good afternoon, David!

Some very basic language rules to be aware of:

Capitalization and whitespace in and around sentences do not have any effect. say hello is the same as Say HELLO . It is easier to read programs where the sentences are indented, but this is not a requirement.

is the same as . It is easier to read programs where the sentences are indented, but this is not a requirement. Functions are sentences followed by a : . Functions can take arguments, described in the parenthesis.

. Functions can take arguments, described in the parenthesis. Questions are sentences followed by a ? . Questions can also take arguments in the same way as functions. Unlike functions, however, questions have an answer designated by the yes or no sentence. If no answer is found, it is assumed to be no (that is why is can be excluded from the question above).

. Questions can also take arguments in the same way as functions. Unlike functions, however, questions have an answer designated by the or sentence. If no answer is found, it is assumed to be (that is why is can be excluded from the question above). The if statement can take a few forms. Here I am using the single line form that is: if <condition or question>, <true> [, otherwise <false>] .

statement can take a few forms. Here I am using the single line form that is: . Functions and questions can be defined and called in any order.

Even through bento programs can be written entirely in the bento language, this is not its intended purpose. Bento is designed to orchestrate one or more backends that do the actual work.

What Will We Be Building?

To demonstrate, here is the bento program we will be implementing:

start:

declare scores is example-scores-php

declare avg is number



add 53.5 to scores

add 17 to scores



average of scores into avg



display avg

display scores

Hopefully the program steps itself are pretty self-explanitory. By the time we finish, we will be able to run this and see the result: