Is this local js only or can you compile the c code and serve it to a client to execute in the browser?
Compile and Run C in JavaScript
11–20 of 31 posts
Re: Compile and Run C in JavaScript
#12This was an unplanned feature I worked on mostly a month ago on a Saturday for fun. Happy to answer any questions To get it out the door, ended up adding some patches to TinyCC to support .framework on macOS and fix a few things with dlopen and include paths. Also added support for parsing the deprecated attribute used in lots of Darwin headers. C parsers seem a lot simpler than JavaScript which is nice
Awesome work on this, it looks like a game changer! From my (admittedly limited) knowledge on this space, it seems like this is a straight upgrade over WASM, with the only limiting factor being that your stack is limited to Bun + C. Are there any downsides of this feature when compared with the alternatives mentioned at the start of the article? There are some tradeoffs listed at the bottom but I'm not sure how napi/…
Re: Compile and Run C in JavaScript
#13Anyone that cares about compiling C code should be skilled enough to actually use the right tools in first place.
Re: Compile and Run C in JavaScript
#14https://github.com/holepunchto/bare-abort or https://github.com/holepunchto/bare-buffer
Re: Compile and Run C in JavaScript
#15Re: Compile and Run C in JavaScript
#16The Objj compiler is pretty similar to this in Cappuccino and you get (pretty much) Cocoa bundled with… https://www.cappuccino.dev/
Re: Compile and Run C in JavaScript
#17For me this looks like a solution for a problem that really isn't there. Anyone that cares about compiling C code should be skilled enough to actually use the right tools in first place.
Not sure what you mean by the right tools in this context.
Re: Compile and Run C in JavaScript
#18For me this looks like a solution for a problem that really isn't there. Anyone that cares about compiling C code should be skilled enough to actually use the right tools in first place.
I would say that the problem really is there. Dealing with native dependencies and addons was almost always a pain as the article describes (and not just from developer perspective), so anything that helps there is really appreciated. Not sure what you mean by the right tools in this context.
Secondly, the right tools are having Python, the C and C++ compiler, node-gyp and cmake.js installed, and actually understand how they work.
But what do I know, nowadays folks use C and C++ as scripting languages putting a full library into a single header file to avoid learning how to use the compiler and linker.
Re: Compile and Run C in JavaScript
#19Earlier quoted context omitted.
I would say that the problem really is there. Dealing with native dependencies and addons was almost always a pain as the article describes (and not just from developer perspective), so anything that helps there is really appreciated. Not sure what you mean by the right tools in this context.
First of all, this is for C, and most extensions are written in C++ or Rust nowadays. Secondly, the right tools are having Python, the C and C++ compiler, node-gyp and cmake.js installed, and actually understand how they work. But what do I know, nowadays folks use C and C++ as scripting languages putting a full library into a single header file to avoid learning how to use the compiler and linker.
Re: Compile and Run C in JavaScript
#20Earlier quoted context omitted.
First of all, this is for C, and most extensions are written in C++ or Rust nowadays. Secondly, the right tools are having Python, the C and C++ compiler, node-gyp and cmake.js installed, and actually understand how they work. But what do I know, nowadays folks use C and C++ as scripting languages putting a full library into a single header file to avoid learning how to use the compiler and linker.
I definitely want to avoid learning how to set up and use the compiler and linker when I just want to use some package.