Mailing List Archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] ruby and python in Japan

On Mon, 26 Feb 2007 13:33:17 +0900, Stephen J. Turnbull <stephen@??> wrote:

Zev Blut writes:

 > Well, this is not restrictive but an annoying aspect is that you must
 > explicitly declare self in all of your instance methods.  It makes the
 > OO aspect of Python feel tacked on.

Ah, you haven't drunk the Kool-Aid.  This is an instance of "explicit
is better than implicit."  I think you should check your mental model
of OO.  I'm not saying that your annoyance is unwarranted---whatever
makes you more productive works for me.  My point is that OO and
implicit arguments are independent constructs.

I am sorry but I must disagree, this simply reeks of an implementation detail. Now I know this technique is very useful when using languages that do not have OO built in yet can easily implement it, but I really have to disagree with this being an instance of "explicit is better than implicit".

 > Also, Rails does some fun stuff with dates and numbers such as
 > "5.days_from_now".

In Python you could spell that

from DateTime import date

five_days_from_now = + 5

So you're exactly right; it's "fun", but lack of it doesn't hinder
serious work by very much.  How much?  This much: you'd like to write

from import today

later = today() + 5

but today is overloaded:

from DateTime.datetime import today

later = today() + 5

The Ruby version does have the advantage that by monkey-patching the
Integer class you can put the units in the method name.  I'd have to
work with it to decide whether that's a convenience or a trap for me.

As you know your above examples also work in Ruby. You are correct that there is no need for something like "5.days_from_now". I have yet to use it and many Japanese Ruby developers like to huff and haw about Rails addition of these methods, but users seem to like it.

Anyway, I don't want to get into a language war so I will end it with
this.  I think Ruby and Python have a number of similar attributes,
but that Ruby has a significantly stronger OO model and other
techniques like blocks and lambdas that make it a bit strong than
Python.  I have looked at Python, but since I know Ruby I do not find
it compelling to learn unless I am going to be paid to do it.  Granted
I am happy to steal good ideas from Python and its' libraries, such as
various concepts in Django and such.  The next languages I would
probably spend more time in are Objective C, Smalltalk, Haskell, Lisp
and Erlang.  Where currently Haskell and Erlang are interesting to me
due to the significantly different model of programming.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links