Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nirvanasupermind/owlet
Programming language for ternary computing
https://github.com/nirvanasupermind/owlet
Last synced: 9 days ago
JSON representation
Programming language for ternary computing
- Host: GitHub
- URL: https://github.com/nirvanasupermind/owlet
- Owner: nirvanasupermind
- License: mit
- Created: 2021-01-05T04:20:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-07T02:37:19.000Z (almost 4 years ago)
- Last Synced: 2024-12-03T05:35:28.175Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 816 KB
- Stars: 30
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# owlet
[![npm version](https://badge.fury.io/js/owlet.svg)](https://badge.fury.io/js/owlet)
Owlet is a high-level language for balanced ternary software development, using S-expression syntax. It was made using node.js. The infrastructure includes the interpreter able to run and decode Owlet programs. This is *not* a full [ternary computer](https://en.wikipedia.org/wiki/Ternary_computer), but is intended to be used as a library for other applications to use. And it has these dependencies:
* [BigInteger.js](https://github.com/peterolson/BigInteger.js/) to print numbers
* [syntax](https://github.com/DmitrySoshnikov/syntax) for the parserHere is an example program:
```clojure
(begin
(def fib(a) (begin
(if (<= a 1)
1
(+ (fib (- a 1)) (fib (- a 2)))
)
))
(print (fib 10))
)
```For more examples see the `examples` folder.
# What is Owlet?
A **ternary computer** (also called trinary computer) is a computer that uses ternary logic (three possible values) instead of the more popular binary system ("Base 2") in its calculations. The dialect of ternary (balanced ternary) used in owlet has digits for {-1,0,1}. Yes, this means EVERY number is signed. owlet is a high-level implementation of a ternary computer,minus the CPU and RAM. This allows it to be used effectively as a library for other applications and ternary computers that require heavyweight computations.# Implementation
The implementation of Owlet is written in JavaScript, and recursively evaluates the expression. It has multiple files to deal with each ternary data type such as ints and floats. The language implementation is quite small and simple compared to other weakly typed languages. Since the syntax is based on S-expression, the parser can be very small.# API
An overview of the syntax can be found in [API.md](API.md).# Using Owlet
You can evaluate Owlet code in a JavaScript string, using the function `Owlet.prototype.eval()`:
```js
const Owlet = require("owlet");
var owlet = new Owlet(); //Owlet interpreter
owlet.eval("")
```Owlet files can be run using node using the function `Owlet.prototype.evalFile()`, like so:
```js
const Owlet = require("owlet");
var owlet = new Owlet(); //Owlet interpreter
owlet.evalFile("my-file.owlet")
```Note that relative directories will be with respect to the folder you run node from.
These examples require that you have Owlet installed on npm, which can be done on Unix systems by typing `npm install owlet` into your terminal.
# Status
The main part of this language is complete, although it may be expanded on later.# License
Owlet is licensed under the MIT License.