Agora - 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
AWS SDK for the Go programming language.

AWS SDK for Go aws-sdk-go is the official AWS SDK for the Go programming language. Checkout our release notes for information about the latest bug fix

Dec 31, 2022
Firebase Cloud Messaging for application servers implemented using the Go programming language.

Firebase Cloud Notifications Client Firebase Cloud Messaging for application servers implemented using the Go programming language. It's designed for

Dec 17, 2022
Google Cloud Messaging for application servers implemented using the Go programming language.

gcm The Android SDK provides a nice convenience library (com.google.android.gcm.server) that greatly simplifies the interaction between Java-based app

Sep 27, 2022
Simple Shopify API for the Go Programming Language

go-shopify Simple API made with go to make CRUD request to your Shopify Store. Installation go get github.com/rapito/go-shopify How-to-use Get Reques

Dec 7, 2022
Nextengine-sdk-go: the NextEngine SDK for the Go programming language

NextEngine SDK for Go nextengine-sdk-go is the NextEngine SDK for the Go programming language. Getting Started Install go get github.com/takaaki-s/nex

Dec 7, 2021
A GitHub action for the Go! programming language (by Francis McCabe, 2004)

Setup Go! (GitHub Action) This project is a GitHub action for the Go! programmin

Oct 22, 2022
Stack-oriented programming language

aiur Stack-oriented programming language TODO Operators If statements Loops Procedures Include statements Package manager Syntax Conditional <conditio

May 20, 2022
twitter clone front-end for Internet Engineering course - fall 99 built by go+echo

twitter backend build twitter-like back-end for internet engeering course - fall 99 with go+echo+gorm team mates Roozbeh Sharifnasab + Parsa Fadaee +

Nov 9, 2022
A serverless sync server for Santa, built on AWS

Rudolph Rudolph is the control server counterpart of Santa, and is used to rapidly deploy configurations to Santa agents. Rudolph is built in Amazon W

Dec 5, 2022
Run proprietary modpack in built in Darwin/macOS sandbox-exec to prevent it from doing malicious things.
Run proprietary modpack in built in Darwin/macOS sandbox-exec to prevent it from doing malicious things.

sandbox-exec lunarclient Run LunarClient in built in Darwin/macOS sandbox-exec to prevent lunar from taking screenshots of your desktop. LunarClient l

Jul 12, 2022
go-macos-pkg was built out of a desire to generate and sign macOS pkgs on non-macOS OSs.

About go-macos-pkg was built out of a desire to generate and sign macOS pkgs on non-macOS OSs. Caveats Right now most of the heavy lifting is done by

Aug 18, 2022
planet is a blockchain built using Cosmos SDK and Tendermint and created with Starport.

planet planet is a blockchain built using Cosmos SDK and Tendermint and created with Starport. Get started starport chain serve serve command install

Oct 31, 2021
A decentralized vinyl marketplace demo built with Go, Cosmos SDK and Starport

emusicchain emusicchain is a blockchain built using Cosmos SDK and Tendermint and created with Starport. Get started starport chain serve serve comma

Dec 5, 2021
A simple command line -based snake game built with go and termbox
A simple command line -based snake game built with go and termbox

snake-task Snake Game A simple command line -based snake game built with go and termbox library. This is a test task for a Golang positon. It took me

Jan 16, 2022
A Lambda function built with SAM (Serverless Application Module)

AWS SAM Lambda Function © Israel Pereira Tavares da Silva The AWS Serverless Application Model (SAM) is an open-source framework for building serverle

Dec 19, 2021
A simple api built in Go that facilitates directly sending email from your client side html to your inbox

go-email-service A simple api built in Go that facilitates directly sending emai

Dec 28, 2021
An app/container built in Go to automate a Twitter account using Notion

Notion Tweeter Notion Tweeter is a utility I built using Go to help automate scheduling my tweets using Notion as a backend. More documentation coming

Sep 26, 2022
Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.
Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.

tutor-pet API Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure. Macro architecture: Code architecture: Pre-Re

Aug 17, 2022
Komikuapitk - Restful API Manga bahasa Indonesia built with Go

Komikku API Restful API Manga bahasa Indonesia built with ❤️ and Go Usage Clone

Sep 2, 2022