❄️ Elsa is a minimal, fast and secure runtime for JavaScript and TypeScript written in Go

Elsa

Travis Status Build Status - Badge Discord invite

Elsa is a minimal, fast and secure runtime for JavaScript and TypeScript written in Go, leveraging the power from QuickJS.

Features

  • URL based imports.
  • No fs, net access unless specified.
  • Compliant to web standards.
  • Supports TypeScript.
  • Module caching.
  • Bundle your script into a single file.
  • Create a standalone executable for your bundles.

Install

Not yet released, build from source instead.

Build from source

You will need Go installed on your machine before building.

Install go-bindata using go get github.com/go-bindata/go-bindata/...

Clone the repo on your $GOPATH and run make build to trigger the build process.

Getting Started

Try running a simple program:

// hello.ts
import { hello } from "https://x.nest.land/[email protected]/mod.ts";

hello("Elsa");
> elsa run hello.ts
Hello, Elsa

Contributing

Start by creating an issue about your feature or bug! Then, create a PR and we'll land it 😄

Credits

FAQs

Where to use Elsa and where not to...

Elsa is small and embeddable into Go programs, using Quickjs as the backend comes with certain pros and cons -

PROS:

  • Suitable for CLI applications and shipping them as an executable
  • Native bindings to system level APIs (webview, etc)
  • Hosting discord bots on your raspberry pie 😉
  • Embeddable inside your Go programs.
  • General purpose scripting

CONS:

  • Slower runtime execution than Node and Deno
  • Slower backends
  • Double GC

Why choose QuickJS over V8?

QuickJS is a small and embeddable JavaScript engine but it lacks V8's JIT for fast JavaScript execution. Although, it doesn't mean you cannot use Elsa on backends and CPU intensive tasks.

QuickJS has a better startup time than V8 so it would be a strong alternative for CLI apps and short-lived runs.

Looks like a QuickJS wrapper to me?

Technically, Node and Deno are also V8 wrappers. All do the same job, init engine - init ops - bundle - run. Most people don't realise that implementing native ops is what makes a runtime and not an interpreter.

What's the status of the project?

It is in it's very early stages of development i.e. nothing should be considered stable. Feel free to take it for a spin though :)

What does "minimal" actually refer to?

The goal is to fullfil the bare minimum requirements needed for development of a project. Elsa, although aims to be extendable via plugins. A few examples of features that are not likely to be included in Elsa are tools for formatting, linting and analysis.

In short, develop - package - ship

License

Elsa.land is licensed under MIT License.

