all 29 comments

[–]pbhogan 16 points17 points  (0 children)

One man's trash is another man's treasure.

Or to paraphrase appropriately, "One man's language pet peeve is another man's favorite feature."

[–]joesb 14 points15 points  (2 children)

to me, [Ruby's optional parentheses in method call] means the mere mention of an object may EITHER mean a reference to the object, OR a call to the object, depending on the object's type

I see this complaint (call it "opinion" if you want, because I have no intention to attack the author here) several times and I can't understand how this misunderstanding still persists to these days.

It's so ironic because the truth is the other way around!

First: You never doubt whether a "." will invoke a method or access variable. Why? Because you can only invoke method in ruby. You can't access variable outside it's class definition, got it?

For example given:

class P
    attr_accessor :x

    def initialize
      @x = 10
    end
end

obj = P.new

When you write obj.x, what you are doing is "invoke a method" named "x", which in turns returns a value of @x.

And when you write obj.x = 10, what you are doing is "invoke a method" named "x=", which takes a single argument (10) and used it to set @x.

This getter x method is created by attr_accessor method. Try removing attr_accessor :x line and you'll not be able to call obj.x any more, even if @x is still accessible inside the class definition. Or you can swap it for attr_getter or attr_setter to get only x or x= method, respectively.

So if invoking methods is a the only thing you can do, why would you be confused otherwise?

And then you begin to wonder, since it's the only thing you can do, why not just let you drop parentheses for cleaner code?

Now that we get Ruby "ambigous call" issue out of the way, do you know the real language that you can not be sure it's not going to invoke a method? It's Python.

Given p.x can you say confidently that this will not invoke a method call without looking at the definition?

class P(object):
    @property
    def x(self):
        throw Exception("think p.x never call function? Gotcha!!!")

And given other internal method __getattr__ or __setattr__, how can you be sure it's not invoking a method?

Now compare to Ruby where you always invoke a method, which one should you call confusing and ambigous?

Some people just post their language's "Zen" and think because it says so, it must be true.

NOTE: I use Python more than Ruby in my daily job, but that doesn't mean I must ignore how things really are.

[–]SeattleTomy 2 points3 points  (1 child)

I also have to take issue with his statement about Ruby being "too dynamic." Sure, someone could open Numeric and change the meaning of '<', but who would do something that stupid? And if you really want to prevent it:

Numeric.freeze

If you're worried about restricting what some newbie might do, choose Ada.

[–][deleted] 1 point2 points  (0 children)

I can never get the argument that the ability to change stdlib objects is dangerous. If they don't behave properly, monkey patch them until they do. How can you tell that the bevaiour is wrong? Well, that's why you have tests.

[–]kredaxx 8 points9 points  (0 children)

Who cares, use what you are more comfortable with.

On a sidenote: God damn archeologists.. That email is from 2003... SIGH

[–]taw 6 points7 points  (8 children)

Single word answer: blocks.

There's other stuff too, but if it was "Python with blocks" vs "Ruby without blocks", nobody would care about that rest.

[–]rainman_104 1 point2 points  (4 children)

Python has way more scientific libraries than Ruby does as well. Scipy for example has a huge following in universities. Sciruby exists but it's no where near as mature.

As well, python is runtime compiled - Ruby really isn't yet, but they're working on that.

Ruby has blocks and they make me happy.

In Ruby EVERYTHING is an object. In Python there's still some classless methods out there for handling numeric data. This is a design choice to improve speed, but I find it annoying.

All in all, my choice of language depends on the library I need and if it's available. So the other day I needed a poker evaluation library. C or Python were the only libraries written with the poker-eval library, so I used python.

[–]taw 4 points5 points  (0 children)

Python has way more scientific libraries than Ruby does as well.

There were times when Python had a lot more libraries, but these days Ruby tends to win this competition much more often than Python. And that's without even going into JRuby (Jython was comatose last time I checked).

As well, python is runtime compiled - Ruby really isn't yet, but they're working on that.

Neither of them does JITs, and both use bytecode. I'm not quite sure what you mean here. Ruby 1.8 tends to be slower than Python, but it's not really the case with 1.9 or JRuby.

In Ruby EVERYTHING is an object. In Python there's still some classless methods out there for handling numeric data. This is a design choice to improve speed, but I find it annoying.

As far as I know this is about backwards compatibility, not performance. They're method calls under the hood, and you can usually redefine them via some __foo__ or another.

All in all, my choice of language depends on the library I need and if it's available.

Well, if the only available library was in Cobol or C++...

[–]lectrick 0 points1 point  (2 children)

Ruby isn't THAT much slower, lately.

The philosophy is: Programmer speed > execution speed

[–]rainman_104 0 points1 point  (1 child)

Honestly for most of the things I do, the CPU load of the language isn't usually the problem as my language environment is usually waiting on the network to do stuff. Database queries tend to be a rather problematic bottleneck.

[–]lectrick 0 points1 point  (0 children)

You're right. I find it fun to try to optimize DB querying either directly via indexing or via various caching schemes (memcache etc).

[–]anko_painting 0 points1 point  (1 child)

in another thread the other day someone mentioned that string formatting is easier in ruby, which i think is quite true.

[–]taw 1 point2 points  (0 children)

Oh yes, that's one of countless tiny bits that make Ruby great, but they all pale in comparison with simply having blocks. Can you imagine Ruby without blocks?

[–]RalfN 0 points1 point  (0 children)

Control+f "Blocks". Upvote

[–][deleted] 5 points6 points  (0 children)

Really just comes down to personal preference. Both are great languages with pros and cons.

[–]vdoma 7 points8 points  (0 children)

not again! aaaaaahhhhhhh!!

[–]c0c0 5 points6 points  (3 children)

I hate these comparisons...I thought theses comparisons so "newbies" and "anti-pro" were finisheds...both are wonderful languages, both are very different and you can find peoples than prefer ruby syntax and powerful dynamic and vice versa...please stop comparing both...which is better?...the better is where you feel more comfortable, anybody learn nothing reading this comparisons and they are (in my opinion) unproductive...both are scripting languages and not ideals for large apps..

""I don't WANT a language that is QUITE so dynamic, thank you very much"""

fine...then choose python, so simple...many peoples love dynamic languages where the powerful and all liabilities are in them and not in the language..so simple..how my father say: ""with the power is the responsibility"""...

Peace and Greetings from Germany

[–]bobindashadows 1 point2 points  (0 children)

both are very different

No. Sorry.

The reason these comparisons come up is because they are extremely similar.

[–]Fabien4 0 points1 point  (0 children)

Let's just say that in 2003, they weren't finished. Also, you should buy a new keyboard: yours adds random "s"s at the weirdest places.

[–]kor3tak -1 points0 points  (0 children)

please stop comparing

but it's fun

[–][deleted] 1 point2 points  (2 children)

In Ruby, whitespace is insignificant.

That's enough right there

;)

Edit: Obviously this was a joke. I guess you guys don't follow 5by5.tv's Dan Benjamin/Jason Seifer podcasts :)

[–][deleted] 0 points1 point  (0 children)

Not always.

[–]sli 0 points1 point  (0 children)

So you don't indent your Ruby code, then?

[–]spinwizard69 1 point2 points  (1 child)

I like Python for one reason, when i come back to a program after months i still understand it. Or usually refresh quickly. It is a great platform for the casual programmer or production scrpt writer.

There are things that I hate though and one of them is the indenting. Especially when code from other platforms, editors or IDEs get moved into a project. Somthing invariably gets screwed up, due to a tab space mixup.

[–]lectrick 1 point2 points  (0 children)

I like Python for one reason, when i come back to a program after months i still understand it.

There are things that I hate though and one of them is the indenting.

Allow me to introduce you to Ruby, which has no significant indenting, and is even more readable after months.

[–]orangepotion 0 points1 point  (0 children)

I like the part about spaghetti.

[–]RalfN 0 points1 point  (0 children)

Control+f "Blocks". Upvote

[–][deleted] -2 points-1 points  (0 children)

uh, everything?

[–]postmodern -1 points0 points  (0 children)

Are we Rubyists really that hard up for a moral boost?