Earlier quoted context omitted.
Yeah I was thinking it might be better to use something like LLVM IR as the “data structure” and then train deep nets to go $(LANG) => IR and then IR => $(LANG), trained with a lot of idiomatic well written code for each Lang, then the nets might be able to glean the intent more than implementation details. Not sure though, I’m not an expert in LLVM IR, so I’m not sure how feasible that is...
The issue is that LANG -> IR is a lossy transform: some constructs are lost, some language specific optimization passes could be applied, etc. Going from LANG1 -> LANG2 starts with more information, so it could in theory work better.
Deep learning to translate between programming languages
61–70 of 81 posts
Re: Deep learning to translate between programming languages
#62This sounds more impressive than it is. I kept an auto-translation going for quite a while from C# to Go just by creating some bash scripts. These languages are so similar, that while not idiomatic, you can be up and running with quite few rules and some simplifications to the original code. While I believe this is a good arena for algorithms to provide solution, I'm sceptical that ML in its current incarnations is t…
But casting any problem with a discrete correct answer into floating point calculations that mimic probability is a bad idea.
[1] : Learning to Compose Neural Networks for Question Answering
[2] : Inferring and Executing Programs for Visual Reasoning
Re: Deep learning to translate between programming languages
#63Re: Deep learning to translate between programming languages
#64Re: Deep learning to translate between programming languages
#65Earlier quoted context omitted.
Yeah I was thinking it might be better to use something like LLVM IR as the “data structure” and then train deep nets to go $(LANG) => IR and then IR => $(LANG), trained with a lot of idiomatic well written code for each Lang, then the nets might be able to glean the intent more than implementation details. Not sure though, I’m not an expert in LLVM IR, so I’m not sure how feasible that is...
The issue is that LANG -> IR is a lossy transform: some constructs are lost, some language specific optimization passes could be applied, etc. Going from LANG1 -> LANG2 starts with more information, so it could in theory work better.
Re: Deep learning to translate between programming languages
#66Earlier quoted context omitted.
You will need to create common library for all these languages, then write all your programs using your own libraries only.
I don't get why? The AST can be parsed by any single language. Haskell is particularly well-suited for writing parsers.
The only way this could work is if you write the whole stdlib in your AST system.
Of course, this still won't mean your lazy Haskell program works as an eager C program. Language semantics are too different, even between similar languages, you'll ALWAYS hit corner cases on anything more than a toy program. Even if you translate C# to Java. Well, maybe C to C++ will work decently, as few programs use the diverging features.
Re: Deep learning to translate between programming languages
#67This sounds more impressive than it is. I kept an auto-translation going for quite a while from C# to Go just by creating some bash scripts. These languages are so similar, that while not idiomatic, you can be up and running with quite few rules and some simplifications to the original code. While I believe this is a good arena for algorithms to provide solution, I'm sceptical that ML in its current incarnations is t…
C# has an open source compiler (Rosyln) with an API that exposes lot of information, so for advanced needs there is this road too.
Re: Deep learning to translate between programming languages
#68Even if it works, which I doubt, the maintenance question is more important than just porting. Porting is rarely done just because there is a new modern language. Writing a compiler/transcoder is likely easier and safer, guaranteed to work. I wonder what the deep learning would do with concurrent code and differences in the memory models of the languages. The part is rather hard for experts in both languages and conc…
It seems like you could maybe go through machine code as an intermediary?
Re: Deep learning to translate between programming languages
#69Re: Deep learning to translate between programming languages
#70Earlier quoted context omitted.
I don't get why? The AST can be parsed by any single language. Haskell is particularly well-suited for writing parsers.
I believe the point is that you can have perfect syntactic compatibility, but that means nothing when your program calls boost::asio or a Common Lisp defmethod and you want to interpret it as Haskell. The only way this could work is if you write the whole stdlib in your AST system. Of course, this still won't mean your lazy Haskell program works as an eager C program. Language semantics are too different, even betwee…