Owner
Elsa
Elsa is a minimal, fast and secure runtime for Javascript and Typescript written in Go.
Elsa
Comments
  • Implement filesystem ops

    Implement filesystem ops

    The goal right now is to implement all the file system APIs provided by Deno - https://github.com/denoland/deno/blob/master/cli/ops/fs.rs

    There is already a Elsa.readFile binding in core/dispatch.go with it's corresponding js call at js/01_namespace.js.

    Looking forward to recieve PRs :smile:

  • Fix some code quality issues and add code transformer

    Fix some code quality issues and add code transformer

    Fixes #85

    This pull request fixes some of the issues raised by DeepSource on my fork of this repo.

    Some issues were automatically fixed by DeepSource, while I fixed some of them by hand.

    This PR also contains a .deepsource.toml, in case you want to run continuous quality analyses on your repository. If you wish to do so, you can follow these steps:

    • Merge this PR.
    • Signup on DeepSource here.
    • Activate analysis on your repo here.

    Adding to reporting the code quality issues, I have also added the Go (gofmt) and JavaScript (Prettier) Transformers which support auto-formatting of code on every new pull-request. You can find the transformers docs here.

    If you don't want to use DeepSource, I can edit the PR to remove the .deepsource.toml file.

  • Project revival and long-term goals

    Project revival and long-term goals

    Hey everyone :wave:
    Been busy with several other projects recently which made it hard for me and @filipporeds to be able to work full-time on this.

    It's time to resume work on elsa:

    1. Revive PRs
    2. Embedding friendly
    3. Adapt internal workings from Deno (resource tables, json_ops, etc). (:heart: Deno)
    4. Fix bundle issues
    5. Runtime backends (Switch backends from quickjs, ducktape, v8, etc)

    Elsa as an embedded runtime is a major goal. Certain applications include k8 using elsa for built-in typescript support, etc.

    Contributions and feature requests are accepted in the issue tracker. Feel free to hop on the discord server.

  • Comparison with Deno

    Comparison with Deno

    Hello, the project looks really cool, looking forward to the http API!

    However, I'd like to suggest to add a comparison table with Deno, e.g. perf, features, size comparison.

    I've seen Deno vs Elsa benchmarks, but a comparison table (either in readme or separate file) with feature lists would be cool as well :D

  • elsa/quickjs should fork bellard/quickjs

    elsa/quickjs should fork bellard/quickjs

    elsa/quickjs forks lithdew/quickjs:

    https://github.com/elsaland/quickjs

    But it's not an official repository and its owner is not an author.

    Recently the author of quickjs created their account at GitHub and hosted quickjs repository:

    https://github.com/bellard/quickjs

    It's official and maintained. I strongly recommend elsa to fork the official repository.

  • there is already an open source project called Elsa

    there is already an open source project called Elsa

    Scott McPeak's C++ front-end is called elsa: http://dsw.users.sonic.net/oink/elsa_features.html

    This is not an obscure project: it was used by Mozilla to do source-to-source transforms on C++, the first time that had been done in history, as it preceded Clang/LLVM.

  • Ineffectual sync.WaitGroup in ops.Serve

    Ineffectual sync.WaitGroup in ops.Serve

    https://github.com/elsaland/elsa/blob/0819922b24f01849de855ff2852f2f28631fc1cb/core/ops/serve.go#L66 This call to wg.Wait is unreachable because the for loop preceding it never breaks. As a fix, a chan error should be used instead of a sync.WaitGroup so the error from http.ListenAndServe can be returned as well (see #75.)

  • feat(fmt/colors)

    feat(fmt/colors)

    a while ago I made a small color library per terminal for dart based on ANSI, I think it can be implemented within the color library, this is the repo of my implementation

  • Can I interact with a JS script while it is running?

    Can I interact with a JS script while it is running?

    For example, I have a javascript game loop, I use a Go grpc server to run it.

    When the player sends an operation request, the Go grpc server will change the status of javascript game loop.

    Can I do it with elsa?

  • Downloadable binary anywhere

    Downloadable binary anywhere

    Hi there,

    Is there downloadable binary anywhere of elsa, or do I need to compile it myself?

    I can see this step in the github actions to generate and upload a binary, but it wasn't obvious to me where I might try to download a binary for linux or OS X:

       - name: Upload Elsa executables
            uses: actions/upload-artifact@v2
            with:
              name: elsa-${{ matrix.os }}
              path: ./src/github.com/elsaland/elsa/elsa-${{ matrix.os }}
    

    I'm not a confident go programmer, so there might be something really obvious I'm missing, and I'm happy to update the README once I know the answer.

  • GO interop

    GO interop

    Is there a way to use this library akin to how something like Goja or Otto usage looks like? I'm working on a CLI where I want to have a JS runtime that will run perhaps many scripts (both files and from variables in go) in the same context. Right now I'm using Otto, and it works, but I'd like something that supports ES6 (especially modules). Here's an example of what I'm doing to setup a vm:

    vm := otto.New()
    
    err = vm.Set("someFunc", func(call otto.FunctionCall) otto.Value {
        message := call.Argument(0).String()
    
        // some go code here
    
        return otto.Value{}
    })
    
    _, err := vm.Run(` // some setup scripts `);
    

    Then later I have some user-defined scripts I want to execute against that vm (via the Run method), using some of those pre-defined setup/functions and interop as necessary. It doesn't look like this is something Elsa currently can handle, but is this a direction you're going in? If not I have some other options, just none as attractive as what you're doing here I think.

    Thanks in advance, and best of luck!

  • Add tests to `testing/`  and `std/` with Elsa.tests

    Add tests to `testing/` and `std/` with Elsa.tests

    Add tests for all the js/ts files inside testing/ and std/

    The test file should be named in the pattern *_test.js for elsa to identify it as a test file.

    Example:

    // some_test.js
    import { eq } from "./utils.ts";
    
    Elsa.tests({
      "test mode == `test`": function () {
        eq(Elsa.mode, "test");
      },
    });
    

    and run ./elsa test

    Marking as a good first issue as anyone with Deno.test experience can give it a try :smile:

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
ECMAScript/JavaScript engine in pure Go

