From: Scott Sauyet on
Teo wrote:
> Ok I'll explain myself better, maybe I tackled the problem from an
> uncorrect point of view. I would need a way to "extend" Javascript, or
> something like that, to make C calls. I understood that probably, like
> you guys told me, it's not possible making directly the calls. I mean
> something like extension features of python, ruby etc. Thank you a lot
> agiain.

To run in what environment? In most web browsers, there are already
plug-in architectures that might help. Of course then your users
would have to be willing to install your plug-in. For other
environments, there are probably mechanisms that are useful too. So
where should this run?

--
Scott
From: Joe Nine on
Teo wrote:
> On 10 Mag, 15:31, Teo <matteo.m...(a)gmail.com> wrote:
>> On 10 Mag, 15:12, Erwin Moller
>>
>>
>>
>> <Since_humans_read_this_I_am_spammed_too_m...(a)spamyourself.com> wrote:
>>> Teo schreef:
>>>> Hello,
>>>> I would like to know if it's possible to make C/C++ calls from
>>>> javascript, compiled in a static or dynamic library and included, and
>>>> in such a case how can I do that. Does someone know it? Thank you very
>>>> much. Any help would be very appreciated.
>>>> Regards
>>>> Matteo
>>> Hi,
>>> AFAIK: No, not from within a browser (unless it is broken).
>>> You can of course make calls to your server and do over there whatever
>>> you like (including calling your C libs) and return the output to your
>>> JavaScript.
>>> Something like:
>>> JavaScript instantiates a XMLHTTPREQUEST object (AJAX).
>>> eghttp://www.example.com/myC_call.php?info=34
>>> and catch the output back.
>>> From myC_call.php (or whatever serverside language suits you) you can
>>> call your C routines.
>>> Of course, this solution will not be suitable for fast execution since
>>> it needs a roundtrip to the server.
>>> Maybe using a Java applet makes more sense in your situation. (This
>>> involves writing your C code again in Java.)
>>> Regards,
>>> Erwin Moller
>>> --
>>> "There are two ways of constructing a software design: One way is to
>>> make it so simple that there are obviously no deficiencies, and the
>>> other way is to make it so complicated that there are no obvious
>>> deficiencies. The first method is far more difficult."
>>> -- C.A.R. Hoare
>> Ok I'll explain myself better, maybe I tackled the problem from an
>> uncorrect point of view. I would need a way to "extend" Javascript, or
>> something like that, to make C calls. I understood that probably, like
>> you guys told me, it's not possible making directly the calls. I mean
>> something like extension features of python, ruby etc. Thank you a lot
>> agiain.
>
> I need this to implement a binding for another technology.

If you're limiting usage to Internet Explorer then you can write an
ActiveX control which can call C dlls. It won't work on non-IE plugins
though as they're as sandboxed as Java is.
From: Ry Nohryb on
On May 10, 2:04 pm, Teo <matteo.m...(a)gmail.com> wrote:
> Hello,
>
> I would like to know if it's possible to make C/C++ calls from
> javascript, compiled in a static or dynamic library and included, and
> in such a case how can I do that. Does someone know it? Thank you very
> much. Any help would be very appreciated.
>
> Regards
> Matteo

You can do that freely on a server running server-side JS (e.g.
Node.js [*1]), but not -normally- on a browser -unless you install a
plugin [*2] for that- where the JS code can't call nothing beyond the
provided secure sandboxed API.

(*1) http://node.js
(*2) http://developer.apple.com/Mac/library/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html
--
Jorge.
From: Ry Nohryb on
On May 10, 3:57 pm, Ry Nohryb <jo...(a)jorgechamorro.com> wrote:
>
> You can do that freely on a server running server-side JS (e.g.
> Node.js [*1]), but not -normally- on a browser -unless you install a
> plugin [*2] for that- where the JS code can't call nothing beyond the
> provided secure sandboxed API.
>
> (*1)http://node.js
> (*2)http://developer.apple.com/Mac/library/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html

Sorry, http://nodejs.org and http://nodejs.org/api.html

See also:
http://google.com/search?q=WebKit_PluginProgTopic+filetype:pdf+site:developer.apple.com
--
Jorge.
From: Johannes Baagoe on
Ry Nohryb :

> For server-side JS there's :

> https://wiki.mozilla.org/ServerJS/Existing_APIs
> http://www.mozilla.org/js/spidermonkey/ /* Pure C! (but not too fast) */
> http://code.google.com/p/v8/ /* Damn fast ! */
> http://webkit.org/projects/javascript/ /* JavaScriptCore: Damn fast too!
> ++Pure C API */

Why "for server-side JS" ?

--
Johannes