GithubHelp home page GithubHelp logo

bot_computer's Introduction

Overview

This project is inspired by some conversations I had with my friend David, who I met through the Zulip project. I am using only his first name to protect his privacy and to avoid conflating his inspiration for my ideas with my own interpretation/exploration of them.

Zulip is a chat system where humans and bots send messages to each other. David and I are imagining a Zulip ecosystem where humans can easily program bots and see their source code and dynamically create new bots with little fanfare. One prerequisite for that is to have some kind of sandboxed programming language that folks can write in.

This project implements a little programming language called "messie" that is aimed to be an LCD, Turing-complete language that can map to more expressive languages like Python/Ruby/JS/Lisp, but with a little more minimalism and adaptability to a messaging paradigm. The name "messie" refers to messaging, not messiness. The language looks superficially messy, but I am striving to make the underlying architecture simple and clean.

Minimal

The language is intended to be minimal in these regards:

  • You cannot mutate data structures, only create new ones.
  • There are no variables or assignments.
  • There are only a small number of built-in functions.
  • The only syntax is JSON (sort of).

Complete

The language is intended to be complete in these regards:

  • You will be able to manipulate all the JSON-serializable types, such as integers, floats, strings, lists, and dictionaries.
  • You can have functions that work on other functions, such as MAP and APPLY.
  • You can create recursive functions like FACTORIAL.
  • It's Turing complete, and you can do things like create an HTML table of factorial values with relative ease.

Unique

The language is unique in these respects:

  • Functions communicate by passing around JSON data structures as messages.

Extendible

The language is extendible:

  • Because "messie" fundamentally works with messages, the VM could be extended to work with multiple processes or multiple computers.
  • Because "messie" code is just JSON, functions written in "messie" can be up-ported to faster or more expressive languages like C/Python/Ruby/JS/Lisp.
  • Because "messie" code is just JSON, functions written in higher level languages can be down-ported to "messie" if you subset those languages to use only functions and immutable types.

Implementation

There is a script called [computer.py] (https://github.com/showell/bot_computer/blob/master/computer.py) that shows examples of "messie". You run it by simply invoking python computer.py.

The computer runs "messie" using a VM that is all in-process, but which uses a message queue to dispatch calculations. It can handle deeply recursive functions despite Python's recursion limit, because function dispatch is mediated through a queue.

The computer currently calculates a bunch of messages to standard output, and then it also calculates an HTML table of math results that it writes to foo.html.

Here is example HTML output from "messie":

ndoublesquarefactorial
51025120
61236720
714495040
8166440320
91881362880
10201003628800
112212139916800
1224144479001600
13261696227020800

You can see the "program" that created the above table here:

https://github.com/showell/bot_computer/blob/master/commands.py

bot_computer's People

Contributors

showell avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.