News for hackers. Stuff that matters.
Re:Transpiling between any programming languages (2019) by fsajkdnjk on Sunday February 16, 2020 @08:29AM (#22341455)
sound great, doesn't work. if it would work, we would have perfect translations for spoken languages already. and google(translate) with it's massive computing, financial and brain power still hasn't figured it out.
Re:Transpiling between any programming languages (2019) by cdirkx on Sunday February 16, 2020 @09:14AM (#22341622)
Spoken languages have the problem of ambiguity, context, changing meaning over time to different people. Programming languages are pretty structured and well defined.
Re:Transpiling between any programming languages (2019) by forgotmypw77 on Sunday February 16, 2020 @10:02AM (#22341822)
First we,ll figure out translating Java to Ruby, then English to Japanese, and only then we,ll be ready to translate Perl :D
Re:Transpiling between any programming languages (2019) by krcz on Sunday February 16, 2020 @09:26AM (#22341664)
On the other hand most spoken languages use similar underlying concepts (with some exceptions, e.g. translation to language without subjective direction terms like "left" or "right" might be tricky). Programming languages can have completely different execution models, especially when you compare ones between paradigms. Translating imperative for loop into map/filter/fold chain in functional language would have to be very non-local.
Re:Transpiling between any programming languages (2019) by cdirkx on Sunday February 16, 2020 @09:37AM (#22341708)
Yes it would probably produce a lot of unidiomatic code (see for example c2rust [1], which generates semantically equivalent Rust code, but with raw pointers and unsafe everywhere). In the worst case you could even just emulate the origin language in the target language, everything is turing complete after all.

With enough effort and smart transformation passes however, I think you could come pretty close to something resembling "native" code. It might not always be worth it to spend that development time though.

[1] https://c2rust.com/

Re:Transpiling between any programming languages (2019) by samatman on Sunday February 16, 2020 @11:39AM (#22342311)
On the contrary, it's trivially possible due to Turing Completeness.

Programming languages aren't languages. They're arithmetic calculations wearing linguistic clothing.

Making it idiomatic and fast, is very, very difficult. Achievable for a subset focused on querying MongoDB? Absolutely.

Re:Transpiling between any programming languages (2019) by JadeNB on Sunday February 16, 2020 @11:14AM (#22342163)
Compilers obviously don't work, because, if they did, then we could automatically turn written English into machine language.
Re:Transpiling between any programming languages (2019) by hooplaz on Sunday February 16, 2020 @09:07AM (#22341586)
Programming languages and natural spoken languages are very different.
Re:Transpiling between any programming languages (2019) by The_rationalist on Sunday February 16, 2020 @04:07PM (#22343765)
BTW any programming language construct can be expressed in natural language. (maybe unidiomatically) The reverse isn't true.

Maybe one day the field of literate programming will come to maturity.