All Projects → 01alchemist → Turboscript

01alchemist / Turboscript

Licence: apache-2.0
Super charged typed JavaScript dialect for parallel programming which compiles to WebAssembly

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Turboscript

Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (-63.66%)
Mutual labels:  compiler, webassembly
Customasm
💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Stars: ✭ 211 (-56.67%)
Mutual labels:  compiler, webassembly
Prototype
(deprecated) The journey continues at ASNEXT: https://github.com/AssemblyScript/assemblyscript
Stars: ✭ 2,114 (+334.09%)
Mutual labels:  compiler, webassembly
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+2600.62%)
Mutual labels:  compiler, webassembly
Webml
A Standard ML Compiler for the Web
Stars: ✭ 326 (-33.06%)
Mutual labels:  compiler, webassembly
Wah
a slightly higher-level language superset of webassembly
Stars: ✭ 147 (-69.82%)
Mutual labels:  compiler, webassembly
Ppci
A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
Stars: ✭ 210 (-56.88%)
Mutual labels:  compiler, webassembly
Reading
A list of computer-science readings I recommend
Stars: ✭ 1,919 (+294.05%)
Mutual labels:  compiler, parallel-computing
Speedy.js
Accelerate JavaScript Applications by Compiling to WebAssembly
Stars: ✭ 300 (-38.4%)
Mutual labels:  compiler, webassembly
Cone
Cone Programming Language
Stars: ✭ 257 (-47.23%)
Mutual labels:  compiler, webassembly
Naskah
Bahasa pemrograman dengan sintaks Bahasa Indonesia (Programming language with Indonesian syntax) 🇮🇩
Stars: ✭ 132 (-72.9%)
Mutual labels:  compiler, webassembly
Jwebassembly
Java bytecode to WebAssembly compiler
Stars: ✭ 426 (-12.53%)
Mutual labels:  compiler, webassembly
Grain
The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
Stars: ✭ 2,199 (+351.54%)
Mutual labels:  compiler, webassembly
Awesome Machine Learning In Compilers
Must read research papers and links to tools and datasets that are related to using machine learning for compilers and systems optimisation
Stars: ✭ 168 (-65.5%)
Mutual labels:  compiler, parallel-computing
Asterius
A Haskell to WebAssembly compiler
Stars: ✭ 1,799 (+269.4%)
Mutual labels:  compiler, webassembly
Binaryen.js
A buildbot for binaryen.js, a port of Binaryen to the Web, with TypeScript support.
Stars: ✭ 201 (-58.73%)
Mutual labels:  compiler, webassembly
Wasm Forth
A Forth implementation compiling to WebAssembly.
Stars: ✭ 92 (-81.11%)
Mutual labels:  compiler, webassembly
Evm2wasm
[ORPHANED] Transcompiles EVM code to eWASM
Stars: ✭ 96 (-80.29%)
Mutual labels:  compiler, webassembly
Graphit
GraphIt - A High-Performance Domain Specific Language for Graph Analytics
Stars: ✭ 254 (-47.84%)
Mutual labels:  compiler, parallel-computing
Bytecoder
Rich Domain Model for JVM Bytecode and Framework to interpret and transpile it.
Stars: ✭ 401 (-17.66%)
Mutual labels:  compiler, webassembly

TurboScript

Build Status AppVeyor Stories in Ready Greenkeeper badge

Super charged typed JavaScript dialect for parallel programming which compiles to WebAssembly

⚠️ Major re-architecting is undergoing.

New spec (WIP) : TurboScript Spec

Things going to change

  • Binaryen as WebAssembly Backend

  • Interop with TypeScript/JavaScript (Import well typed TypeScript to TurboScript, will not compile to WASM)

  • Import any compiled WASM module to TurboScript

  • Integration with WebPack

Throughput Graph

    @             _________
     \____       /         \
     /    \     /   ____    \
     \_    \   /   /    \    \
       \    \ (    \__/  )    )          ________  _____  ___  ____
        \    \_\ \______/    /          /_  __/ / / / _ \/ _ )/ __ \
         \      \           /___         / / / /_/ / , _/ _  / /_/ /
          \______\_________/____"-_____ /_/  \____/_/|_/____/\____/

TurboScript is an experimental programming language for parallel programming for web which compiles to JavaScript (asm.js) and WebAssembly (targeting post-MVP). The syntax is similar to TypeScript (Hardly trying to fill the gaps) and the compiler is open source and written in TypeScript. TurboScript has zero dependencies.

