Live data from Hacker News

Deep learning to translate between programming languages

ai.facebook.com

41–50 of 81 posts

Re: Deep learning to translate between programming languages

#41
post #27

Earlier quoted context omitted.

And it's also a quite nonsensical use of ML technology, to be honest. Neural nets are good for problem domains with fuzzy definitions of right and wrong as you find them in the physical world out there. Is this a tiger or a rock? Is this food or poison? Should I walk around this pond or swim through it? That's what the human brain is good at handling and neural nets are trying to approximate that. Programming languag…

So why does it work better than the commercially available tools at the moment as claimed in the article?

Because the commercially available tools aren't that good and because they kept working on it until it was better.

If they kept working on it I think they would run into an asymptote. Maybe they could get closer and closer to 90% accuracy on a task with real hardware, 92% boiling the oceans, and 93% with a Dyson sphere, 93.5% if you can harness a quasar. At that point it probably passes a whiteboard interview and the people who have to fix the bugs can console themselves that the last programmer had neither a brain nor a soul.

That system has an approximate, not an exact model of the domain it works on and that is why it has an asymptote. Turning a graph-structured program into a vector is like mapping the curved surface of the Earth onto a flat map -- except instead of it being a 3-dimensional space it is more like a 1000-dimensional space. Information is destroyed in that process and forever lost so there will always be important characteristics of the problem that it will never "get".

If the message recipient is a person they will meet you halfway and might even accept bullshit if it is presented with complete confidence and lack of shame. The computer will interpret exactly what you said and reveal that you're a dog. (e.g. mute animal)

Re: Deep learning to translate between programming languages

#43

Cool magic trick but I fail to see anything useful coming out of it. I would not blindly rewrite code, rather see how it can be improved and maybe dig a bit in the existing functionality, clean it out, use the new language in my advantage... Also as a programmer your mental modal is completely out of sync, how do you work on such application suddenly now that its all in Python (coming from C++)? Or is this shipped to…

You would, but FB and some other companies are dealing with 20 years and millions of lines of code written by a small army of developers. If they decide to switch language and rebuild their services, just doing it manually will in all likelihood take longer and more people if they don't apply tricks like automatic conversion, because it takes more effort to rebuild than to build fresh due to multiple reasons.

Re: Deep learning to translate between programming languages

#44
post #22

Earlier quoted context omitted.

How well does that really work out? It seems like that would aggregate a lot of cruft, or are there ways around that?

I think the theory is a small subset of engineers can do work that speeds up the entire codebase for the rest of the engineers instead of spending time rewriting that entire code base and also retraining all of those engineers.

I think this is just it; at some point, code becomes a numbers game, an investment game. Rewriting their PHP codebase to, say, C++ would cost 10000 work-years, whereas creating HVVM cost 100 (random numbers) at a 1000% improvement in performance.

Rewrites at that scale are really expensive and take forever, and by the time it's done they'll be running behind the facts already.

Re: Deep learning to translate between programming languages

#45
post #28

Earlier quoted context omitted.

And it's also a quite nonsensical use of ML technology, to be honest. Neural nets are good for problem domains with fuzzy definitions of right and wrong as you find them in the physical world out there. Is this a tiger or a rock? Is this food or poison? Should I walk around this pond or swim through it? That's what the human brain is good at handling and neural nets are trying to approximate that. Programming languag…

> "undefined" corners but that's not because we don't understand them but because they are deliberately left open. Even they are precisely defined. Not sure what language you are referring to, because this statement is very vague, but it's worth pointing out that undefined behavior in the C/C++ sense is absolutely not precisely defined. If a program executes undefined behavior in either of these languages, the entire…

Reminds me of that time I exported my MATLAB code as C.

Re: Deep learning to translate between programming languages

#46
post #33
post #16

This 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…

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...

Good call on LLVM. Was thinking about that too, but had to look up IR. This one looked interesting:

https://idea.popcount.org/2013-07-24-ir-is-better-than-assem...

IR looks to be targetting machine code, so not sure it'll be the right format to embed high-level language concepts.

Re: Deep learning to translate between programming languages

#47
I've been thinking of a pandoc-like tool to translate between languages, i.e. a transpiler.

You would need to write down the most general abstract syntax tree (AST) that encompasses all supported languages' features, as well as a way to read languages into this AST, and write the AST into languages.

The cool thing about pandoc is the ability to transform the AST between the read and write. In the context of a transpiler, that might mean that you transform the AST to be safer (e.g. adding type-checks in Python) before writing out.

That would be a very tedious tool to write, given that every language has its strange behaviors. But it might be a fun project if you limit the number of languages you support.

Re: Deep learning to translate between programming languages

#48

I've been thinking of a pandoc-like tool to translate between languages, i.e. a transpiler. You would need to write down the most general abstract syntax tree (AST) that encompasses all supported languages' features, as well as a way to read languages into this AST, and write the AST into languages. The cool thing about pandoc is the ability to transform the AST between the read and write. In the context of a transpi…

Something like LLVM and decompiling

Re: Deep learning to translate between programming languages

#50
I see deep learning doing really well for one shot translation of declarative languages like HTML etc. As well as simple grammars like English etc. You could maybe generate HTML and CSS based on English.

But languages that have side effects, such as imperative languages, would be very hard to generate. On the other hand, this is the first thing I’ve seen that approaches it.

I am very worried about the uncanny valley of producing stuff based on remixing other stuff with no understanding of the logic behind it.

Recognizing and classifying images and finding correlations is altogether different than programming. I can see how physics and science can be automated. But programming?

Post reply on HN