[cap-talk] Confessions of a C programmer
Sandro Magi
naasking at higherlogics.com
Tue Sep 22 16:39:27 PDT 2009
The OCaml compiler can output C *object files*, suitable for linking
with other C object files, which is used for the OCaml FFI. The C you
saw was for the platform-specific Pervasives and Unix modules which link
to the platform's C libraries.
The object files are generated via assembly code emission, not to C and
and compiled via the C compiler. I don't think OCaml ever compiled to C,
and I will eat my shirt if you can find an OCaml compiler switch that
outputs C!
One of OCaml's claims to fame is that a primary performance determinant
is good native code generation, not intermediate optimizations (as MLTon
and Haskell do). They do very few intermediate optimizations, which is
why their compiler is so fast, and yet compiled program performance is
still good, so they've proven their point.
Sandro
Stiegler, Marc D wrote:
>> I also wish to clarify what seems to be a common
>> misconception: OCaml does not compile to C. It has its own
>> native code generator, and a C-based bytecode VM for
>> unsupported architectures.
>
> Sandro, the last time I installed Ocaml on a windows box (about 2 years ago), there were two sets of instructions for setting it up to use either the Cygwin gcc compiler, or the Visual Studio C compiler, for the final step of compilation. The programmer never needs to look at the C intermediary code, the programmer just sees executable native code at the end of the pipe, but the C is there in an intermediary step.
>
> --marcs
> _______________________________________________
> cap-talk mailing list
> cap-talk at mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/cap-talk
More information about the cap-talk
mailing list