What makes this project even more incredible is the fact that it's written in C# under .NET 4.0 using IronRuby for the parser.
Yes it says Mono is supported, but why? Windows is the least run environment for either of these languages (Ruby / PHP). Were I to guess, I'd say this was a dare that it couldn't be done, and if that's the case, then hats off to the owner for doing it.
Somewhat related: One RubyConf, zenspider and tenderlove hacked together Phuby on Phails, an abomination that allowed you to use PHP within Rails. It even translated instance variables from Rails controllers to PHP views.
Projects like these are awesome learning experiences. I've been working on something similar (rubyisms in php) but in pure php - https://github.com/shuber/phuby
Besides being a fun side project and having a chance to play with lexical parsing - does this have any point?
Converting programming languages really doesn't serve any purpose whatsoever - this can't be used as a learning tool (a rubyist wanting to learn php) nor should this output ever be trusted in a production environment as you are going to count on the converted code being as efficient as your original code.
If you want to code in PHP, use PHP - if you want to code in Ruby, use Ruby - this just seems silly.
There are plenty of reasons to use source-to-source compilers (which is what I assume you meant by "converting programming languages")
* Running multiple languages (each with it's own strengths) on platforms that natively support only a few languages. e.x. GWT, CoffeeScript.
* Enhancing an existing language. e.x. Objective-J, Stratified JavaScript.
* Performance. e.x. HipHop for PHP.
* Quickly building new languages. Objective-C (and I think C++?) was originally just a preprocessor for C.
That said, I personally don't find a Ruby-to-PHP compiler particularly useful. Maybe it could be useful for running Ruby on the ubiquitous and cheap Apache/PHP shared hosts, but I suspect the overhead of loading a large amount of code (even just Ruby's standard library, let alone Rails) on each request will make that infeasible.
Converting programming languages really doesn't serve any purpose whatsoever - this can't be used as a learning tool (a rubyist wanting to learn php) nor should this output ever be trusted in a production environment as you are going to count on the converted code being as efficient as your original code.
I'm guessing you don't use a lot of programs written in C?
C++ started out as a precompiled language, and I love CoffeeScript, which compiles to JavaScript. Java and C# don't compile all the way down to assembly either. There are plenty of reasons to compile one language to another.
"Converting programming languages really doesn't serve any purpose whatsoever"
Compilers are useful.
This probably won't reach production quality but that doesn't mean it couldn't with the right effort, see hip-hop or one of those x-> javascript compilers.
The only reason this seems at all useful would be to take advantage of cheap shared hosting that can only run php. But that's hardly a good reason given that you can run a ruby (rack-based) app on heroku for free!
Thats a pretty crappy example to put on the homepage: 13 lines of Ruby compiled into 67 lines of PHP. You could write some PHP more or less identical to the Ruby in the same original 13 lines.
A call of action to all PHP developers out there: We must defend our language against this misrepresentation that PHP is ugly and verbose. It is not a fair comparison of teh power of PHP as it is now. I suggest we start a similar project called "Sucralose" in which we compile PHP into Ruby 1.8 written in Objective-C using MacRuby. I will host it on PEAR. All hail Zend!
I like the implications of the name. Fructose - it's kinda sweet but not quite real sugar, and there's a suspicion of some deep and not-quite-right subterfuge going on underneath the entire industry that supports it for no real reason...
Although I'm sure this was a fun weekend project, which is very cool, I can say that I could actually see something like this being useful IF Ruby could be compiled to PHP which could then be compiled by HipHop to C++.
I've actually played around with this concept. Conceptually it's not very difficult (or at least it wasn't for the code I was working with)... The biggest issue is PHP's reliance on global functions vs Ruby's methods for strings, numbers, arrays, etc. So, for every PHP global string function, for instance, you'd need to pull out one of the arguments and call an equivalent method on it. Bleh.
Is this some sort of snide commentary on how much more limited of a language php is? It doesn't seem like it could possibly be meant for production. I guess I could see it being a fun learning project, tho.
I'm curious - would it be inefficient to use something that could efficiently compile Ruby into PHP such as Fructose, and then use HipHop for PHP from Facebook to compile the PHP into C++? So far I don't see a lot of tools that utilize the Ruby->C++ direction, and much work has gone into HipHop for PHP.
First, HipHop doesn't support create_function, which is used in the example.
Second, feature mismatch between Ruby and PHP will make efficient compilation quite hard and most likely be far from optimal. The languages doesn't seem to be very easily optimizable either.
HipHop isn't a silver bullet either: sometimes it seems to be faster than cached PHP bytecode, but not always.
[+] [-] jameskilton|15 years ago|reply
Yes it says Mono is supported, but why? Windows is the least run environment for either of these languages (Ruby / PHP). Were I to guess, I'd say this was a dare that it couldn't be done, and if that's the case, then hats off to the owner for doing it.
[+] [-] aphyr|15 years ago|reply
[+] [-] wiredfool|15 years ago|reply
Now that would be perverse.
[+] [-] VladRussian|15 years ago|reply
[+] [-] mnutt|15 years ago|reply
http://www.youtube.com/watch?v=lsWKjS6Vufw
[+] [-] bonquesha99|15 years ago|reply
[+] [-] elliottcarlson|15 years ago|reply
Converting programming languages really doesn't serve any purpose whatsoever - this can't be used as a learning tool (a rubyist wanting to learn php) nor should this output ever be trusted in a production environment as you are going to count on the converted code being as efficient as your original code.
If you want to code in PHP, use PHP - if you want to code in Ruby, use Ruby - this just seems silly.
[+] [-] tlrobinson|15 years ago|reply
* Running multiple languages (each with it's own strengths) on platforms that natively support only a few languages. e.x. GWT, CoffeeScript.
* Enhancing an existing language. e.x. Objective-J, Stratified JavaScript.
* Performance. e.x. HipHop for PHP.
* Quickly building new languages. Objective-C (and I think C++?) was originally just a preprocessor for C.
That said, I personally don't find a Ruby-to-PHP compiler particularly useful. Maybe it could be useful for running Ruby on the ubiquitous and cheap Apache/PHP shared hosts, but I suspect the overhead of loading a large amount of code (even just Ruby's standard library, let alone Rails) on each request will make that infeasible.
[+] [-] jrockway|15 years ago|reply
I'm guessing you don't use a lot of programs written in C?
[+] [-] pkulak|15 years ago|reply
[+] [-] rtaycher|15 years ago|reply
[+] [-] drm237|15 years ago|reply
[+] [-] mburney|15 years ago|reply
[+] [-] stanmancan|15 years ago|reply
[+] [-] ctide|15 years ago|reply
[+] [-] fosk|15 years ago|reply
[+] [-] hardboiled|15 years ago|reply
[+] [-] compay|15 years ago|reply
[+] [-] bigiain|15 years ago|reply
I like the implications of the name. Fructose - it's kinda sweet but not quite real sugar, and there's a suspicion of some deep and not-quite-right subterfuge going on underneath the entire industry that supports it for no real reason...
[+] [-] mitchellh|15 years ago|reply
But still, fun project to see.
[+] [-] jonursenbach|15 years ago|reply
[+] [-] erik_p|15 years ago|reply
(Did I just feel all of the HN rubyists shudder at once?)
[+] [-] StavrosK|15 years ago|reply
[+] [-] swivelmaster|15 years ago|reply
[+] [-] rauljara|15 years ago|reply
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] healthyhippo|15 years ago|reply
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] TamDenholm|15 years ago|reply
[+] [-] mduvall|15 years ago|reply
[+] [-] lautis|15 years ago|reply
First, HipHop doesn't support create_function, which is used in the example.
Second, feature mismatch between Ruby and PHP will make efficient compilation quite hard and most likely be far from optimal. The languages doesn't seem to be very easily optimizable either.
HipHop isn't a silver bullet either: sometimes it seems to be faster than cached PHP bytecode, but not always.
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] ashchristopher|15 years ago|reply
Active community participation too =).
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] michaelhalligan|15 years ago|reply
[deleted]