This is still an experiment and isn't intended for real use yet but we are working towards an MVP release. Please feel free to open issues if it stop working or need a new feature.

Try online

Install

npm install -g turboscript

Types

Type Native type Description
int8 i32 An 8-bit signed integer.
uint8 i32 An 8-bit unsigned integer.
int16 i32 A 16-bit signed integer.
uint16 i32 A 16-bit unsigned integer.
int32 i32 A 32-bit signed integer.
uint32 i32 A 32-bit unsigned integer.
int64 i64 A 64-bit signed integer.
uint64 i64 A 64-bit unsigned integer.
boolean i32 A 1-bit unsigned integer.
float32 f32 A 32-bit floating point number.
float64 f64 A 64-bit floating point number.
void none No return type.
string * A utf-8 encoded textual data type.
Array<T> * A generic array data type.

Syntax

variables

var myGlobal:int32 = 1;
let evaluatedVar:int32 = myGlobal + 1;
// let is same as var.

Number Literals

let integer:int32 = 1234;
let integer64bit:int64 = 1234;
let floatingPoint:float32 = 1.234f;
let floatingPoint64bit:float64 = 1.234; // default floating point number is 64 bit

// You can also omit type since compiler infer type from the literal
let integer = 1234; // default integer is 32 bit, use type :int64 for 64 bit integer 
let floatingPoint = 1.234f;
let floatingPoint64bit = 1.234;

function

// add.tbs
export function add(a:int32, b:int32):int32 {
    return a + b;
}

class

// vector3D.tbs
export class Vector3D {
    x:float32;
    y:float32;
    z:float32;

    constructor(x:float32, y:float32, z:float32){
        this.x = x;
        this.y = y;
        this.z = z;
    }
}

Generic

class Foo<T> {
    value:T;
    constructor(value:T){
        this.value = value;
    }
    getValue():T {
        return this.value;
    }
}

export function testI32(value:int32):int32 {
    let instance = new Foo<int32>(value);
    return instance.getValue();
}

export function testI64(value:int32):int32 {
    let value2 = value as int64;
    let instance = new Foo<int64>(value2);
    return instance.getValue() as int32;
}

export function testF32(value:float32):float32 {
    let instance = new Foo<float32>(value);
    return instance.getValue();
}

export function testF64(value:float64):float64 {
    let instance = new Foo<float64>(value);
    return instance.getValue();
}

Operator overload

class Vector3D {
    x:float32;
    y:float32;
    z:float32;

    constructor(x:float32, y:float32, z:float32){
        this.x = x;
        this.y = y;
        this.z = z;
    }

    operator + (other:Vector3D):Vector3D {
        return new Vector3D(this.x + other.x, this.y + other.y, this.z + other.z);
    }

    operator - (other:Vector3D):Vector3D {
        return new Vector3D(this.x - other.x, this.y - other.y, this.z - other.z);
    }
}
export function test():boolean {
    let a = new Vector3D(1.0f,1.0f,1.0f);
    let b = new Vector3D(1.0f,1.0f,1.0f);
    let c = a + b;
    return c.x == 2.0f && c.y == 2.0f && c.z == 2.0f;
}

Array

// f64-array.tbs
var a: Array<float64> = null;

export function test(num:int32): Array<float64> {
    a = new Array<float64>(num);
    let i:int32 = 0;
    while (i < num) {
        a[i] = 0.0;
        i = i + 1;
    }
    return a;
}

export function getArrayByteLength(value:Array<float64>):int32 {
    return value.bytesLength;
}
export function getArrayElementSize(value:Array<float64>):int32 {
    return value.elementSize;
}

export function getArray(): Array<float64> {
    return a;
}
export function getData(index:int32):float64 {
    return a[index];
}
export function setData(index:int32, value:float64):void {
    a[index] = value;
}

Compile to wasm

tc add.tbs --wasm --out add.wasm

Join Slack

You need an invitation to join Slack. Open a ticket with your email address. I will make it happen.

Roadmap

  • Parallel JavaScript
  • WebAssembly Emitter
  • Basic malloc and free
  • ASM.JS Emitter
  • Import external functions with namespace
  • Array Data Type
  • Parallel WebAssembly (post-MVP)

Wiki

Documentations can be found at wiki (under construction 🚧)

Useful links

Credit

Lexical analysis, Parsing, Checking codes are borrowed from Evan Wallace's thinscript

Now enjoy - Wow! this snail is fast

Wow! this snail is fast

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].