Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat kinds of patterns could I enforce on the code to make it easier to translate to another programming language?
    primarykey
    data
    text
    <p>I am setting out to do a side project that has the goal of translating code from one programming language to another. The languages I am starting with are PHP and Python (Python to PHP should be easier to start with), but ideally I would be able to add other languages with (relative) ease. The plan is:</p> <ul> <li><p>This is geared towards web development. The original and target code will be be sitting on top of frameworks (which I will also have to write). These frameworks will embrace an MVC design pattern and follow strict coding conventions. This should make translation somewhat easier. </p></li> <li><p>I am also looking at IOC and dependency injection, as they might make the translation process easier and less error prone.</p></li> <li><p>I'll make use of Python's <a href="http://docs.python.org/library/parser.html" rel="noreferrer">parser module</a>, which lets me fiddle with the Abstract Syntax Tree. Apparently the closest I can get with PHP is <a href="http://php.net/manual/en/function.token-get-all.php" rel="noreferrer">token_get_all()</a>, which is a start.</p></li> <li><p>From then on I can build the AST, symbol tables and control flow. </p></li> </ul> <p>Then I believe I can start outputting code. <strong>I don't need a perfect translation</strong>. I'll still have to review the generated code and fix problems. Ideally the translator should flag problematic translations.</p> <p>Before you ask "What the hell is the point of this?" The answer is... It'll be an interesting learning experience. If you have any insights on how to make this less daunting, please let me know.</p> <hr> <h3>EDIT:</h3> <p>I am more interested in knowing what kinds of patterns I could enforce on the code to make it easier to translate (ie: IoC, SOA ?) the code than how to do the translation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload