Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ovr/StaticScript
:rocket: TypeScript compiler on top of TypeScript as frontend and LLVM as backend
https://github.com/ovr/StaticScript
llvm typescript
Last synced: 3 days ago
JSON representation
:rocket: TypeScript compiler on top of TypeScript as frontend and LLVM as backend
- Host: GitHub
- URL: https://github.com/ovr/StaticScript
- Owner: ovr
- License: other
- Created: 2018-10-06T17:07:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-12T17:55:41.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T07:34:26.107Z (9 days ago)
- Topics: llvm, typescript
- Language: TypeScript
- Homepage:
- Size: 2.23 MB
- Stars: 630
- Watchers: 21
- Forks: 29
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StaticScript
> Real Static Typed Script - RSTS project.
StaticScript is a language on top of TypeScript as frontend and LLVM as backend for code-generation to binary.
![](./docs/assets/how-it-works.png)
### How it was implemented
My talk about How it's working on hight level and about V8/JIT and etc
[Video](https://www.youtube.com/watch?v=gS9a_NBHdw0)
I prepared two talks on PiterJS meetup with explanation about how it was implemented
***Part 1***
[Slides](https://speakerdeck.com/ovr/staticscript-typescript-compiler-on-top-of-typescript-as-frontend-and-llvm-as-backend-number-1)
[Video](https://youtu.be/KjJn-J8d1Xc)
***Part 2***
[Slides](https://speakerdeck.com/ovr/staticscript-typescript-compiler-on-top-of-typescript-as-frontend-and-llvm-as-backend-number-2)
(Video)(Sorry, but due technical problems on meetup It was not recorded)
# Installing
For latest stable version:
```sh
npm install -g static-script
```# Let's write simple example
Put it in `calculate-pi.ts`
```ts
{
function calculatePI(cycles: number): number {
let inside = 0;for (let i = 0; i < cycles; i++) {
let x = Math.random() * 2 - 1;
let y = Math.random() * 2 - 1;if ((x*x + y*y) < 1) {
inside++
}
}return 4.0 * inside / cycles;
}console_log(calculatePI(1000000000));
}
```Next compile it:
```sh
$ ./bin/ssc calculate-pi.ts
```Next run it:
```sh
$ time ./output/main
```This will produce:
```
3.144800
./output/main 0,01s user 0,00s system 80% cpu 0,013 total
```### LICENSE
This project is open-sourced software licensed under the MIT License.
See the [LICENSE](LICENSE) file for more information.