r/programming • • Aug 30 '08

Tour De Babel -- Rant about programming languages (at Amazon)

http://steve.yegge.googlepages.com/tour-de-babel
14 Upvotes

122 comments sorted by

View all comments

11

u/13ren Aug 30 '08

I like his religious rant on emacs, and then had to retract part in footnote [2]. But he seems to have a fair handle on the issues in general.

Is Ruby as good as he says?

22

u/Leonidas_from_XIV Aug 31 '08

Ruby is in fact good, but as a Python programmer I think he overstates the problems with it. When you learn Ruby or Python you don't need to learn the other one because it gives you too less so that it weights out the experience that you already have in the first language.

That said, I don't see Ruby overtaking Python (it is getting used more and more in various application but also on .NET, the JVM etc.) but on the other hand, both Python and Ruby are overtaking Perl.

All three languages are currently in the overhaul phase, Perl 6, Ruby 2 and Python 3, but as far as Perl 6 remains vapourware and the Ruby 2 development seems to be chaotic (not to mention that 1.8.x releases seem to be not 100% compatible) Python is at least the winner here, by providing Python 3.0 plus an upgrade plan, a converter, one or even more compatibility releases etc.

So basically: use Ruby if you want to try it, use Python if you want to try that too. Best if you use both for some things, you'll find out what fits you best.

Yegge complains about whitespace in Python (which, combined with PEP8 does definitely solve some problems curly-brace languages have), but I have to admit, that I hate writing all the ends in Ruby, so it is a thing that you have to get comfortable with. And in the years since this article was published, the complaining about the whitespace is not as common anymore.

23

u/necrecious Aug 31 '08

His prediction of Ruby eating Python's lunch definitely didn't come true. I think Ruby has lost a little momentum due backlash against Rails and Ruby 2's development.

I like a lot of Python's libraries and the communities around those libraries, but I like Ruby's syntax and idioms better.

0

u/[deleted] Aug 31 '08

[deleted] — view deleted comment

3

u/necrecious Aug 31 '08

That's why both languages are co-existing pretty nicely. There isn't huge hate between the two camps as you might expect.

→ More replies (7)

6

u/drbold Aug 31 '08 edited Aug 31 '08

In my experience, people get over the whitespace-shock pretty quickly. I don't find it odd at all anymore, and coding is very comfortable and natural.

6

u/[deleted] Aug 31 '08

That's the same experience I had with Lisp. At first I was all "I can't get used to these parentheses!!!". After a while I don't even see them, I just see the lists they encompass.

5

u/Leonidas_from_XIV Aug 31 '08

Yes, with a decent editor you start actually liking the parentheses. I prefer the regularity of S-Expressions to the quirky syntax that some other languages use.

→ More replies (36)

16

u/[deleted] Aug 31 '08 edited Aug 31 '08

His assertion that whitespace and "frost" (his term for a perceived coldness in Python culture) make Python inferior to Ruby make it hard to take his other assertions seriously.

In Python you have to enter more "self"s. In Ruby you have to enter more "end"s (rather than having whitespace interpretation figure that out for you). Neither are big deals.

12

u/shifty3 Aug 31 '08 edited Aug 31 '08

One thing about Python that annoys me are the builtin functions like len(), reduce(), map() etc. Why aren't these object methods? len() even calls __ len __(). Is this some legacy stuff?

Ruby is much more consistent in this regard, I especially like the convention of using an exclamation mark to denote destructive methods.

4

u/[deleted] Aug 31 '08 edited Aug 31 '08

At least len is a function

lambda x:len(x)
<function <lambda> at 0xb7d0ebfc>

ever been bitten by this one? I have :

lambda x:print(x)
  File "<stdin>", line 1
    lambda x:print(x)
                 ^
SyntaxError: invalid syntax 

5

u/ubernostrum Aug 31 '08

Meh. All languages have inconsistencies like this. Python's len() doesn't really bother me, personally (I like having a convenient polymorphic built-in for certain common operations), but if you see it as an abomination you don't have to use it (or Python).

→ More replies (6)

7

u/[deleted] Aug 31 '08

All three of those functions are built-ins because they operate on any object that looks like a sequence, including lists, tuples, generators, iterators, strings, and any user-defined object that can be iterated over. If I want to write a list-like object without inheriting from list, should I have to write stub map/reduce/len methods just in case someone wants to use them? Wouldn't it be smarter to implement these very generic functions as something that will work on any list-like object?

9

u/akdas Aug 31 '08

If I want to write a list-like object without inheriting from list, should I have to write stub map/reduce/len methods just in case someone wants to use them?

In Ruby, you don't have to inherit from Array to get a bunch of methods that operate on list-like objects for free by simply includeing the Enumerable module.

Wouldn't it be smarter to implement these very generic functions as something that will work on any list-like object?

Like Ruby's Enumerable.

I like Python, and I understand it has a different philosophy, but examples like this are why I prefer Ruby (once again, it's purely a personal preference).

Now if only Ruby's built-in file manipulation libraries were better.

5

u/ubernostrum Aug 31 '08 edited Aug 31 '08

Well.

From the Python perspective I like the fact that len() is a built-in that delegates to a double-underscore method. I like the fact that a lot of other functionality works that way, too, because it means I don't have to treat a bunch of otherwise-usable public identifiers as reserved because someone might interpret their presence as meaning that I'm implementing some API.

I also like the fact that Python deliberately sets off the names of the "special" methods so you know something different is going on.

And there's a certain sparseness that results from the Python approach which appeals to me; for example, Ruby's Enumerable includes at least four methods which simply consist of "return all the items in the collection which match/don't match some condition". As a Python programmer, I instinctively ask:

  • Why should I need to tie up so many names in my class just to do one thing, when filter() or a list comprehension would do just as well?
  • Why should I have to remember which methods take which arguments (some take regular expressions, some take blocks...) instead of having a unified interface that can behave intelligently?

Similarly, there are at least three methods in Enumerable which basically boil down to "execute this code once for each item"; again, why tie up so many names when I could just use map() or a comprehension? Why have multiple methods instead of a unified interface?

→ More replies (2)
→ More replies (2)

9

u/jmhodges Aug 31 '08

I'm going to disagree with Leonidas and say that "[w]hen you learn Ruby or Python you don't need to learn the other one" is a false statement. I came to ruby from python thinking ruby was just another python. I was very, very wrong.

8

u/[deleted] Aug 31 '08

As a former Python programmer, what stuff in Ruby wins you over? I take it it's not just a syntax preference.

12

u/martincmartin Aug 31 '08

As someone who has used both (and also contributed to Groovy), I think the biggest difference is that Ruby has real anonymous functions, that can have an arbitrary number of statements/expressions in them. It makes dealing with any sort of collection much easier. Python's list comprehensions seem timid in comparison: they can only do "collect" and "grep," with single expressions, and the syntax for combining them is different than the rest of the language.

In Ruby, you can write a function which takes a file name and an anonymous function as arguments, then opens the file, passes it to the anon function, then closes the file in a "finally" block. It's much nicer than having to have explicit finally blocks.

6

u/jmhodges Aug 31 '08

mcantelon, that ^ pretty much. It sounds weird, because it is weird when you first run into it. It's a bit different than passing functions around (even anonymous ones in functional languages) because the syntax to do this.. feels different.. cleaner. It's hard to explain, but when you see it and grok it, its a very nice way of seeing a problem in a simpler, easier to understand way.

Oh, and everything is an object and really, really an object and holy christ is it awesome not to have to pass self around everywhere. And modules rock.

I should note that I still like python. Ruby just has some things that are nifty that python doesn't.

→ More replies (17)
→ More replies (1)

5

u/mikkele Aug 31 '08

I guess that what he meant was that either language will do nicely for most of the same tasks. Sure, Ruby has some features that Python does not have (and probably vice versa), but personal preferences aside, either language can be used for roughly the same purposes with roughly the same resulting quality and productivity.

So if you want to be a Ruby hacker, be a good Ruby hacker. Ditto for Python. Either way, it does not matter much these days.

→ More replies (2)

8

u/stewdick Aug 31 '08

I personally like Ruby. However, the easiest thing to do is just to give it a shot: http://tryruby.hobix.com/

4

u/thephotoman Aug 31 '08

Forward: I'm a Python guy.

Ruby is awesome, just like he says. It's a bit sluggish (slower than Python, even), and I don't like the end keyword (personal preference there).

2

u/troelskn Aug 31 '08

I like his religious rant on emacs, and then had to retract part in footnote [2]. But he seems to have a fair handle on the issues in general.

Yeah, that was kind of funny. But it doesn't really detract from the point; vi and emacs are equal in being tools-of-choice for hackers.

Oh, and is it just me, or isn't he confusing Japanese with Chinese? To my knowledge, there are only about fifty or so characters in the Japanese alphabet.

→ More replies (1)
→ More replies (1)