As I've been delving into the fundamentals of Linux, hardware, and networking, I've grown increasingly fascinated by how programs in various langua...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
Am I the only one who thought, from the title of this article, that it was going to be about somehow interpreting a compiled C program from JavaScript in the browser? Admittedly that would be a total waste of time, but at least it would have made the title accurate. The titie of this article should be "Using Node"s exec() function". It has nothing specifically to do with C programs, and barely anything to do with JavaScript as most people would expect, in the context of a browser environment. I doubt that title would have garnered as many clicks, though.
Sorry, that was not the intent. I am changing the title right now as you suggested
Thanks for the feedback <3
I assumed it was something using Emscripten and C.
I have been using Emscripten and will make a post on calling a C program converted to a webassembly using emscripten and called via javascript.
Now that would be an interesting article! I looked at emscripten, but for my purposes, AssemblyScript was a better choice for writing Wasm functions.
Will make one soon, I am working on some emscripten and its been a struggle but it's all worth it when you see pointers exchanged between C and javascript.
I made the first one dev.to/amythical/call-c-binary-fro...
Agreed. The language the called program is written in is irrelevant. It could be written in any language.
Just like they said, "if something can be made with JavaScript, it will be made with JavaScript".
haha :D
This is cool, I've been looking for a solution to run shell scripts in my EC2 without resorting to changing from JavaScript, thanks for the insight!
Awesome post! Do you have a solution for executing FFI from C in JavaScript?
Ahh! Good question, i've never tried it. But, found this
node-ffi
from google search, maybe it will work.JavaScript can do some amazing things, though not necessarily quickly. for instance, I once implemented Brenham's line and circle algorithms using JavaScript. Thing to keep in mind is that JavaScript was specifically designed to not be able to be used to access the file system of the client except on Server Side Javascript, and even then, pretty dangerous. When you give shell access to a program, the permissions run at the system level. That means a hacker could gain access to the machine and anything on it, and even use it to access other machines on the network
Of course you can invoke a binary from any (system scripting language) script. The amount of filler text before and after, as well as the overly complicated wrap around exec() makes me wonder if it's mostly a ChatGPT generated article. The title "Executing C Code with JavaScript" is extremely misleading.
My thoughts too. I came in expecting a C compiler or interpreter written in JavaScript.
learnful.