goja ECMAScript 5.1(+) implementation in Go. Goja is an implementation of ECMAScript 5.1 in pure Go with emphasis on standard compliance and performan

Dec 29, 2022
v8 javascript engine binding for golang

Go-V8 V8 JavaScript engine bindings for Go. Features Thread safe Thorough and careful testing Boolean, Number, String, Object, Array, Regexp, Function

Nov 21, 2022
A JavaScript interpreter in Go (golang)

otto -- import "github.com/robertkrimen/otto" Package otto is a JavaScript parser and interpreter written natively in Go. http://godoc.org/github.com/

Jan 2, 2023
A Go API for the V8 javascript engine.

V8 Bindings for Go The v8 bindings allow a user to execute javascript from within a go executable. The bindings are tested to work with several recent

Dec 15, 2022
Execute JavaScript from Go
Execute JavaScript from Go

Execute JavaScript from Go Usage import "rogchap.com/v8go" Running a script ctx, _ := v8go.NewContext() // creates a new V8 context with a new Isolate

Jan 9, 2023
Lua runtime to control Philips Hue lamps 💡

go-hue Control Philips Hue Lamps with Lua About This is just a throw-away tooling to control Hue Lamps with a simple Lua script. hue -interval=2000 sc

Dec 10, 2021
Expression evaluation engine for Go: fast, non-Turing complete, dynamic typing, static typing
Expression evaluation engine for Go: fast, non-Turing complete, dynamic typing, static typing

Expr Expr package provides an engine that can compile and evaluate expressions. An expression is a one-liner that returns a value (mostly, but not lim

Dec 30, 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
A standalone nREPL/prepl client written in Go and heavily inspired by Grenchman

Trenchman A standalone nREPL/prepl client written in Go, heavily inspired by Grenchman Trenchman is a standalone nREPL/prepl client, which means that

Dec 11, 2022
A multi-pass compiler written in Go comprised of scanner, recursive-descent parser, generation of AST, intermediate representation (ILOC), and code generation (Armv8).

GoLite Project - Go Huskies! This is a project conducted and led in the course MPCS 51300 Compilers at the University of Chicago. In a group of two, w

Jan 10, 2022
Scriptable interpreter written in golang
Scriptable interpreter written in golang

Anko Anko is a scriptable interpreter written in Go. (Picture licensed under CC BY-SA 3.0, photo by Ocdp) Usage Example - Embedded package main impor

Dec 23, 2022
A POSIX-compliant AWK interpreter written in Go

GoAWK: an AWK interpreter written in Go AWK is a fascinating text-processing language, and somehow after reading the delightfully-terse The AWK Progra

Dec 31, 2022
A BASIC interpreter written in golang.
A BASIC interpreter written in golang.

05 PRINT "Index" 10 PRINT "GOBASIC!" 20 PRINT "Limitations" Arrays Line Numbers IF Statement DATA / READ Statements Builtin Functions Types 30 PRINT "

Dec 24, 2022
A basic Forth parser written in Go.

GoForth ======= I got really interested in Forth and thus I began making a parser, of sorts, in Go. Though I don't intend for it to catch on, it's st

Mar 1, 2022
A customisable virtual machine written in Go

== About GoLightly == GoLightly is a lightweight virtual machine library implemented in Go, designed for flexibility and reuse. Traditionally popular

Nov 16, 2022
A simple virtual machine - compiler & interpreter - written in golang

go.vm Installation Build without Go Modules (Go before 1.11) Build with Go Modules (Go 1.11 or higher) Usage Opcodes Notes The compiler The interprete

Dec 17, 2022
A dialect of Lisp extended to support concurrent programming, written in Go.

LispEx A dialect of Lisp extended to support concurrent programming. Overview LispEx is another Lisp Interpreter implemented with Go. The syntax, sema

Nov 22, 2022
Genetic Algorithms library written in Go / golang

Description Genetic Algorithms for Go/Golang Install $ go install git://github.com/thoj/go-galib.git Compiling examples: $ git clone git://github.com

Sep 27, 2022