6 ms·
AI converts between hundreds of programming languages
- bee_rider 4y agoHmm, it wasn't able to convert from Fortran to Matlab for the first exmample, but it seems to have produced legitimate C++ from Fortran. So I guess... this spells doom for the quants but the scientists can sleep soundly.
- lee101 4y agoCheckout https://text-generator.io 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
- dleslie 4y agoI think I broke it. Input: TypeScript Output: QuakeC Code: Sample 3 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.
- UncleOxidant 4y agoI 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.
- adamwk 4y agoProlog also seems to be broken; it keeps importing modules over and over
- mmarx 4y agoTypeScript 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.
- aerovistae 4y agoAh damn I ran out of free credits after like 2 basic runs. Definitely not enough of a taste to convince me to spend money on this. Might want to adjust that freemium model. It's a cool idea for sure and could definitely be useful though.
- version_five 4y agoJust 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
- MauranKilom 4y agoTried 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.
- lofatdairy 4y agoAt least the samples seem legit, in the sense that some break the algorithm badly enough that we can be confident they weren't hard-coded lol.
- john_the_writer 4y agoha ha
- probably_a_gpt 4y agoPlus a trivial translation is just that, trivial. 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.
- cyanydeez 4y agoNot today anyway, but it's not like this type of conversion lives in a unknown future.
- withinboredom 4y agoThere 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.
- 4y ago
- awb 4y agoInteresting going from untyped languages to typed languages, as an inference needs to be made. For example, in JavaScript: function add(a, b) { return a + b; } converting to Go, it becomes: func add(a int, b int) int { return a + b } Where as the original JS version works with integers, floats, strings, arrays, etc.
- john_the_writer 4y agoSame for ruby and elixir. Assumed type..
- danielvaughn 4y agoI just want AI that will write a unit test for me.
- hleszek 4y agoWhat 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.
- ben_w 4y agoI’m remembering a joke from my childhood. Guy is in a computer store. Salesman says “This will halve your workload”. Guy says “Great, I’ll buy two!” We’re nearly there now.
- KMnO4 4y agoHave you tried Copilot? It writes my unit tests 80% of the way. It’s the main reason I pay for it (I hate writing tests).
- dkroy 4y agoWhen 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.
- arriu 4y agoSample 2, typescript to c++: infinite loop. It just keeps spitting out code
- lofatdairy 4y agoWhat'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.
- cleandreams 4y agoI 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.
- chiefalchemist 4y agoI 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.
- jaunkst 4y agoI’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.
- andrewstuart 4y agoAsking me to sign up just to give it a little try made be hit the close tab button real fast.
- Sirened 4y agofinally: fully automated memory corruption
- john_the_writer 4y agoha
- frontman1988 4y agoFirst underwhelming AI post on the frontpage. Thank god our jobs are safe atleast!
- z9znz 4y agoWriting 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.
- version_five 4y ago> 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
- TylerE 4y agoThe interesting bit will be when the AI is smart enough to take an “easy” language like Typescript and convert it to rust or c++
- 4y ago
- john_the_writer 4y agoRUBY... def add(a, b) return a if b.zero? return b if a.zero? a + b end Now lets see elixir :) I say the trial should allow at least one bit of code that we provide.
- SeanLuke 4y agoNot a good sign that this website thinks Java is an acronym. And has both "Lisp" and "Common Lisp".
- vgel 4y agoI 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.
- AYoung010 4y agoDitto 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.
- john_the_writer 4y agoI think the best case something like this could achieve is a syntax translate and nothing more. At best I'd get Ruby code with elixir syntax. Programming languages require thinking about memory and code differently. That's why we have them. I'd be interested to see this in elixir :) while (s++ = t++);
- merlincorey 4y agoSeems 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])
- polygot 4y agoI bought some credits. Here is the result (Python to C++): std::map<int, int> foobar(std::vector<int> x, std::vector<int> y) { std::map<int, int> map; for (int i = 0; i < x.size(); i++) { if (std::find(y.begin(), y.end(), x[i]) != y.end()) { map[x[i]] = x[i + 1]; } } return map; }
- merlincorey 4y agoThanks for checking into that... doesn't look like the AI is even close to ready for prime time right now as this is not the correct translation: #include <algorithm> #include <iostream> #include <map> #include <vector> std::map<int, int> foobar(std::vector<int> x, std::vector<int> y) { std::map<int, int> map; for (int i = 0; i < x.size(); i++) { if (std::find(y.begin(), y.end(), x[i]) != y.end()) { map[x[i]] = x[i + 1]; } } return map; } int main(int argc, char** argv) { std::vector<int> ex{ 1, 2, 3, 4 }; std::vector<int> wy{ 3, 4, 5, 6 }; std::map<int, int> result = foobar(ex, wy); std::cout << "{"; for ( const auto &item : result) { std::cout << item.first << ": " << item.second << ", "; } std::cout << "}" << std::endl; } It outputs: {3: 4, 4: 0, } But it SHOULD be getting: {3: 1, 4: 2, }
- _jal 4y agoDemanding a signup for a toy like this is rude. Like demanding an email address to tell someone the punchline to your joke.
- QuantumSeed 4y agoTried converting a Typescript function that returns the sum of a and b, and it generated: + Clearly not ready for prime time.
- thorum 4y agoYou 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.
- lsbehe 4y agoTried CHIP-8 and so far I got // TODO: Translate the above Rust into CHIP-8 ### TODO and now it got stuck on emitting some assembly. I don't exactly know what because CHIP-8 doesn't have an assembly representation. It printed this 16 times @0000 LD V0, [I] LD V1, [I + 1] LD V2, [I + 2] ADD I, 3 LD V3, [I] LD V4, [I + 1] LD V5, [I + 2] ADD I, 3 LD V6, [I] LD V7, [I + 1] LD V8, [I + 2] ADD I, 3 LD V9, [I] LD VA, [I + 1] LD VB, [I + 2] ADD I, 3 LD VC, [I] LD VD, [I + 1] LD VE, [I + 2] ADD I, 3 LD VF, [I] LD I, V0 LD V0, [I]
- justinlloyd 4y agoI 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.
- brutuz 4y agoYet another simple gpt3/codex wrapper. Monetizing is hard if not much value is offered on top of the AI.
- hemmoworld 4y ago
- mononcqc 4y agoI 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.
- john-tells-all 4y agoI 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.
- strajk 4y agoHow did you instruct Copilot to do the conversion? I've always used it just as a smart auto-complete.
- s3graham 4y agoSample 2, TypeScript -> Common Lisp... might be a recursion joke? :)
- chris_wot 4y agoDon't try to convert sample code two from TypeScript to C++. Or rather do... it goes into a loop.
- _ZeD_ 4y agoDo you plan to support additional languages? I'm working on porting a library from web (ts) to roku (brightscript)
- ThinkBeat 4y agoI wish the price structure was a lot more explicit. I can buy 20.000 credits for $5. This will give me "around 5-20 code conversions" That is a pretty big difference. What are the metrics to estimate what a conversion will cost? I am not critiquing that you cant have a fixed price since length, complexity, edge cases varies significantly but I would like some indication.