[erlang-questions] Crazy Question: C -> Erlang Core

Dave Smith dave.smith.to@REDACTED
Thu Nov 13 16:40:22 CET 2008


C  Flavoured Erlang???

Converting existing C projects to such a language would be a challenge. Even
if you could transform the language elements, calls to standard libraries
would need to be replaced with OTP.


2008/11/13 Alceste Scalas <alceste@REDACTED>

> Il giorno lun, 10/11/2008 alle 21.33 +0100, Robert Virding ha scritto:
> > Yes, it would be possible [to compile C in Core Erlang] but there
> > would be quite severe restrictions on the C you could write. Three
> > main ones are:
> >
> > - no destructive operations on data as all data is immutable in Erlang
>
> You could simulate destructive operations by using fresh variables.  In
> other words, you could convert your C code into SSA (Static Single
> Assignment) form [1] and then compile it almost directly into Core
> Erlang.
>
> That's what we are doing for compiling a Matlab-like language into Core
> Erlang.  See [2].
>
>
> > - global data is tricky
>
> ...and very slow (you could simulate global variables using a server
> process).
>
>
> > - many of the basic C data structures don't map easily to Erlang
>
> Furthermore, if you need something like pointer arithmetics, you will
> need to simulate the memory as a global variable.  Not very fun...
>
> Regards,
>
> alceste
>
> References:
>
>  [1] Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman,
>        and F. Kenneth Zadeck.  Efficiently computing static single
>        assignment form and the control dependence graph.  ACM
>        Transactions on Programming Languages and Systems (TOPLAS),
>        13(4):451-490, 1991.
>
>  [2] Alceste Scalas, Giovanni Casu and Piero Pili.  High-performance
>        Technical Computing with Erlang.  Presentation at the VII ACM
>        SIGPLAN Erlang Workshop, Victoria, British Columbia, Canada,
>        September 27, 2008.
>        http://www.erlang.org/workshop/2008/Sess23.pdf
>
> --
> Alceste Scalas <alceste@REDACTED>
> CRS4 - http://www.crs4.it/
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081113/deb6a4ef/attachment.htm>


More information about the erlang-questions mailing list