On 20/02/2014 00:20, Robert A Duff wrote:> Ivan Godard <ivan@ootbcomp.com> writes:>>> ...we use the C++ compiler as the first pass, then execute the resulting>> program as the second pass. You write a C++ function for each machine>> operation: "add(regNum r1, regNum r2)" or whatever.>> Good idea, except I'd write it in Ada or OCaml or something. I've> done something similar.>

This is certainly the most important decision.
The tools/language used cannot be switched during the development.

I wrote a parser for C++ code in C and Flex/Bison. Due to the
difficulty to program complex C code, I have migrated my code to C++.
The code get 20% smaller (due to all free() and low level functions
which are no more necessary) and the code get easier to understand.
The STL contains was also permitting to implement high level
optimization and also reducing the complexity of the algorithms. Doing
this in C is more difficult.

Now, I would write the same in OCaml because:
- The type checking is very good
- Menhir (replacement of Flex/Bison) exists
- The source code would be smaller without syntax glue (like the
necessity to have heaer, ....)
- Easy possibility to program complex algorithm in few lines.
- The OCaml code is only 2 times slower that C code (which is acceptable)
- The startup code (time nead to reach main) is similar to C++.

But migrating an existing project is not possible.
In other words: it makes sense to take time to choose the right
framework at the beginning.