Live data from Hacker News

Compile and Run C in JavaScript

bun.sh

11–20 of 31 posts

Re: Compile and Run C in JavaScript

#12
post #2

This 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/…

NAPI and WASM let you use optimizing compilers, so they're suitable for use with larger C and C++ codebases

Re: Compile and Run C in JavaScript

#13
For 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.

Re: Compile and Run C in JavaScript

#17
post #13

For 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.

Re: Compile and Run C in JavaScript

#18
post #17
post #13

For 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.

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

#19
post #18
post #17

Earlier 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.

I definitely want to avoid learning how to set up and use the compiler and linker when I just want to use some package.

Re: Compile and Run C in JavaScript

#20
post #18

Earlier 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.

Knowledge is empowering.
Post reply on HN