4 ms·
> No, transpiled code is bad. Moreover, I see close to no point in transpilation of a code made to run in browser from an another language. Instead of writing a
by guitarbill 9y ago
> No, transpiled code is bad. Moreover, I see close to no point in transpilation of a code made to run in browser from an another language. Instead of writing an in-browser app in Go, and then spending an amount of time equal to writing the original code fixing bugs brought by transpilation, why not to just write the thing in Javascript from the start?
Transpiled code is not inherently bad. Transpiling is still compilation, we just give it a different name to distinguish "high-level" to "high-level" compilation from the more usual "high-level" to "low-level" compilation (whatever high/low-level exactly means).
Compilers exist to support nicer/more high-level syntax on a common platform, Babel is no different than Java, GCC or LLVM in this regard. A nice side-effect of compilation is certain checks for correctness, and compile-time checks don't get magically erased because you're transpiling to a different high-level language.
Note that when he says "write the thing in Javascript from the start", that's not giving all the facts. Javascript now has several versions, how do you target older ones, or if you're using older ones, how do you take advantage of newer concepts? You'll either be using a load of shims, or probably transpiling Javascript. Babel is pretty sane as far as the Javascript ecosystem goes, and has some great upsides. IMO it's better to use Babel so you get to use the newer ECMAScript features (which is future-proof for when browser adoption progresses), instead of infesting your codebase with cancerous "helper" libraries like underscore that are painful to remove or replace with modern ECMAScript equivalents.
So, if transpiling helps you write more maintainable code, don't be put off by this. Assembly isn't that practical, neither is really old Javascript.