a dynamically typed, garbage collected, embeddable programming language built with Go

The agora programming language

Agora is a dynamically typed, garbage collected, embeddable programming language. It is built with the Go programming language, and is meant to provide a syntactically similar, loose and dynamic companion to the statically typed, machine compiled Go language - somewhat like Lua is to C.

Installation

go get -t github.com/PuerkitoBio/agora/...

This will install the agora packages as well as the agora command-line tool. See agora -h for help, provided the $GOPATH/bin path is in your exported path. The -t flag installs the test dependencies, it works only on Go 1.2 and later, omit it otherwise.

Example

Much more examples are available in the wiki and the source code under /testdata/src, but to give a taste of the syntax, here is the mandatory hello world:

// Output: Hello, Agora !
fmt := import("fmt")
func greet(name) {
	fmt.Println("Hello,", name, "!")
}
greet("Agora")

A few things to note:

  • It looks very similar to Go, minus the types.
  • import is a built-in function, not a keyword. This is important with dynamically-loaded modules, it gives you control of where this overhead of loading and compiling the code is done. It returns the value exported by the module - in this case, an object that exposes methods like Println.
  • Obviously, since this is a dynamically-typed language, arguments have no types.
  • := introduces a new variable. Using an undefined variable is an error, so this statement could not have been =.
  • Statements are valid in the top-level (module) scope. That's because a module (the name for an agora file) is an implicit (top-level) function.
  • Semicolons are managed just like in Go, so although they are inserted in the scanning stage, they are optional (and usually omitted) in the source code.

Resources

Changelog

v0.2.0 / 2013-10-08

v0.1.0 / 2013-09-17

License

Agora is licensed under the BSD 3-Clause License, the same as the Go programming language. The full text of the license is available in the LICENSE file at the root of the repository.

