alshdavid / BorrowScript

TypeScript with a Borrow Checker. Multi-threaded, Tiny binaries. No GC. Easy to write.
1.45k stars 16 forks source link

Compiler #49

Closed argoopjmc closed 1 year ago

argoopjmc commented 2 years ago

Have you decided how you want to build the compiler for BorrowScript? I think at this point, we have a basic specification for the language so some of us interested in the project can start coming up with a test suite of valid and invalid source files for the language, along with discussing and setting up the basic infrastructure for the compiler ( parsing and code generation).

I think it would be a great idea to have a Discord/Slack for this project where people can join, discuss and work together on making this project a reality.

alshdavid commented 2 years ago

Great idea, will set up a discord channel to kick things off.

I'm new to writing compilers so it will take me some time to learn things like targeting llvm, etc - but I was planning on starting by writing an AST parser, type checking and borrow checking prior to compilation.

By the time it's done I'll hopefully know enough about llvm to know how to target it, or just go with a less sophisticated approach of code to code compilation to C then use gcc to compile the program.

argoopjmc commented 2 years ago

That sounds like a plan! Let us know when we join and help out.

mindplay-dk commented 2 years ago

I've been hearing a lot about MLIR lately - I came across this video, which provides a basic overview of MLIR and LLVM. 🙂

ESchouten commented 2 years ago

Brainspin: with WASM and WASI growing and maturing, can't we just compile to WebAssembly?

mindplay-dk commented 2 years ago

Yeah, I have been wondering about the same thing. 🤔

Basically, WASM + SIMD + threads = FAST

![image](https://imgopt.infoq.com/fit-in/1200x2400/filters:quality(80)/filters:no_upscale()/articles/webassembly-simd-multithreading-performance-gains/en/resources/16Picture2-1613514952206.jpg)

It might be relatively easier to target WASM than LLVM or MLIR?

Although perhaps with SIMD it's now just as hard to generate optimized WASM?

alshdavid commented 2 years ago

Sorry I keep dropping off on this project - I have been going away studying how I could approach it. I have spent some time learning LLVM IR and I think it's entirely rational to target LLVM from the get go (rather than my previously proposed BS -> C++ transpiler).

A lot of the language syntax makes sense except the way lifetimes are designed and there is nothing on how "unsafe" will be applied syntactically.

That said, it doesn't stop the ability for me to start writing some of the more basic features, like a hello world application.

Once the language compiler starts moving forward, there will be the big task of the standard library and tooling.