All Projects → StaticScript → Staticscript

StaticScript / Staticscript

Licence: mit
🎉🎉🎉 A new statically typed programming language, syntactically like TypeScript.

Programming Languages

typescript
32286 projects
language
365 projects

Projects that are alternatives of or similar to Staticscript

Soll
SOLL is a new compiler for generate Ewasm from solidity and yul. See a demo here: https://asciinema.org/a/ezJqNLicn5fya02zwu4VXIo8a
Stars: ✭ 329 (-2.37%)
Mutual labels:  compiler, llvm
Play with llvm
A book about LLVM & Clang(中文开源书:玩转 LLVM)
Stars: ✭ 175 (-48.07%)
Mutual labels:  compiler, llvm
Rhine
🔬 a C++ compiler middle-end, using an LLVM backend
Stars: ✭ 157 (-53.41%)
Mutual labels:  compiler, llvm
Flax
general purpose programming language, in the vein of C++
Stars: ✭ 111 (-67.06%)
Mutual labels:  compiler, llvm
Llvm
[MERGED UPSTREAM] AVR backend for the LLVM compiler library
Stars: ✭ 222 (-34.12%)
Mutual labels:  compiler, llvm
Hikari
LLVM Obfuscator
Stars: ✭ 1,585 (+370.33%)
Mutual labels:  compiler, llvm
Compile To Web
Discover what languages can be compiled to Web Assembly
Stars: ✭ 164 (-51.34%)
Mutual labels:  compiler, llvm
Numba Scipy
numba_scipy extends Numba to make it aware of SciPy
Stars: ✭ 98 (-70.92%)
Mutual labels:  compiler, llvm
Nxdk
The cross-platform, open-source SDK to develop for original Xbox: *new* xdk
Stars: ✭ 200 (-40.65%)
Mutual labels:  compiler, llvm
Lhc
The LLVM LHC Haskell Optimization System
Stars: ✭ 188 (-44.21%)
Mutual labels:  compiler, llvm
Brain
An esoteric programming language compiler on top of LLVM based on Brainfuck
Stars: ✭ 112 (-66.77%)
Mutual labels:  compiler, llvm
Deepc
vendor independent deep learning library, compiler and inference framework microcomputers and micro-controllers
Stars: ✭ 260 (-22.85%)
Mutual labels:  compiler, llvm
Fanx
A portable programming language
Stars: ✭ 101 (-70.03%)
Mutual labels:  compiler, llvm
Ispc
Intel SPMD Program Compiler
Stars: ✭ 1,924 (+470.92%)
Mutual labels:  compiler, llvm
Faust
Functional programming language for signal processing and sound synthesis
Stars: ✭ 1,360 (+303.56%)
Mutual labels:  compiler, llvm
Jitfromscratch
Example project from my talks in the LLVM Social Berlin and C++ User Group
Stars: ✭ 158 (-53.12%)
Mutual labels:  compiler, llvm
Ghdl
VHDL 2008/93/87 simulator
Stars: ✭ 1,285 (+281.31%)
Mutual labels:  compiler, llvm
Enzyme.jl
Julia bindings for the Enzyme automatic differentiator
Stars: ✭ 90 (-73.29%)
Mutual labels:  compiler, llvm
Llvm Guide Zh
User Guides For those new to the LLVM system.(LLVM系统的新用户指南,中文翻译版)
Stars: ✭ 180 (-46.59%)
Mutual labels:  compiler, llvm
Ts Llvm
TypeScript to LLVM compiler (abandoned)
Stars: ✭ 230 (-31.75%)
Mutual labels:  compiler, llvm

StaticScript

StaticScript is a statically typed programming language, syntactically like TypeScript.

Github Workflow Status Platform License

GitHub Repo stars GitHub forks GitHub issues GitHub pull requests

GitHub Repository Size GitHub code size in bytes GitHub top language

English | 简体中文

Install

Install on Ubuntu

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-ubuntu.sh)"

Or

wget https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-ubuntu.sh
sudo chmod +x install-ubuntu.sh
sudo /bin/bash install-ubuntu.sh

For other linux distributions, you may need to modify the installation script to install properly.

The installation script may request administrator privileges.

Install on macOS

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-macos.sh)"

Or

wget https://raw.githubusercontent.com/StaticScript/StaticScript/master/install-macos.sh
sudo chmod +x install-macos.sh
sudo /bin/bash install-macos.sh

The installation script may request administrator privileges.

Install on Windows

Temporarily not supported

Usage

First you need to write a legal StaticScript code file as following.

// test.ss

let content: string = "Hello World";

ss_println_string(content);

Then execute the following command from the command line.

staticscript test.ss -o test
./test

Language Features Summary

Variable and Constant Declaration

Here are some variable declarations.

let flag: boolean = true;
let count: number = 20;
let content: string = "Hello World";

Thanks to the type inference feature of StaticScript, we can write the above variable declaration as follows. They are exactly equivalent.

let flag = true;
let count = 20;
let content = "Hello World";

The compiler of StaticScript cleverly deduced the type of the variable from the initial value.

In addition to using let to declare variables, you can also use const to declare constants.

const name = "StaticScript";
const age = 1;
const developing = true;

The difference between let and const is that constants declared with const cannot be modified.

Variable Evaluation

You can use a wealth of operators to perform operations on variables, including arithmetic operations, bitwise operations, logical operations, relational operations, assignments, and string concatenation.

let a = 1;
let b = 2;

// add, subtract, multiply and divide
let sum = a + b;
let diff = a - b;
let product = a * b;
let quotient = a / b;

a = a << 1; // equivalent to `a <<= 1`
b = b >> 1; // equivalent to `b >>= 1`

let year = "2020", month = "08", day = "06";
let birthday = year + "/" + month + "/" + day;

Control Flow

let a = 1;
let b = 100;
if (a < b) {
    ss_println_string("b is bigger");
} else {
    ss_println_string("b is not bigger");
}


let max = a;
if (a < b) {
    max = b;
}

Loops

StaticScript supports using while statement and for statement to do some repetitive things.

// Calculate the sum of all even numbers between [1, 100]
let sum1 = 0;
let i = 1;
while(i <= 100) {
    if (i % 2 == 0) {
        sum1 += i;
    }
}


// Calculate the sum of all integers between [1, 100]
let sum2 = 0;
for(let i = 1; i <= 100; i++) {
    sum2 += i;
}

Function

StaticScript supports defining functions in the top level scope and using function in any scope.

function add(a: number, b: number): number {
    return a + b;
}

The above function can omit the return type because StaticScript can deduce the return type through the expression of the return statement.

It is important to note that the parameter types of functions must be explicitly declared.

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].