Git Product home page Git Product logo

ghost's Introduction

ghost

The programming language that's barely there

Jokes aside, ghost is the working name of a small programming language I'm developing primarily for fun.

Example


Compute and print the 20th Fibonacci number: ``` [dup [drop 1] [dup 2 - fib swap 1 - fib +] rot3 3 < if] fib def 20 fib print ```

Basics


Ghost is a concatenative, stack based language partly inspired by [Forth](http://en.wikipedia.org/wiki/Forth_(programming_language)). This means that all program elements are functions that take a stack as an argument, and return a stack as a result. The returned stack is not necessarily the same stack that was consumed, although there is no semantic difference between the two models. There is a mathematical difference though: treating the consumed stack and returned stack as different means that most functions will be pure, even if they modify the stack. This has clever and interesting consequences. For more about stack languages: http://evincarofautumn.blogspot.com/2012/02/why-concatenative-programming-matters.html

A program is simply the composition of its constituent functions, as are functions themselves, if they are composite functions. Thus, to facilitate easy composition, ghost's syntax is in postfix notation:

1 2 + print

This short program consists of four functions: 1, 2, +, and print. Since they are in postfix notation, they are evaluated left to right: 1 pushes an number onto the stack, as does 2, + pops two numbers, adds them, and pushes the result back, and print peeks the top of the stack and prints it to standard out. This program will output 3.

< further documentation to come >

ghost's People

Contributors

burntpizza avatar

Stargazers

 avatar Connor Elsea avatar Maxwell avatar

Watchers

James Cloos 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.