4 ms·
Running multiple languages (each with it's own strengths) on platforms that natively support only a few languages. e.x. GWT, CoffeeScript. While this may be a
by elliottcarlson 16y ago
Running multiple languages (each with it's own strengths) on platforms that natively support only a few languages. e.x. GWT, CoffeeScript.
While this may be a valid arguement for some - I just can't accept it - if you are targeting a specific platform you really should (completely imho) use the tools meant for it. Anything else will easily lead to issues that may not be debug-able if you aren't already familiar with your target.
Enhancing an existing language. e.x. Objective-J, Stratified JavaScript.
Both of these enhance an existing language by creating a interpreted scripting language that gets compiled down by the original language. I wouldn't classify these as a source-to-source compiler imho.
Performance. e.x. HipHop for PHP.
HipHop is indeed a good example and I stand corrected there. The slight difference is that this is specifically targetted at creating highly optimized C++ to be compiled for quicker execution. In a Ruby-to-PHP example it's certainly not going to add performance gain and is a silly idea - but as I said, I didn't think about a valid execution like HipHop in my initial blanket statement.
Quickly building new languages. Objective-C (and I think C++?) was originally just a preprocessor for C.
I didn't even think about preprocessors and they are indeed another valid implementation for source-to-source compilation.
My original statement was a bit too quickly posted - thanks for the correction!
- chc 16y agoThat's about as sensible as saying that languages that compile to machine code are impractical because you can't read machine code on all the platforms where you're going to deploy. Which is every language, ultimately. And you're also discounting the possibility that somebody might know multiple languages well enough to support the generated code (as is usually the case for CoffeeScripters) but are more productive one language for certain tasks.
- billybob 16y ago"if you are targeting a specific platform you really should (completely imho) use the tools meant for it. Anything else will easily lead to issues that may not be debug-able if you aren't already familiar with your target." By that logic, since my processor doesn't natively run Ruby, I should be coding in machine language. I can't speak for CoffeeScript yet, but the front-end developer who sits near me is using SCSS to generate CSS for our web pages, and he is able to do things that wouldn't be practical with plain CSS. For example, change a base color variable from blue to green, and have all the other colors on the page adjust to use complementary colors. If you trust Ruby to produce reliable C code and C to produce reliable assembly code, etc, isn't it possible that Coffeescript could produce reliable Javascript? Mightn't it give you advantages like Ruby gives you over plain C? I think this is less a matter of "compiling X to Y is good/bad" than "do I trust this particular conversion to be done correctly?" As far as compiling Ruby to PHP - well, I can't see any use for that at the moment, but I'm sure someone will come up with one. :)