The Objj compiler is pretty similar to this in Cappuccino and you get (pretty much) Cocoa bundled with… https://www.cappuccino.dev/
Compile and Run C in JavaScript
21–30 of 31 posts
Re: Compile and Run C in JavaScript
#22If it is, consider looking in Nim. It compiles to C, and even compiles to Javascript. And is extremely performant while at it.
Re: Compile and Run C in JavaScript
#23...So is this a transpiler of some sort? If it is, consider looking in Nim. It compiles to C, and even compiles to Javascript. And is extremely performant while at it.
In addition, it automatically generates wrappers to transparently convert between Javascript's memory model and C's memory model to seamlessly allow Javascript to call upon the C functions imported using it.
Just your usual FFI, really, but with less call overhead than the FFI specification defined by Node (N-API). Albeit with some different tradeoffs made in order to accomplish that.
Re: Compile and Run C in JavaScript
#24Earlier 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.
The thing is, I'm not already using the Bun runtime and wouldn't switch just for this.
Re: Compile and Run C in JavaScript
#25...So is this a transpiler of some sort? If it is, consider looking in Nim. It compiles to C, and even compiles to Javascript. And is extremely performant while at it.
Of some sort. The C is transpiled to machine code so that the processor can execute it. Turns out CPUs don't understand C natively. In addition, it automatically generates wrappers to transparently convert between Javascript's memory model and C's memory model to seamlessly allow Javascript to call upon the C functions imported using it. Just your usual FFI, really, but with less call overhead than the FFI specificat…
Re: Compile and Run C in JavaScript
#26This 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
Re: Compile and Run C in JavaScript
#27Earlier quoted context omitted.
Of some sort. The C is transpiled to machine code so that the processor can execute it. Turns out CPUs don't understand C natively. In addition, it automatically generates wrappers to transparently convert between Javascript's memory model and C's memory model to seamlessly allow Javascript to call upon the C functions imported using it. Just your usual FFI, really, but with less call overhead than the FFI specificat…
C is compiled to machine code.
Re: Compile and Run C in JavaScript
#28Re: Compile and Run C in JavaScript
#29Earlier quoted context omitted.
Yes, that's right. Compile and transpile are the same thing.
Only for Javascript folks without CS background in compilers.
Re: Compile and Run C in JavaScript
#30It's worth noting that similar functionality is what allowed PHP to be useful well beyond its original capabilities when companies hit scale and needed more performance out of it. Companies would just write a C module for their critical path code, and load it in as a PHP extension.
An article from Facebook in 2010 about them writing and using a custom C extension for PHP, that was probably the precursor to JSX:
https://www.facebook.com/notes/10158791323777200/
An article from Zend in 2011 about how to write a PHP extension in C:
http://web.archive.org/web/20110222035803/http://devzone.zen...