:,(
I'm searching for some tool that would help me to convert open source caml
(.ml) files to C/C++, C#, VBScript, ASP, and/or PHP.
The main reason for searching a tool that could help me to convert these .ml
files is the following:
1- I don't have the time to learn another new language.
2- I'm already doing programming in some many languages, that it gets
annoying. Just think about it. I'm doing programming in C/C++, C#, and
Visual Basic for college. Soon I will have to learn Java. I'm doing ASP,
PHP, Actionscript and Javascript for Web Design.
3- I don't have problem to learn Caml if in the future I find a company that
required me. Mind while, I would like to spend my time learning how to do
better algorithms that learning thousand of new languages.
Please let me know where I can find a program or opensource program that
could do this task. =)
Regards,
Axl Laruse
axll...@yahoo.com
--
View this message in context: http://www.nabble.com/--Convert-Caml-to-C-C%2B%2B%2C-C-%2C-PHP%2C-etc---tp19791755p19791755.html
Sent from the Caml Discuss2 mailing list archive at Nabble.com.
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
> I'm searching for some tool that would help me to convert open source caml
> (.ml) files to C/C++, C#, VBScript, ASP, and/or PHP.
Sorry, such a tool doesn't exist. It is probably possible to hire
a person to do the conversion.
> The main reason for searching a tool that could help me to convert these .ml
> files is the following:
>
> 1- I don't have the time to learn another new language.
Why is that? Lazy?
The languages you mention are all imperative which means that
conceptually they are all basically the same (the differences
are mostly syntax).
Ocaml on the other hand is a functional programming language
with imperative and object oriented features. Ocaml is far
more different to all of the languages you mention that any
two of that group.
Learning Ocaml (or similar languages like Haskell) will teach more
about programmoing that you will ever learn from learning Java
(another imperative programming language).
> 2- I'm already doing programming in some many languages, that it gets
> annoying. Just think about it.
I use C, C++, Python and Ocaml regularly and a number of other
languages irregularly. I don't see this as a problem.
> 3- I don't have problem to learn Caml if in the future I find a company that
> required me.
Jane St Capital has been on the lookout for Ocaml programmers.
Companies like Microsoft and Intel employ some too. There are
also numerous smaller companies using Ocaml. I work for a small
tech startup and about 50% of the code I write for work is in
Ocaml.
> Mind while, I would like to spend my time learning how to do
> better algorithms that learning thousand of new languages.
Ocaml is not about better algorithms its about different
ways of thinking about programming.
> Please let me know where I can find a program or opensource program that
> could do this task. =)
Which particular piece of ocaml code is it that you want to
convert?
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"life is too long to know C++ well" -- Erik Naggum
--
View this message in context: http://www.nabble.com/--Convert-Caml-to-C-C%2B%2B%2C-C-%2C-PHP%2C-etc---tp19791755p19792384.html
Sent from the Caml Discuss2 mailing list archive at Nabble.com.
_______________________________________________
> I would like to convert all the MTASC open source project to
> C/C++ or PHP.
Sorry, but you're crazy.
MTASC is a compiler and compilers are one of the tasks that
Ocaml does better that all of the languages you mention.
Converting the MTASC compiler to a less capable language (yes, C++
is less capable) would be an exercise in extreme Greenspunning:
http://en.wikipedia.org/wiki/Greenspun's_Tenth_Rule
in that you would need to implement in the target language many
features that are built into Ocaml.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Java is, in many ways, C++--." -- Michael Feldman
Indeed.
> Converting the MTASC compiler to a less capable language (yes, C++
> is less capable) would be an exercise in extreme Greenspunning:
>
> http://en.wikipedia.org/wiki/Greenspun's_Tenth_Rule
>
You forget to mention another rule:
"If it works, don't fix it"
Which also apply to the WORKING mtasc compiler in OCaml.
But, just for fun (and having work at converting COBOL program to
C/C++), I really would like to see the result of an automatic
conversion... Just for fun ;-)
There is something like 100% chances, that the resulting source code will
be totally __unreadable__, not working and full of undetectable bug. I
think it will be worse to have an unreadable PHP file than a clean OCaml
code.
This kind of conversion can fill your entire life -- without good
result. FYI, translating COBOL to other languages is in most cases not
possible and, in the remaining cases, produced code is not readable. The
only thing you can perform, quite well, is COBOL X to COBOL Y
translation (like Fujitsu COBOL to MicroFocus COBOL). Or in our case,
you can perform things like OCaml to JoCaml...
Regards
Sylvain Le Gall
> I'm searching for some tool that would help me to convert open source caml
> (.ml) files to C/C++, C#, VBScript, ASP, and/or PHP.
>
> The main reason for searching a tool that could help me to convert these .ml
> files is the following:
Actually I didn't find a real reason from the list: what are you going
to do with the resulting program after conversion? Any results of
conversion would likely be very difficult to work with.
If you just want to run the programs, you should be able to do that
without conversions, other than compiling the code. If you want to use
it as a library, well, that might be more difficult. I believe there
is a project to enable that for the .NET environment though.
There is one compiler that is similar to what you're looking for:
http://skydeck.com/blog/programming/ocamljs-ocaml-to-javascript-compiler/
I do wonder if you can make any use of that, though. Developing it
further would mean learning O'Caml ;).
--
_____________________________________________________________________
/ __// /__ ____ __ http://www.modeemi.fi/~flux/\ \
/ /_ / // // /\ \/ / \ /
/_/ /_/ \___/ /_/\_\@modeemi.fi \/
Tsk tsk... you know you shouldn't say that. :-)
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bag...@cs.unipr.it
Cheers,
David
On Thu, 2008-10-02 at 22:33 -0700, axllaruse wrote:
> I would like to convert all the MTASC open source project to C/C++ or PHP.
--
David Teller-Rajchenbach
Security of Distributed Systems
http://www.univ-orleans.fr/lifo/Members/David.Teller
Angry researcher: French Universities need reforms, but the LRU act
brings liquidations.
Um, since Ocaml can be compiled to bytecode and said bytecode executed
by an interpreter written in C, that's sorta-kinda el-cheapo conversion
right there. One can work backwards.
1. Get the bytecode compiler to output C that resembles what would be
called in the interpreter loop. That still uses all of the interpreter's
innards, just removes the interpreter loop.
2. Tweak the bytecode compiler to output higher-level C stuff where
applicable. That way you can get C that looks more like C and less like
bytecode-primitives-called-in-C.
(2) is probably the hard part as it involves sweeping modifications to the
compiler. (1) is easy, you can do it on raw bytecode without touching
the compiler, although it'd be a good exercise to get to know the compiler.
Side note: is there an Ocaml bytecode-compiler written in Ocaml somewhere?
It'd be easier to work on than said compiler written in C/C++.
Cheers, Kuba
> Um, since Ocaml can be compiled to bytecode and said bytecode executed
> by an interpreter written in C, that's sorta-kinda el-cheapo conversion
> right there. One can work backwards.
I'm pretty sure the original poster's intent was to convert the MTASC
compiler to C, C++ or PHP and then continue developement in the new
language.
Unfortunately, the machine conversion from languages as different as
Ocaml and the imperative laguages above result ins source code that
may compile in the target language, but is almost completely
unreadable by human programmers familiar with the target language.
Doing the conversion via bytecode would result in even less readable
code than the more direct route for the same reasons that we don't
have usable binary to high level language decompilers.
> Side note: is there an Ocaml bytecode-compiler written in Ocaml
> somewhere?
I'm pretty sure the vast majority of the standard Ocaml bytecode
compiler is written in Ocaml. The same is probably not true for
the bytecode VM.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
Pastafarianism : http://www.venganza.org/
The intelligent alternative to 'Intelligent Design'.
You mean the program that generates OCaml's bytecodes is written in OCaml. I
assume Kuba meant that the program that executes OCaml's bytecodes is not
written in OCaml.
I would love to see an interpreter of OCaml's bytecode that was itself written
in OCaml. There are also some obvious derivative projects, like a JIT
compilers written in MetaOCaml or written using LLVM (similar to Basile's
ocamljit). Once LLVM did some optimizations, it could be interesting to
compare the performance of native-code OCaml with LLVM JITted OCaml bytecode.
Perhaps some things (like Int32/64) could be greatly improved in performance?
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e
> You mean the program that generates OCaml's bytecodes is
> written in OCaml.
Commonly known as a compiler.
> the program that executes OCaml's bytecodes
Commonly known as a virtual machine.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Well behaved women rarely make history." -- Dorothy Parker
One of the compilers, yes.
> > the program that executes OCaml's bytecodes
>
> Commonly known as a virtual machine.
No, I was referring specifically to the interpreter (byterun/interp.c) and not
the run time. So not the whole VM. What is done with the rest of the VM is up
in the air.
An interpreter of OCaml's bytecode written in OCaml or a JIT compiler written
in MetaOCaml would just use their own run time. A JIT compiler using LLVM
would probably interop with the existing run-time.
IIRC, there are differences between the native code and byte code run times
but I do not recall the specifics. I don't know which would be easiest to
target from a JIT compiler.
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e
_______________________________________________
Chicken-and-egg question: how was it bootstrapped, at the dawn of time?
Cheers, Kuba
Some very ancient, embryonic, subset of Caml was initially coded in
LeLisp. You probably won't find any source of them (neither the first
Caml - which was a ancestor of CamlLight - not the LeLisp
implementation, which was proprietary, running on some obscure machine,
perhaps MITRA15 or whatever).
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
http://camlcvs.inria.fr/cgi-bin/cvsweb/cdk/asmdynlink/interp.ml
$ head -18 interp.ml | tail -7
(*
This module implement an interpretor for OCAML bytecode. The bytecode is
supposed to be linked (ie symbols are resolved). Closures are compiled as
native closures taking only one argument each time. For example, GRAB creates
a native closure waiting for "arity" arguments, then putting them on the stack
and calling the interpretor with a new pc.
*)
--
Mauricio Fernandez - http://eigenclass.org
This wouldn't bring you much, unless you're planning to improve MTASC is
some way ?
If you're interested in writing a single language to output to
Javascript / PHP / C++ and FlashSWF, then have a look at http://haxe.org
instead.
Oh, and yes, haXe compiler is written in OCaml as well.
Nicolas