thinscript

A low-level programming language inspired by TypeScript

  • 所有者: evanw/thinscript
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

ThinScript

ThinScript is an experimental programming language that compiles to JavaScript, WebAssembly, and C.
It's meant to be a thin layer on top of WebAssembly that makes it easier to work with: no dependencies and fast compile times.
The syntax is inspired by TypeScript and the compiler is open source and bootstrapped (it can compile itself).

This is still an experiment and isn't intended for real use yet.
The biggest issue is that the generated code currently doesn't delete anything (garbage collection is planned but not yet implemented).
Also the WebAssembly specification is still being developed and the current binary format will stop working when WebAssembly is officially released.

Demo

An interactive compiler demo is available online at http://evanw.github.io/thinscript/.
Here's some example code to demonstrate the language (documentation will be written at some point):

declare function print(text: string): void;

class Link {
  value: int;
  next: Link;
}

class List {
  first: Link;
  last: Link;

  append(value: int): void {
    var link = new Link();
    link.value = value;

    // Append the new link to the end of the chain
    if (this.first == null) this.first = link;
    else this.last.next = link;
    this.last = link;
  }
}

extern function main(): int {
  var list = new List();
  list.append(1);
  list.append(2);
  list.append(3);

  var total = 0;
  var link = list.first;
  while (link != null) {
    total = total + link.value;
    link = link.next;
  }

  #if JS
    print("Hello from JavaScript");
  #elif WASM
    print("Hello from WebAssembly");
  #elif C
    print("Hello from C");
  #else
    print("Unknown target");
  #endif

  return total;
}

Building

Run node build.js to build the compiler using itself.
This generates updated versions of out/compiled.js, out/compiled.wasm, and out/compiled.c.
If you have a C compiler installed, this also builds a native version of the compiler by compiling out/compiled.c and lib/thinc.c together into the out/thinc binary.

主要指標

概覽
名稱與所有者evanw/thinscript
主編程語言C
編程語言HTML (語言數: 3)
平台
許可證
所有者活动
創建於2016-03-22 08:26:09
推送於2016-05-11 17:12:56
最后一次提交2016-04-23 11:58:35
發布數0
用户参与
星數1.4k
關注者數48
派生數49
提交數134
已啟用問題?
問題數17
打開的問題數9
拉請求數1
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?