Comments
  • Make

    Make "" and 0 truthy

    In Lua and Ruby, the only falsy values are nil and false. This makes it very convenient to check if a value is defined without worrying about what types the value may be. (It's usually easy to know if a value may be boolean.) If strings and numbers are allowed to be false, then I have to worry about how I will treat those special falsy values in every if statement. That's a lot of extra mental load, and it would be worse than if the interpreter to threw an error for non-boolean if expressions. Historically, when other languages allow "" and 0 to be false, it's because the language did not start out with a native boolean type, and they want backward compatibility. I hope you'll reconsider this.

  • Print nested objects is incoherent

    Print nested objects is incoherent

    The top-level object gets printed ok, since it is converted to its native (map) value, but the inner objects panic because runtime.object does not support conversion to String() and inner fields are not converted to native values.

  • Comparsion of runtime.Object and front matter

    Comparsion of runtime.Object and front matter

    Tests do not always pass. Because "abc" and "abc" should be equal, but "abc, {a:1,b:2,c:3}" and "abc, {b:2,c:3,a:1}" should be equal too. runtime.Object is map[Val]Val, but map doesn't support ordering. Playground implementation of pull request.

  • Remove dumper interface from Val

    Remove dumper interface from Val

    Instead, make it a separate, public interface, and check if Val implements this interface at runtime to determine how to pretty-print the value (and fall back on %v or something to print by default - which would end up using the .String() implementation?).

  • typo on emitter.go:225

    typo on emitter.go:225

    https://github.com/PuerkitoBio/agora/blob/31eb3645f349bc0fd577a00d87dfffef90d62195/compiler/emitter/emitter.go#L225

        case "=":
            e.assert(sym.Ar == parser.ArBinary, errors.New("expected `+` to have binary arity"))
    

    the symbol should be =, not +.

  • Implement closures

    Implement closures

    Even required for simple cases like calling a func declared in the module, because the module itself is a function, so it needs to close over those funcs - see 46-json.agora.

  • Badly scoped vars at runtime

    Badly scoped vars at runtime

    A variable with the same name as one in a parent scope doesn't get defined in its local scope, only when it doesn't exist anywhere else.

    Easy fix: at compile-time, save a list of locals in the func prototype. At func instantiation, force-declare all locals before running. Removes the need for expected vars count.

  • Mix of Int and Float breaks simple cases

    Mix of Int and Float breaks simple cases

    Since Int() operations return Float()s, such simple cases like the source files 34 now fail, because the keys on the args object are Int()s, not Float()s.

  • v0.1 TODO list

    v0.1 TODO list

    • [x] Run simple code
    • [x] Call a Goblin function
    • [x] Call native Go function from Goblin
    • [x] Looping constructs
    • [x] Clean printing of VM's state for debugging
    • [x] Table/object type
    • [x] Call methods on object, support for no-such-method
    • [x] Access global variable (outside current func scope)
    • [x] Support for the this keyword, bound to object
    • [x] Refactor native functions/stdlib as objects?
    • [x] arguments[] array to access all received arguments
    • [x] Add K values to DUMP instructions, as comments
    • [x] Bytecode compiler command-line
    • [x] Dynamic loading of .goblin source files (and/or compiled bytecode)
    • [x] Test file that runs all .goblin test data and compares output to expected
    • [x] Syntax
    • [x] Lexer
    • [x] Parser
    • [x] Module/package support (import "user/library")
    • [x] Code generation
    • [x] Ternary operator (?:)
    • [x] Refactor Ctx.Load() by returning only the compiled Module, and have Module.Run() (Val, error) to execute it. Pass the ctx in the constructor of the module (and to each function's constructor).
    • [x] Call a specific Goblin function from Go (get any *Func, possibly based on name?)
    • [x] Make import a built-in function, not a keyword (so import can happen in an if, for example) Example: mod := import("dir/sub/mod")
    • [x] Exception/error handling (https://draftin.com/documents/117086)
    • [x] Make a debug built-in function or keyword, that takes a number as argument, to generate a DUMP (then debug the ternary operator bug for test file 19)
    • [x] len() builtin, returns the number of items in an object if it is an object, the length of the string representation of the value otherwise
    • [x] Make assignment to builtins/keywords fail
    • [x] Cyclic dependencies don't work anymore now that Ctx.Load doesn't Run the modules
    • [x] Support standard for loop (for i := 0; i < 10; i++)
    • [x] test use as script in #!
    • [x] Stdlib
    • [x] Emitter tests to validate statements generation (i.e. an if, if else, func within a func within a func, etc.)
    • [x] A complex-ier implementation of an agora program (a JSON parser/stringifier)
    • [x] Finalize stdlib tests
    • [x] Finalize stdlib docs
    • [x] Review all docs, comments for godoc.org

    Docs:

    • [x] Internals + Native API on godoc
    • [x] Readme with changelog, quick start, short example, links to docs, to contributing, and license
    • [x] Wiki for language docs by version (ie: all pages for v0.1, then copy for v0.2, ...): installation/Getting started (detailed), similarities & differences vs Go, language reference, VM opcodes, roadmap, stdlib, known bugs (with links to issues), how to write native modules
    • [x] Blog post to announce it
T# Programming Language. Something like Porth, Forth but written in Go. Stack-oriented programming language.

The T# Programming Language WARNING! THIS LANGUAGE IS A WORK IN PROGRESS! ANYTHING CAN CHANGE AT ANY MOMENT WITHOUT ANY NOTICE! Something like Forth a

Jun 29, 2022
Yayx programming language is begginer friendly programming language.
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

Dec 27, 2021
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

May 20, 2022
WindLang, A simple programming language built with golang 🍃
WindLang, A simple programming language built with golang 🍃

WindLang, A simple programming language built with golang ?? WindLang, A simple programming language built with golang ?? What is wind? Playground Coo

Dec 1, 2022
Sabre is highly customisable, embeddable LISP engine for Go. :computer:

Sabre DEPRECATED: This repository is deprecated in favour much better slurp project and will be archived/removed soon. Sabre is highly customizable, e

May 23, 2021
Go bindings to QuickJS: a fast, small, and embeddable ES2020 JavaScript interpreter.

quickjs Go bindings to QuickJS: a fast, small, and embeddable ES2020 JavaScript interpreter. These bindings are a WIP and do not match full parity wit

Dec 28, 2022
Gentee - script programming language for automation. It uses VM and compiler written in Go (Golang).

Gentee script programming language Gentee is a free open source script programming language. The Gentee programming language is designed to create scr

Dec 15, 2022
Port of the lemon parser generator to the Go programming language

From the golang-nuts mailing list (with few modifications): --== intro ==-- Hi. I just want to announce a simple port of the lemon parser generator

Feb 17, 2022
An LL(1) parser generator for the Go programming language.

What is it? I have implemented an LL(1) parser generator for the Go programming language. I did this to build parse trees for my HAML parser. You can

Jan 18, 2022
PHP bindings for the Go programming language (Golang)

PHP bindings for Go This package implements support for executing PHP scripts, exporting Go variables for use in PHP contexts, attaching Go method rec

Dec 27, 2022
The Slick programming language is an s-expression surface syntax for Go.

The Slick programming language The Slick programming language is a Lisp/Scheme-style s-expression surface syntax for the Go programming language, with

Jan 8, 2023
Pineapple Lang is a simple programming language demo implements by Go

Pineapple Lang is a simple programming language demo implements by Go. It includes a hand-written recursive descent parser and a simple interpreter, although the language is not even Turing-complete. But this repo's main goal is to give beginners of compilation principles a warm up and a simple look at how a programming language is built.

Dec 26, 2022
⛳ A minimal programming language inspired by Ink, JavaScript, and Python.

⛳ Golfcart My blog post: Creating the Golfcart Programming Language Getting Started Scope Rules Usage Building and tests Contributions License Golfcar

Sep 6, 2022
Simple, safe and compiled programming language.

The X Programming Language Simple, safe and compiled programming language. Table of Contents Overview OS Support Contributing License Overview The X p

Dec 28, 2022
A interpreter of SweetLang, is writed in Go Programming language.

SweetLang ( Soon ) A interpreter of SweetLang, is writed in Go Programming language. SweetLang is made with clarity and simplicity we try to make its

Oct 31, 2021
Monkey programming language project from 'Writing An Interpreter In Go'and 'Writing A Compiler In Go' Books
Monkey programming language project from 'Writing An Interpreter In Go'and 'Writing A Compiler In Go' Books

Monkey Monkey programming language ?? project from "Writing An Interpreter In Go

Dec 16, 2021
ReCT-Go-Compiler - A compiler for the ReCT programming language written in Golang

ReCT-Go-Compiler A compiler for the ReCT programming language written in Golang

Nov 30, 2022
ReCT-Go-Compiler - A compiler for the ReCT programming language written in Golang

ReCT-Go-Compiler A compiler for the ReCT programming language written in Golang

Nov 30, 2022
This package is built for Embedding PHP into Golang.

GoEmPHP This package is built for Embedding PHP into Golang. It is easy to use: script = php.New() script.Startup() defer script.Close()

Jul 2, 2022