Tried pasting a big piece of code. "Whoah, that's big, try something smaller." Ok, paste small snippet of code. Click "translate". "Sign up first". Urgh, fine, this looks just about exiting enough to try, but barely so.
After signing up, I have zero credits, without a single translation performed. I mean, not that I expect free lunch, but I'm also not gonna pay money before seeing a single 10 line example.
It’s not going to rewrite the huge web of dependencies that any given app consists of, nor will it recreate the various differences between runtime environments for interpreted languages.
It’s essentially a cute party trick.
Stuff like copilot is where I see the utility in the space.
There are some bits that just simply cannot be translated. For example, you can’t just “translate” a stdlib function from a high level language into a low level language, there’s likely no comparison in the low level language.
I was about to come back to this thread and post almost the exact same comment. I didn't even get 10 lines - I just converted the 3 line typescript example that was already there, and couldn't try anything else. There's no way I'd ever pay for this.
I used GitHub Copilot to translate a few small programs, from Javascript to Python.
Results:
- single lines went over well, and even became idiomatic in the destination language
- snippets translated well
- for two snippets translated separately, the 2nd snippet didn't understand the original context and got confused. Lesson: translate a whole file at once, or you'll have to fix cross-function references/names.
One test I thought didn't work. My 100 lines of (admittedly crappy) Javascript got cut off. Actually... it worked! It translated 100 lines of JS into 50 lines of idiomatic Python! I was extremely surprised.
More results
- original had a driver function and a worker function. The translated code just inlined everything. I'd have preferred the multiple functions be preserved, but it's okay.
- idiomatic Javascript was translated to idiomatic Python
- it used modules I'd never heard of. I thought the AI had just made things up, but the modules were actually real! Very happy with this.
- it also used old modules. I had to rewrite several lines and retarget the code to use a modern module, vs the original which was deprecated.
Bottom line: at least the AI I tried (Copilot), is effing magic! We saved our client probably $1000 in just one usage of this tool.
I'm going to continue paying for this out of my own pocket, to use for learning new languages, modules, and for translating the occasional small program.
Huge caveat: talk to your Dir Eng or CTO about sending their proprietary code to some random service on the internet. They probably will NOT like it. Thus, AI can only be used in occasional "I'm starting from scratch and learning this" type situations. You can NOT use AI on business code without company consent, which dramatically limits its usefulness for the moment.
Seems completely broken now; like others, I tried to test something, found I had to sign up, signed up, and found I have "0 free credits".
I really wanted to see what it was gonna do for Python -> C++ converting some nested dictionary and list comprehensions:
def foobar(x, y):
return {
_: __
for _, __ in zip(
[_ for _ in x if _ in y],
[_ for _ in x if _ not in y]
)
}
{3: 1, 4: 2} == foobar([1, 2, 3, 4], [3, 4, 5, 6])
Writing code is rarely the problem anyway. Understanding the problem and devising a suitable solution given the full context is where the magic is. And since most humans have a hard time even accurately describing a problem and full context, there's no threat that AI will replace developers.
If we can build up an immense library of clearly defined problems and solutions, with variants which fit with all conceivable unique contexts, then maybe it will become possible for AI to provide useful assistance.
It would be a good goal to do what I describe, as it would result in many fewer bugs in software. The risks then would be either misidentifying the problem (and therefore getting a solution which doesn't fit the need) or providing inaccurate context which allows for suboptimal selection of a predefined solution.
> If we can build up an immense library of clearly defined problems and solutions, with variants which fit with all conceivable unique contexts, then maybe it will become possible for AI to provide useful assistance.
Agreed. What you're describing (an immense library of problems and solutions) is essentially what's in the head of a very experienced developer. A system that helped surface those in a simple way for "new" problems so that people aren't constantly reinventing the wheel and making the same mistakes would be great. I've seen ideas about similar "tacit knowledge" systems in other domains (though I'm not sure there is a good one yet). For software, such a system would be way more helpful, and a much better goal, than this kind of idiot-savant gpt stuff
Programming is 10-20% of the job, sure it's fundamental but even if an AI could generate optimal code solutions for most use cases it'd still never replace us...
It still won't help with setting up the development environment to be able to compile rust of the week or c++??. Both of which have dev communities which adopt forwards incompatible features fairly rapidly so the environment in your distro probably won't work as is. But eventually, maybe they AI will set that up too, https://www.commitstrip.com/en/2019/03/15/css-css-everywhere...
Seems to spin forever. (Which makes sense, as QuakeC is incapable of the constructs in Sample 3).
Edit: after a few minutes spinning it's... Spewing a lot of nonsense. It seems to be dumping every variable combination it can "think" of that it has seen in QuakeC.
TypeScript to Fortran is also broken, generating lots of dlopen/dlsym/dlclose calls (one for every variable, it seems), but never actually doing anything else with it.
For what it's worth, Sample 2 generates syntactically invalid code, having `:` instead of `::`. Sample 1 is actually working code (but relies on the implicit typing rules, which gives you the default real kind instead of double precision reals). Interestingly, translating Sample 1 from Rust to Fortran suddenly generates a subroutine instead of a function, but does generate types.
I think maybe they're being a bit too ambitious by trying to cover so many languages. Obscure languages won't have nearly as many examples to train on.
I had a particularly funny result: Trying sample #3 (put a record into S3) from Typescript to Python, it reliably... outputs a completely different program, which instead downloads an image from S3 and resizes it in /tmp. Weird.
Ditto for converting sample #3 from Python to Rust...it doesn't even try to interact with S3 at all, it just saves the image to a path specified in args (twice, overwriting the first image). Also, the comments it writes are incorrect.
Just tried the default example from C to Forth. It gave an answer but also appended two other commented Forth functions to it.
Also, this almost immediately adds a signup wall not for the real product, but to the little demo box on the home page that makes it not worth playing with
I applaud the effort of whoever put this together, but it is a toy, and a broken one at that. Trivial examples break it easily. When an "AI" like this can take 5,000 lines of SAS in a single file where execution starts at the top and finishes at the bottom with nary a function or external module to be found written by a government employee who hates his job and really doesn't think you should be reading his source code and can turn it in to comprehensible Python that is readable I might be interested. But this is most likely going to be a case of GIGO.
I have written translators and they are really hard. I think training on code bases is the way to go but I am skeptical overall that it is even worth the effort. The problem is that the translation doesn't get you all the way there. The code produced is buggy and wrong in most cases. You probably get a better result from re-designing and re-implementing.
I wonder what the data being trained on even is. It has to include successful translations, right? There are not many of those. Not enough for a good result.
I’ve written translators that also had to consider pattern changes. The amount of training to translate code effectively is enormous to be effective at scale. I assume this is segmenting separate models based on each language permutation.
I would love to see AI applied to predict algorithms and provide intelligent recommendations.
I think it depends on how urgent the migration is, and how much you're paying to fix the bugs.
If the systems works functionally but the infrastructure (?) hasn't aged well, and there's only time / budget to switch horses, that might be the sweet spot.
When trying Sample Code 3 converting the TypeScript to Python the conversion was incorrect. Probably worth swapping that out for another sample if the owner is in this thread. As I was writing this I noticed that this wasn't a Show HN post.
What a good idea! It could also relatively easily verify if it's correct and only return a result when the test is passing and all the lines (or even paths) are covered.
Checkout https://text-generator.io which can also be made to translate between human and computer languages with prompt engineering, has a nice 100 requests a month free teir
You can accomplish something close to this with GitHub Copilot (or OpenAI Codex), just write some code in a comment and then say “rewrite the above (language) code in (language)”. Typing the first few characters of the converted version yourself helps with accuracy.
I tried it with Erlang. Their "Sample Code 2" does not generate working code (lowercase variable assignments), and their "Sample Code 3" does not even generate valid syntax, flat out leaving bits of typescript untranslated.
What's weird is that it starts generating a function to print out its parameters in ts then immediately translates it to cpp, both initiated with comment lines which seems similar to copilot.
After signing up, I have zero credits, without a single translation performed. I mean, not that I expect free lunch, but I'm also not gonna pay money before seeing a single 10 line example.