alshdavid / BorrowScript

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

First-class N-API integration #25

Closed vjpr closed 1 year ago

vjpr commented 3 years ago

My first thoughts for a TS-like native language was that it would lower the barriers to entry for writing N-API plugins. Currently most Node tools are being re-written in Rust for performance, but the learning curve is high.

If there was first-class N-API support, and great C library integration, then BS could become the language of choice for writing N-API plugins.

Imagine if wanting to make a TS function fast, was just a matter of changing the file extension to .bs and interoperability with TS code would be seamless. You could use Node's ESM --experimental-loader to achieve this.

It would be interesting to look at a few JS libraries, and see the minimal set of syntax changes that would need to be made to achieve perf improvements as well as safety. Rust trades off ergonomics for explicitness and safety, maybe BS could go the other direction.