Git Product home page Git Product logo

ton-lang's Introduction

ton-lang

ton-lang is a visual programming language whose interpreter is implemented as a cellular automaton, meaning that each cell is transformed at every frame depending on its direct neighbors.

Evaluating programs as cellular automata gives some interesting features such as partial evaluation. On the other hand some features can be hard to implement โ€” at least the way I've approached the problem โ€” e.g. I'm still trying to figure out how to implement recursion.

Installing

Run the following command to install the editor/interpreter

$ python3.8 setup.py install --user

Make sure that the site-packages directory is in your path.

Dependencies:

  • pygame v2
  • fire
  • numpy

Usage

CLI

  • Creating a new file: ton new <path>
  • Editing an existing file: ton edit <path>
  • (Upcoming) Render the evaluation of a program as a gif: ton run <program-path> <gif-output-path>

Editor

Cells

Cells are divided in three main categories:

  • Links: wires connecting cells, visually "pulling" values to processors
  • Processors: cells that actually do computations, inputs are shown as blue pins and outputs as red pins, drawn on the border of the cell.
  • Values: for now only booleans, integers and lists

Additionally, programs can be separated in modules with "chips", which are basically sub-programs.

Eventually I'd like to implement quotes (as in e.g. lisp) which would make processors behave as values temporarily (and therefore movable through wires)

Controls

  • Left-click: write the selected cell
  • Right-click: delete the pointed cell
  • Scrolling: change the cell type in the toolbar
  • Ctrl+S: save the current program
  • Ctrl+R: reload the program from disk (going back to the last saved state)
  • Ctrl+Q: quit the editor
  • Ctrl+L: Clears the board
  • s+scroll: switch the state of the cell, which depends on the pointed cell (cycles through values for value-cells, rotates the pins for processor-cells)
  • Space: evaluates 1 step
  • Enter: evaluate continuously (toggle)
  • Tab: edit the selected chip
  • Esc: go to parent program
  • Shift+Esc: go to root program
  • M: save selected chip to toolbar
  • D: print JSON-representation of a cell in the console for debugging
  • I: shows information about a cell directly in the editor

Examples

  • Using chips to define a subroutine that increments an integer:

  • Manipulating lists

ton-lang's People

Contributors

dependabot[bot] avatar felko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hermetique

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.