Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 28, 2018. It is now read-only.

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

License

NotificationsYou must be signed in to change notification settings

01alchemist/TurboScript

Repository files navigation

Build StatusAppVeyorStories in ReadyGreenkeeper 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.

Install

npm install -g turboscript

Types

TypeNative typeDescription
int8i32An 8-bit signed integer.
uint8i32An 8-bit unsigned integer.
int16i32A 16-bit signed integer.
uint16i32A 16-bit unsigned integer.
int32i32A 32-bit signed integer.
uint32i32A 32-bit unsigned integer.
int64i64A 64-bit signed integer.
uint64i64A 64-bit unsigned integer.
booleani32A 1-bit unsigned integer.
float32f32A 32-bit floating point number.
float64f64A 64-bit floating point number.
voidnoneNo return type.
string*A utf-8 encoded textual data type.
Array<T>*A generic array data type.

Syntax

variables

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

Number Literals

letinteger:int32=1234;letinteger64bit:int64=1234;letfloatingPoint:float32=1.234f;letfloatingPoint64bit:float64=1.234;// default floating point number is 64 bit// You can also omit type since compiler infer type from the literalletinteger=1234;// default integer is 32 bit, use type :int64 for 64 bit integerletfloatingPoint=1.234f;letfloatingPoint64bit=1.234;

function

// add.tbsexportfunctionadd(a:int32,b:int32):int32{returna+b;}

class

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

Generic

classFoo<T>{value:T;constructor(value:T){this.value=value;}getValue():T{returnthis.value;}}exportfunctiontestI32(value:int32):int32{letinstance=newFoo<int32>(value);returninstance.getValue();}exportfunctiontestI64(value:int32):int32{letvalue2=valueasint64;letinstance=newFoo<int64>(value2);returninstance.getValue()asint32;}exportfunctiontestF32(value:float32):float32{letinstance=newFoo<float32>(value);returninstance.getValue();}exportfunctiontestF64(value:float64):float64{letinstance=newFoo<float64>(value);returninstance.getValue();}

Operator overload

classVector3D{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{returnnewVector3D(this.x+other.x,this.y+other.y,this.z+other.z);}operator-(other:Vector3D):Vector3D{returnnewVector3D(this.x-other.x,this.y-other.y,this.z-other.z);}}exportfunctiontest():boolean{leta=newVector3D(1.0f,1.0f,1.0f);letb=newVector3D(1.0f,1.0f,1.0f);letc=a+b;returnc.x==2.0f&&c.y==2.0f&&c.z==2.0f;}

Array

// f64-array.tbsvara:Array<float64>=null;exportfunctiontest(num:int32):Array<float64>{a=newArray<float64>(num);leti:int32=0;while(i<num){a[i]=0.0;i=i+1;}returna;}exportfunctiongetArrayByteLength(value:Array<float64>):int32{returnvalue.bytesLength;}exportfunctiongetArrayElementSize(value:Array<float64>):int32{returnvalue.elementSize;}exportfunctiongetArray():Array<float64>{returna;}exportfunctiongetData(index:int32):float64{returna[index];}exportfunctionsetData(index:int32,value:float64):void{a[index]=value;}

Compile to wasm

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

JoinSlack

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 atwiki (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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp