Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translating C to JavaScript [closed]

Tags:

I've got a bunch of math/dsp algorithms in C. Single functions, one function per file, no fancy linking or includes or preprocessor directives, only c99 and standard library calls (mainly memset and memmoves to handle array copying etc). Translating them is not a big problem, but it takes time. I was wondering if there was some C -> Javascript translation tool, in order to speed up the work.

Please mind I don't need a perfect translation, I will put my hand on the final result anyway. What I need is a simple tool that helps with the basic, "boring" things.

Anyone heard of such a thing?

Edit: seems that emscripten will do the trick.

like image 567
janesconference Avatar asked Nov 18 '10 01:11

janesconference


People also ask

Can I use C in JavaScript?

It is possible to implement a C API in JavaScript! This is the approach used in many of Emscripten's libraries, like SDL1 and OpenGL. You can use it to write your own APIs to call from C/C++.

What is $() JavaScript?

The $() function The dollar function, $(), can be used as shorthand for the getElementById function. To refer to an element in the Document Object Model (DOM) of an HTML page, the usual function identifying an element is: document.

Is JavaScript C style?

Many of the other big names, such as Python, Perl, PHP, and Ruby also have a C-style influence, although how important that is, and to what degree, depends on who you ask. JavaScript has a C-like syntax, but is substantially different once you get past the surface.

Can JavaScript be converted to C++?

This is absolutely possible, but all attempts to do so never quite made the golden bridge from C to javascript, if we would, C++ would not exist since C would just be the best language to use at any level of programming.


1 Answers

Update: it seems The Times They Are a-Changin' :)

See this article: DOOM Ported to JavaScript and HTML5

Zakai compiled the DOOM source code from C to JavaScript using Emscripten and Clang and optimized it with Closure Compiler.

And here is the Project page. Have fun! :)

like image 74
25 revs, 4 users 83% Avatar answered Sep 20 '22 00:09

25 revs, 4 users 83%