🍱 bento — A New English-based Automation Language for Non-technical People

Elliot Chance
Aug 7, 2019 · 5 min read
Photo by Franck V. on Unsplash
display "Hi, I'm bento."

What is bento?


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:

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
$ bento hello.bento
Good afternoon, Jane!
Good afternoon, David!
  • Functions are sentences followed by a : . 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).
  • 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>] .
  • Functions and questions can be defined and called in any order.

What Will We Be Building?

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

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
The total is 70.5.

  1. A backend is a directory by the same name. Bento will search for the backend in all directories defined in the $BENTO_BACKEND environment variable, which works similar to $PATH. It may contain zero or more paths split by a :. If $BENTO_BACKEND is not defined or is empty then it will receive a default value of . — the current directory.
  2. Bento will start and communicate with the backend through a simple text based socket protocol. Which we will build in PHP next.

Creating the Backend

We start by creating a directory called example-scores-php . Put it in the same directory as where we will run the script to make things easy. In this directory there will be three two files:

  1. scores.php (The backend can be in any language because the backend will responsible for it’s own server. For this example I will use PHP because it’s pretty common):
<?php// This file is an example of a backend written in PHP.$handlers = [
'add ? to ?' => function($args) use (&$total, &$count) {
$total += $args[0];
'average of ? into ?' => function($args) use (&$total, &$count) {
return ["set" => ['$1' => (string)($total / $count)]];
'display ?' => function() use (&$total) {
return ["text" => "The total is $total."];
// The code following should not need to be changed.$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$result = socket_bind($socket, "", $_ENV['BENTO_PORT']);
$result = socket_listen($socket, 3);
$spawn = socket_accept($socket);
while ($message = json_decode(socket_read($spawn, 65536, PHP_NORMAL_READ))) {
if ($message->special === "sentences") {
$result = ['sentences' => array_keys($handlers)];
} else {
$handler = $handlers[$message->sentence];
$result = $handler($message->args);
if (!$result) {
$result = new stdClass();
$output = json_encode($result) . "\n";
socket_write($spawn, $output, strlen($output));
"run": "php scores.php"

bento scores.bento

How Is the Language Implemented?

Bento is an interpreted language, but it has a lexer, grammar, compiler and virtual machine. You can find the full language specification in the README.

What’s Planned For The Future?

I want to keep the language itself very simple and allow extension through people creating their own packages. That being said, there are some things that I believe must be implemented to create a productive environment for everyone:

  1. Richer built-in types including arrays, structures and time. These will make writing programs that interact with structured data (like a database or CSV file) much easier.
  2. GUI development. There are many great frameworks out their for building native and web GUI apps. I’m not sure what this will look like yet, but being able to create interactive forms, lists, graphs, etc. would make it easier to present simple interfaces that connect and communicate with complex backend systems without having to build and maintain that software through traditional means.

I’d Love To Hear From You

As I said, it’s still early days. While all the difficult technical parts have been completed there is still a lot of polish to be added that can only really be done with feedback from users.

The Startup

Medium's largest active publication, followed by +568K people. Follow to join our community.

Elliot Chance

Written by

I’m a data nerd and TDD enthusiast from Sydney. I love exploring new technologies and working on modern ways to solve age old problems 🤓 elliotchance@gmail.com

The Startup

Medium's largest active publication, followed by +568K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade