Hacker News new | past | comments | ask | show | jobs | submit login
Unholy: _why's Ruby to Python compiler (github.com/whymirror)
130 points by DanielRibeiro on March 14, 2011 | hide | past | favorite | 54 comments



_why was infinitely pragmatic. He serves as a constant, near daily inspiration to me, just because he programmed because he wanted to, because he loved it, not because it was his career.


_why is indeed an inspiration to all of us. i always make sure that i point out "Poignant Guide to Ruby" and other _why's brilliance to ruby newbies.


I think he may have been so whimsical that he popped out the other side of reality into the pragmatic.


In his comments, he says Ruby and Python programmers "battle" a lot. I love and use Python a lot and have a small dislike for Ruby's very irregular syntax, but nothing worth fighting for.

But don't get me started on Java... ;-)


I don't know how long you've been doing Python and Ruby, but when Why wrote that, the relationship between Rubyists and Pythonistas was pretty chilly.

As I saw it: There was this feeling that, after years of being dismissed as a mere scripting language, it was Python's time to shine — but then Ruby came along and (pushed along by Rails) was about to steal Python's thunder, and they were so similar that people thought there was only room for one such language in the New World Order. So Pythonistas began acting pretty rude toward the upstart Rubyists, and the Rubyists got this idea that Python was an evil, enemy technology.


There is a stark ideological contrast between the Ruby and Python communities with regard to code uniformity. Pythonistas believe there should be only one obvious way to do things. Rubyists, on the other hand, are more accepting of personal style in code, probably having gleaned some of the individualism from Perl culture.


I disagree, Rubyist barely exist, Ruby is primarily driven by Rails, and if anything is more opposite to the Perl TMTOWTDI concept it's "The Rails Way". You can follow the Rails design or you can experience a lot of pain trying to do it any other way.


Two comments:

I spent the past week at a multi-lang conference in Montreal as part of the Ruby contingent. What i found is that most of the non-rubyists have a notion of Rails that is stuck back in 2007. Rails has changed a whole lot, particularly with version 3, and in doing so, has become a much better citizen in the Rubysphere, in particular it's integration with other libraries and tools. So in so far as that is the case, Rails follows a Rubyist paradigm now.

Second, i strongly disagree with the notion that the Ruby ethos and aesthetic "barely exist[s]". The number of Ruby conferences which do not have a rails focus that take place every year is quite large. Rails is and has been known to be different from Ruby, and once you are anywhere away from being a casual user of Rails, you will become familiar with the Ruby aesthetic by virtue of encountering libraries outside of Rails. The days of Rails plugins are gone.


That is…not how most Rubyists view things, and not how most of the Ruby code out there works.

Yes, Rails brought convention-over-configuration to the forefront of Ruby programming, but it wasn't the first library to do so…and it's had a lot of external influences as well. Remember that Rails3 is essentially Merb2, and that's heavily influenced by Rack as the backing mechanisms for networking.

Just in the Web arena, Rails is the big player, but Sinatra matters, as does Padrino. Ruby is still closer to Perl's TMTOWTDI than Python's "preferably one".

[Edited to fix typing errors from the iPad.]


I agree Rails is not the Ruby opus magnum and the easiest way to get convinced about it is to read ruby-talk list for a couple of months.

OTOH the Python's "one way" is also not the point and is easily misunderstood.

I recently jumped into myriads of Python low-level webserver libs and engines - like say Sinatra. I had to investigate them thoroughly to decide what to use for our startup. There are dozens of them and each encourages some other style of programming. There wouldn't be so much of them if people went into "one way of doing things" church.


You're right: it's a preference for "one obvious way", not saying that there's "only one way". My error for saying this the way that I did.

Ruby also has a bit of the "obvious way" (convention over configuration) stuff, but it's not as front-and-center as, say, the Zen of Python (where the obvious way stuff comes from, IIRC).

There's more in common than not in common between the two languages. I still prefer Ruby because it works the way my brain does (or, more accurately, there are choices made in Python design that do not work the way my brain does).


That's a regrettably blinkered view of Ruby.


I don't remember Python ever having a driving force equivalent to Rails. Ruby was a somewhat obscure language before Rails, regardless of its strenghts. I got into Python because of Zope, but the world would be a much, much better place had it been as popular as Rails.


I'm glad Zope lost, and that has nothing to do with Python.

Zope was just a morass of over-complication. I remember buying the zope book sometime in the early 00s.

I was initially impressed with the completeness, but found it to be overly-complex and ugly to work with. Rails + Django happened for a reason.

Now, I haven't played with it in maybe 8 years, but I'd say pre-rails it was just not as elegant.


I see you met Zope 2. There is still a lot of it under Plone.

Neither Rails nor Django appeared on the radar before Zope 3 and Zope 3 is much a nicer platform than 2 (they applied a lot of lessons learned when making it). Grok is even more interesting, as it brings the convention over configuration to Zope 3 (Zope Corp does a lot of government contracts where, I assume, XML configuration files were mandated by clueless PHBs)

Also, had Zope been more successful at that time, it would have captured a lot of space that's now owned by Sharepoint and EJB messes.


While it is true that Ruby became popular because of Rails, it is no longer true that Ruby is only popular in the area of Rails nowadays.


Speaking as someone who used to write Zope 2 apps, allow me to say no. Hell, no.

Zope < 3.0 was a convoluted mess of two over-engineered applications named Bobo and Principia that were hacked together.

That's why the API had functions names like:

  bobobase_modification_time 
  principia_is_folderish
That's why Zope 3 was rewritten from scratch.

Zope 3 has a sane, albeit complex, architecture. Regretably it came too late into the game and by the time it was ready, every Python web developer had moved to turbogears or something else.

The only interesting piece of technology from Zope was the ZODB. I wish it had developed as a separate product.


> the world would be a much, much better place had it been as popular as Rails.

Why?


No relational database sort of hidden under an object-relational mapper, a template language where the template is valid HTML are two reasons that pop out promptly. Also, Python would be more popular now, perhaps taking some space from things far uglier than Python or Ruby.

Just imagine the joy of using ZODB instead of EJB's layered on top of Oracle databases.


I don't understand why having your template be valid HTML is even a little bit good (I'm not saying it's bad — I just don't see why it's better than anything else). I don't think sending unprocessed templates as pages is a common use case, so there is zero benefit in having them be in a language that a browser can render unmodified.


Argh, I meant to upvote ig1's reply, but accidentally hit the arrow down... these arrows are so close together!


Perhaps I don't participate in the mailing lists and message boards where these battles were fought, but the only python/ruby users I've met in real life have always been pretty neutral towards the other language, at least acknowledging that it's better than the alternatives (PHP, Java etc).


Maybe this should serve as a reminder to all of us: http://jacobian.org/writing/thank-you-rails/


Do you have an example of this? I've always seen it as the other way round - Rubyists dismissing Python along with PHP and Java as old/irrelevant/less powerful.

But the whole thing is pointless anyway. Everyone should learn at least a little of both languages since they're both fantastic.


I have to agree the Ruby community always seemed to be very... emotional.


I saw a video of a talk of DHH in which he expressed his love for Ruby; he also said that Ruby was/is his first language and he doesn't need any other languages. As a counterexample, he showed a snippet of a Python class and scoffed at the double underscores for special methods, and the need to explicitely use 'self'.


> and they were so similar that people thought there was only room for one such language in the New World Order.

I hear this said a lot, but where does this idea come from? Their object models are different, their syntax is different, their goals are different.

Admittedly, I haven't written much Python (my experience is mostly reading it), but that's primarily because I preferred Ruby and have never seen what Python brings to the table.


Heh, and I use Ruby a lot and find Python's syntax troublesome :) I do like the idea that we can all unite behind hatred of Java however. Although Groovy at least is a step up and would be my choice if I ever had to program Java under threat of death or dismemberment.

Also I'd highly recommend the movie Python from 2000, starring none other than Wil Wheaton trying to defend the small town of Ruby from an attack by a giant Python.


Last time I tried Groovy I found that the speed of it is really the pain of using it. It was considerably slower than plain Java.

I'd recommend Scala even if you skip all the functional parts of it (Clojure's too un-java to speak as an alternative.)


Groovy++ is working on improving the performance: http://code.google.com/p/groovypptest/


You kidding? Clojure is nice precisely because it's an un-Java as it can possibly be.


Exactly. If one want a Java-but-less-painful, Clojure ain't it.


"Java-but-less-painful" makes every bit as much sense as "gently gouging out an eye" ;-)


Sheesh. Listen, I'm a rubyist as much as anyone and have a number of commercial ruby/rails projects under my belt, but I've also done Java for more than a decade. This willingness by rubyists to piss on Java is quite silly. Java as a language can be frustrating at times, but it's really not that bad and the platform itself is solid. I manage a number of applications in Java which would be an absolute nightmare to write in ruby, simply because of their complexity and size. In large systems, Java excels.


Why not just use JRuby over Groovy?


I'd use Jython or Clojure (or JRuby). Or start considering an afterlife or prosthetics.


Freud's Narcissism of small differences 1): the phenomenon that it is precisely communities with adjoining territories, and related to each other in other ways as well, who are engaged in constant feuds and ridiculing each other.

This theory applies to some other conflicts such as Hells Angels vs. Bandidos, Emacs vs. Vim, Sunni muslims vs. Shia muslims, Christians vs. Protestants etc.

1) http://en.wikipedia.org/wiki/Narcissism_of_small_differences


Old joke (which you might well believe if you've heard Protestants talking amongst themselves/ourselves):

I was walking across a bridge one day, and I saw a man standing on the edge, about to jump off. So I ran over and said, "Stop! Don't do it!" "Why shouldn't I?" he said. I said, "Well, there's so much to live for!" He said, "Like what?" I said, "Well, are you religious or atheist?" He said, "Religious." I said, "Me too! Are your Christian or Buddhist?" He said, "Christian." I said, "Me too! Are you Catholic or Protestant?" He said, "Protestant." I said, Me too! Are your Episcopalian or Baptist? He said, "Baptist!" I said, "Wow! Me too! Are your Baptist Church of God or Baptist Church of the Lord? He said, Baptist Church of God!" I said, "Me too! Are your Original Baptist Church of God or are you Reformed Baptist Church of God?" He said, "Reformed Baptist Church of God!" I said, "Me too! Are you Reformed Baptist Church of God, Reformation of 1879, or Reformed Baptist Church of God, Reformation of 1915?" He said, "Reformed Baptist Church of God, Reformation of 1915!" I said, "Die, heretic scum!" and pushed him off.


I feel it worth pointing out (with no disrespect to parent) that this was written by Emo Phillips, the paraprosdokian master of our time.


Hahah nice joke. Thx.


Th differences between vi and Emacs are not small


Uhh no your examples aren't about "small differences" they're about power struggles. Not the same thing. :-)


Python's syntax has some irritating holes in it too. Why, for instance, do class methods rely on annotations? Why not take advantage of the explicit self? It's almost like there's a blessed core to Python's syntax that crystalised in about 2000, and nothing since then has been allowed to infringe on it.


>> Why, for instance, do class methods rely on annotations?

Python do not have annotations. Decorators are not like java annotations.

>>Why not take advantage of the explicit self?

I think "self" is good. Python lets you bloody patch python objects and classes in runtime and "self" makes it more clear.

Something like:

class MyClass(object): pass

def setX(self,x): self.x = x

MyClass.setX = setX

mc = MyClass()

mc.getX = lambda self: self.x

(INB4: I do not think that bloody patching is good practice)


> Python do not have annotations. Decorators are not like java annotations.

Sorry, yes - wrong word. The point stands, though. For class methods to require the use of a feature as outside the core syntax as decorators just screams of a hacked-in afterthought.

> I think "self" is good.

I am indifferent to it, but the fact that the space in the syntax opened up by requiring an explicit receiver on all method definitions is not taken advantage of for class methods speaks volumes.


Class methods are not so useful in python as in java and C#.

I think that classmethods was added only for java/C# folks.

In fact it's always better just to combine defs in module and use it as module.method.

I like the approach in Scala with "objects" (Scala-singletones).

About "self": I don't understand you. Can you show me a language with optional (not forced) OOP, that lets you bloody patch objects and classes that deals with this problem in better way?


I wrote a parser once that translated Ruby code using Python syntax convention into Ruby. It felt like it was basically Python, without explicit self method parameters. But I'm sure everything was horribly un-Pythonic.


Java has a very regular syntax, albeit a verbose one... but I guess the last part about Java was for different reasons.


If you like this, check out RubyPython[1], a project recently started by Aman Gupta, one of Github's new hires.

1: https://github.com/tmm1/rubypython


This claim is incorrect: Aman Gupta did not create RubyPython, nor does he claim to (and Aman's repo linked above even shows that his repo is a fork of my repo).

Aman has provided some comments, discussion, and code back to RubyPython over the last few days. I know this because I've been chatting with him and pulling his modifications back into the main GitHub repo[1] (which happens to be mine) and pushing them back into the canonical repo on Bitbucket[2] (which is the original creator's repo).

RubyPython was created in 2008 by Zach Raines, rewritten to use FFI in late 2010. Steeve Morin forked it as Rupy (apparently with Zach's blessing as Zach pointed me to it when I posted a bug fix to Zach's code) earlier this year. I got involved shortly after Steeve's fork. After some discussion, we (Steeve, Zach, and I) unforked Rupy back into RubyPython and opened the project a bit wider. I'm currently working on a new release (0.5) that should be out later this week that unifies the two repositories and includes some fixes and enhancements by Aman.

We're using Schacon's wonderful hg-git[3] for navigating between git and hg.

[1] https://github.com/halostatue/rubypython [2] https://bitbucket.org/raineszm/rubypython/ [3] https://hg-git.github.com/


Sadly, this can't handle C extensions in either language, making it unable to port a lot of major libraries. Fun to play around with, though.


Is there any reason as to why this resurfaces from 2008? No pun intended.


"... any reason as to why this resurfaces from 2008? ..."

A practical reason: Ruby doesn't have the depth of Python libraries, get more done in less time.[0] A theoretical reason: reading through the docs you find that 'decompyle' is based on 'spark' (John Aycock's generic small languages compiler), learning new things about languages & compilers is good. A philosophical reason: studying _whys' code is like finding some lost Greek classic from the library of Alexandria. Worthy of reading, just to see how a hacker works this problem, thus making it timeless.

[0] At the time the code was written.


why the lucky stiff was like the BucketHead (http://en.wikipedia.org/wiki/Buckethead) or Daft Punk of programming. I like that - besides the mysterious persona thing - he also reserved the right to follow any tangent; He's a musician as well and made an album for one of his programming books if i'm not mistaken.

If/when I release my programming mixtape - in which i'll spite hot fire about unit testing and my gripes with MVC - he'll definitely get a spot in the liner notes. haha :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: