Report Offensive Message

kinda
You could do something like that. There are at least two problems with this, however:

1. As TobiF points out, you'd lose all the little naming convention hints and so on that makes code readable by compiling and decompiling (to a different language) the code.

2. Perhaps worse, you'd get what amounts to an automated writer of atrocious code, because the resulting code would not be idiomatic of the target language, because the abstractions used tend to be so thoroughly different for different high-level languages. For instance, the block-argument form for iterators in Ruby is substantially different from the recursion typically used in Scheme. Translating from Ruby to Scheme via an intermediate language (which would more likely be C than machine language or even assembly language) would likely result in a Scheme program written with clumsy iterations scattered around rather than elegant recursive routines. Even going the other way would not likely result in use of Ruby's powerful iterators being used; instead, you'd get a lot of for and while loops.

Sure, you could learn about the most basic, simplistic syntactic elements of each language by translating code that way, but you wouldn't learn much about the language as a whole, or how to write good code in that language. It is said sometimes that someone who has not adapted to the idioms of (for instance) Ruby "writes Perl in Ruby" or "writes C in Ruby" (or whatever, depending on the particular failures to adapt). This is not a good thing.
Posted by apotheon
12th Nov 2010