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

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

What is bento?

What Does bento Look Like?

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
$ bento hello.bento
Good afternoon, Jane!
Good afternoon, David!

What Will We Be Building?

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

Creating the Backend

<?php// This file is an example of a backend written in PHP.$handlers = [
'add ? to ?' => function($args) use (&$total, &$count) {
$total += $args[0];
++$count;
},
'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, "127.0.0.1", $_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));
}
socket_close($spawn);
socket_close($socket);
{
"run": "php scores.php"
}
bento scores.bento

How Is the Language Implemented?

What’s Planned For The Future?

I’d Love To Hear From You

The Startup

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

Elliot Chance

Written by

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com

The Startup

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

Elliot Chance

Written by

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com

The Startup

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

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store