clio icon indicating copy to clipboard operation
clio copied to clipboard

Discuss C/C++ Implementation

Open garritfra opened this issue 4 years ago • 9 comments

We should discuss a way to use native code for bottleneck functions.

Related

  • My lab on implementing Rust: #131

garritfra avatar Jan 19 '20 13:01 garritfra

https://medium.com/@atulanand94/beginners-guide-to-writing-nodejs-addons-using-c-and-n-api-node-addon-api-9b3b718a9a7f

garritfra avatar Jan 30 '20 12:01 garritfra

Seems Rust is being used for compiling...than isn't it okay to use Rust for native binding? https://github.com/neon-bindings/neon

This is just a question...I'm new in here.

kination avatar Feb 04 '20 09:02 kination

Hi @djKooks! I have tried using Rust with Neon in a small codelab a few days ago (#131), and it worked like a charm. The thing thats holding us back is that if we use rust in our project, the user will need to have the rustc installed on their system, which can be confusing for some people. Another solution would be to build and publish the binaries for every platform via CI, and then downloading it conditionally after installing clio. I think you can see the issues with that :) As much as we'd love to use rust in this project, its not yet suitable for npm packages that will be used on multiple platforms.

Virtually any system has a C/C++ compiler preinstalled, so we can more or less safely assume that we can compile native C++ modules on install-time. Thats why we chose this path for the future.

garritfra avatar Feb 04 '20 09:02 garritfra

@garritfra seems right~thanks for comment 🙏

kination avatar Feb 04 '20 11:02 kination

I started working on an experimental Rust implementation for clio: https://github.com/clio-lang/rio

I'm still trying to evaluate some crates for parser implementations. Feel free to share your thoughts!

garritfra avatar Feb 04 '20 12:02 garritfra

@garritfra great! Is rio to replace pacakges/core/part of this repository?

kination avatar Feb 05 '20 06:02 kination

I don't think so. At least not anytime soon. If we decide to use rust, we'd probably have to move away from npm, and instead go for a release approach (Something like rustup would be great). But for now, we will stick to npm for the sake of simplicity. We're still in an early state of development.

garritfra avatar Feb 05 '20 10:02 garritfra

Afaik, LLVM can compile to JavaScript / WASM, and native binaries / machine code. Should we probably discuss targeting LLVM and moving away from node.js?

pouya-eghbali avatar Feb 05 '20 11:02 pouya-eghbali

Seems this project are focused on 'take advantage of multiple CPUs and CPU cores (parallelism)', maybe you need to think about moving on...(not sure what will be the best option...)

kination avatar Feb 06 '20 00:02 kination