From: Teo on
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
From: Joe Nine on
Teo 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

From Java you can call C/C++

Java -> JNI -> C libraries

and from JavaScript you can call Java applets

JavaScript -> Java Applet

But I doubt you can complete the sequence from JavaScript to Java to JNI
to C because a Java Applet is trapped within a sandbox called the JVM
(Java Virtual Machine) and I'd be surprised if it lets you access JNI
and C libraries. If it did, then any webpage with an applet on it could
basically do anything at all on your machine.

All the above changes if your web page isn't on the web and can use hta
of course.
From: Erwin Moller on
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).
eg http://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
From: Teo on
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.
From: Teo on
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.