News for hackers. Stuff that matters.

Show HN: Java to PHP Compiler

I had this crazy idea like some years ago.. I wasn't expecting it be factible, and there's still some semantic problems with this approach

Anyways, the whole idea was to take some java source, generate an AST, and output it back as syntactically correct PHP.

why? 50% fun + 50% exploration

So I have this really basic compiler, which can roughly output its own code; what's still missing?

    - static vs instance detection (-> vs ::)
    - class' properties
    - method visibility
    - enums
    - inner types
    - annonymous classes
    - dealing with method overriding
There's a huge gap in the semantic area (eg: String.format vs sprintf) that is way out of scope for this hack.

Source: https://gist.github.com/eridal/a850a8a665a255b74d2c

( 3 comments | 7 points | on HN )
Re:Show HN: Java to PHP Compiler by freefouran on Friday December 12, 2014 @08:19AM (#8739807)
Interesting idea, you should clean it up into multiple files and put it on an actual repository. If you compiled all of Java's libraries, would you be able to self host the trans-compiler?
Re:Show HN: Java to PHP Compiler by skibz on Friday December 12, 2014 @08:02AM (#8739756)
why have you not put it in a regular repo, yet? by the looks of it, this thing is something far beyond a mere 'gist' :P
Re:Show HN: Java to PHP Compiler by smilepet_26 on Saturday December 13, 2014 @01:12AM (#8744383)
Great work, it looks awesome.