Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[BLOG] A different perspective on Ruby.

16 views
Skip to first unread message

ES

unread,
May 25, 2005, 11:46:49 PM5/25/05
to

This has perhaps been aired here already, if so, apologies.

Someone did not like Ruby; I find it refreshing to read
these takes as well since the actually bring up some
(fairly) valid points, this one moreso than usual.

http://www.ericw.org/rants/showrant.psp?rant=ruby

E


--
template<typename duck>
void quack(duck& d) { d.quack(); }


James Britt

unread,
May 26, 2005, 12:18:50 AM5/26/05
to
ES wrote:
> This has perhaps been aired here already, if so, apologies.
>
> Someone did not like Ruby; I find it refreshing to read
> these takes as well since the actually bring up some
> (fairly) valid points, this one moreso than usual.
>
> http://www.ericw.org/rants/showrant.psp?rant=ruby

First, an OT question: Is there a Firefox extension that lets me
*quickly* disable/enable page colors? I know I can do this via the Web
dev tool bar stuff, but it's too many clicks, and sites with white text
on a dark background (hip as that may be) are so painful to look at I
get retina burn before I can finish all that clicking.

About the log entry. I have a rule of thumb. If someone is using the
words "shit" or "fuck" three or four times on page, they quickly lose
all credibility. (Certain words should be treated like global
variables: saved for special cases and for specific effect.)

I like reading critiques (or criticism, even) of Ruby, but most of what
was mentioned there were straw man arguments. Certainly POLS is a known
subjective aspect and an easy target. I expect everyone reading
ruby-talk could assemble a list of cases where Ruby violates their own
sense of POLS.


James Britt

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys


Martin DeMello

unread,
May 26, 2005, 1:36:18 AM5/26/05
to
James Britt <jam...@neurogami.com> wrote:
>
> First, an OT question: Is there a Firefox extension that lets me
> *quickly* disable/enable page colors? I know I can do this via the Web
> dev tool bar stuff, but it's too many clicks, and sites with white text
> on a dark background (hip as that may be) are so painful to look at I
> get retina burn before I can finish all that clicking.

I use a bookmarklet in my bookmarks toolbar for this.

http://www.squarefree.com/bookmarklets/zap.html

martin

Luc Heinrich

unread,
May 26, 2005, 3:51:56 AM5/26/05
to
On 26 mai 05, at 05:46, ES wrote:

> Someone did not like Ruby; I find it refreshing to read
> these takes as well since the actually bring up some
> (fairly) valid points, this one moreso than usual.

Some valid points ? I think this guy does not know what he's talking
about, or simply did not read the documentation correctly, or is
simply blinded by something he should unlearn first, or simply likes
making straw man arguments for the sake of it, or simply likes to
rant (that I can understand, I like it too :) ).

And calling the language creator(s) "fucktard(s)" really doesn't help
making a point, really.

--
Luc Heinrich - luc...@mac.com - http://www.honk-honk.com

Dennis Roberts

unread,
May 26, 2005, 4:15:36 AM5/26/05
to
He is 18 and just out of high school and thinks he knows everything.
I think everyone goes through that phase.

gabriele renzi

unread,
May 26, 2005, 5:31:59 AM5/26/05
to
Martin DeMello ha scritto:

> I use a bookmarklet in my bookmarks toolbar for this.
>

for *just a second* I've been thinking you used a toolbar to collect
places where ruby-talk shows that POLS relates to Matz' least surprise.
How lovely.

Andrew Walrond

unread,
May 26, 2005, 5:36:01 AM5/26/05
to
On Thursday 26 May 2005 04:46, ES wrote:
> This has perhaps been aired here already, if so, apologies.
>
> Someone did not like Ruby; I find it refreshing to read
> these takes as well since the actually bring up some
> (fairly) valid points, this one moreso than usual.
>
> http://www.ericw.org/rants/showrant.psp?rant=ruby
>

Despite the fucking swearing, he did come up with a list of almost everything
that has confused or annoyed me since I started using ruby.

What he neglected to mention is that Ruby is without doubt the closest attempt
yet at a perfect scripting language. Sure, it has some wrinkles, but I have
high hopes of those being sorted in the next iteration, whether by Matz or by
somebody else standing on his (and other giants) shoulders.

Despite the colourful language, an insightful critique and worth a quick
browse.

Andrew Walrond

PS The lack of documentation regarding method thrown exceptions is perhaps my
favourite criticism. Not at all core, but frustrating as hell when writing
OO /exception driven programs.


gabriele renzi

unread,
May 26, 2005, 5:37:05 AM5/26/05
to
Luc Heinrich ha scritto:

> On 26 mai 05, at 05:46, ES wrote:
>
>> Someone did not like Ruby; I find it refreshing to read
>> these takes as well since the actually bring up some
>> (fairly) valid points, this one moreso than usual.
>
>
> Some valid points ? I think this guy does not know what he's talking
> about, or simply did not read the documentation correctly, or is simply
> blinded by something he should unlearn first, or simply likes making
> straw man arguments for the sake of it, or simply likes to rant (that I
> can understand, I like it too :) ).
>

I think this is a bad written rant, but I agree that I'd like implicit
namespace creation a-la python and that it's refreshing to see some ruby
critiques.

Austin Ziegler

unread,
May 26, 2005, 7:12:29 AM5/26/05
to
On 5/25/05, ES <rub...@magical-cat.org> wrote:
> This has perhaps been aired here already, if so, apologies.
>
> Someone did not like Ruby; I find it refreshing to read
> these takes as well since the actually bring up some
> (fairly) valid points, this one moreso than usual.
>
> http://www.ericw.org/rants/showrant.psp?rant=ruby

I haven't seen it, and I see very little valid on that page.

-austin
--
Austin Ziegler * halos...@gmail.com
* Alternate: aus...@halostatue.ca


gsin...@gmail.com

unread,
May 26, 2005, 8:32:44 AM5/26/05
to
ES wrote:

> http://www.ericw.org/rants/showrant.psp?rant=ruby

"It's 5.abs for absolute value, but Math.sqrt(5) for square root."

Good point. That bugs me too. abs is a *function*, not logically a
method.

A few other good points, too. Shame about the presentation.

Gavin

Brian Schröder

unread,
May 26, 2005, 8:38:34 AM5/26/05
to
On 26/05/05, gsin...@gmail.com <gsin...@gmail.com> wrote:
> ES wrote:
>
> > http://www.ericw.org/rants/showrant.psp?rant=ruby
>
> "It's 5.abs for absolute value, but Math.sqrt(5) for square root."
>
> Good point. That bugs me too. abs is a *function*, not logically a
> method.
>

Why not 5.sqrt instead. Better to ask the object to do something, that
to do something with the object. That allows to use duck typing and
special casing to be done in the "special cased" object. I prefer
"string".length a lot over length(string)

regards,

Brian

> Gavin
>
>


--
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/


Florian Frank

unread,
May 26, 2005, 8:42:58 AM5/26/05
to
gsin...@gmail.com wrote:

>Good point. That bugs me too. abs is a *function*, not logically a
>method.
>
>

What about 5.-@ ?

--
Florian Frank

Martin DeMello

unread,
May 26, 2005, 8:43:50 AM5/26/05
to
gsin...@gmail.com <gsin...@gmail.com> wrote:
> ES wrote:
>
> > http://www.ericw.org/rants/showrant.psp?rant=ruby
>
> "It's 5.abs for absolute value, but Math.sqrt(5) for square root."
>
> Good point. That bugs me too. abs is a *function*, not logically a
> method.

I'd say conceptually abs belongs with floor, ceil, round and truncate.

martin

Cameron McBride

unread,
May 26, 2005, 8:53:47 AM5/26/05
to
On 5/26/05, Brian Schröder <ruby....@gmail.com> wrote:
> On 26/05/05, gsin...@gmail.com <gsin...@gmail.com> wrote:
> > ES wrote:
> >
> > > http://www.ericw.org/rants/showrant.psp?rant=ruby
> >
> > "It's 5.abs for absolute value, but Math.sqrt(5) for square root."
> >
> > Good point. That bugs me too. abs is a *function*, not logically a
> > method.
> >
>
> Why not 5.sqrt instead. Better to ask the object to do something, that
> to do something with the object.

I would also agree. This did make me ponder when I initially found
it. If they have to be in a module, wouldn't it make sense to have it
be default includeable?

Cameron


Jim Freeze

unread,
May 26, 2005, 8:56:42 AM5/26/05
to
* gsin...@gmail.com <gsin...@gmail.com> [2005-05-26 21:35:19 +0900]:

> "It's 5.abs for absolute value, but Math.sqrt(5) for square root."
>
> Good point. That bugs me too. abs is a *function*, not logically a
> method.

My take is that there are a few methods that apply to floats
and ints and bignums. These (like floor, ceil, abs) are commonly
known, accepted and used functions and it makes sense to make
them methods.

However, my f(x) is likely to be different than your f(x). In
fact, there are an infinite number f(x)'s in the world and
an infinite number of function names. If Ruby included them
into numeric, then I would feel like I was in Java swing. :)

Also, since 9/4 = 2, I'm not so sure that 5.sqrt wouldn't
be 2 or 0, depending upon how you slice it.

> A few other good points, too. Shame about the presentation.

Nothing that hasn't been said before, but in a much more acceptable
way that promotes good discussion and real action.

Nothing new here people... move along, move along.

--
Jim Freeze
Ruby: I can explain it to ya but I can't understand it fer ya.


Yukihiro Matsumoto

unread,
May 26, 2005, 9:51:39 AM5/26/05
to
Hi,

In message "Re: A different perspective on Ruby."


on Thu, 26 May 2005 21:35:19 +0900, "gsin...@gmail.com" <gsin...@gmail.com> writes:

|"It's 5.abs for absolute value, but Math.sqrt(5) for square root."
|
|Good point. That bugs me too. abs is a *function*, not logically a
|method.

The definition of abs is not questionable; it returns self, negated
when self is negative, for all numeric value. On the other hand,
natural sqrt() may return float or integer, or something else. That's
the reason for sqrt() being a function in Math module. Note that the
name "Math" means math.h (collection of float value functions) in
Unix, not mathematics in general.

Besides that, he doesn't understand what POLS means. Since someone
will surprise for any arbitrary choice, it is impossible to satisfy
"least surprise" in his sense. The truth is two folds: a) when there
are two or more choices in the language design decision, I take the
one that makes _me_ surprise least. b) as a result, you will have
less surprise in Ruby than other languages, once you have accustomed
to it.

But I'm tired of explaining POLS again and again. I haven't even used
it first. I hope no one will use the term "POLS" any more to sell
Ruby. It's free after all.

matz.


Jay Levitt

unread,
May 26, 2005, 10:32:36 AM5/26/05
to
In article <1117115503.104127...@x31.priv.netlab.jp>,
ma...@ruby-lang.org says...

> Besides that, he doesn't understand what POLS means. Since someone
> will surprise for any arbitrary choice, it is impossible to satisfy
> "least surprise" in his sense. The truth is two folds: a) when there
> are two or more choices in the language design decision, I take the
> one that makes _me_ surprise least. b) as a result, you will have
> less surprise in Ruby than other languages, once you have accustomed
> to it.

Nicely put. I suggest we start referring to the POMLS - Principle of
Matz's Least Surprise. That way, if anyone ever debates it, you can pop
in and say "I wasn't surprised at all," thus authoritatively refuting
the argument!

--
Jay Levitt |
Wellesley, MA | I feel calm. I feel ready. I can only
Faster: jay at jay dot fm | conclude that's because I don't have a
http://www.jay.fm | full grasp of the situation. - Mark Adler

ES

unread,
May 26, 2005, 12:31:48 PM5/26/05
to

Le 26/5/2005, "James Britt" <jam...@neurogami.com> a écrit:

>ES wrote:
>> This has perhaps been aired here already, if so, apologies.
>>
>> Someone did not like Ruby; I find it refreshing to read
>> these takes as well since the actually bring up some
>> (fairly) valid points, this one moreso than usual.
>>
>> http://www.ericw.org/rants/showrant.psp?rant=ruby
>
>First, an OT question: Is there a Firefox extension that lets me
>*quickly* disable/enable page colors? I know I can do this via the Web
>dev tool bar stuff, but it's too many clicks, and sites with white text
>on a dark background (hip as that may be) are so painful to look at I
>get retina burn before I can finish all that clicking.
>
>About the log entry. I have a rule of thumb. If someone is using the
>words "shit" or "fuck" three or four times on page, they quickly lose
>all credibility. (Certain words should be treated like global
>variables: saved for special cases and for specific effect.)

Ah, yes. I forgot to append a disclaimer about the language.

>I like reading critiques (or criticism, even) of Ruby, but most of what
>was mentioned there were straw man arguments. Certainly POLS is a known
>subjective aspect and an easy target. I expect everyone reading
>ruby-talk could assemble a list of cases where Ruby violates their own
>sense of POLS.

Sometimes it is good to know what the other people think is surprising;
not because it violates some imaginary principle but because it might
actually be a good idea to re-evaluate a given aspect to make it more
obvious.

>James Britt

Jim Freeze

unread,
May 26, 2005, 3:08:14 PM5/26/05
to
* Jay Levitt <jay+...@jay.fm> [2005-05-26 23:35:18 +0900]:

> > Besides that, he doesn't understand what POLS means. Since someone
>

> Nicely put. I suggest we start referring to the POMLS - Principle of
> Matz's Least Surprise. That way, if anyone ever debates it, you can pop
> in and say "I wasn't surprised at all," thus authoritatively refuting
> the argument!

I think if you read Matz' post carefully, you will see that he
is not the originator of POLS. So, I don't think he wants any
POLS attached to himself, even POMLS. This would be a repeat of
what happed with POLS.

Besides, if we drop the POLS thing, then we can spare the poor
misguided, uninformed (slack jawed, lazy eyed) individuals who
write long articles trying to sound intelligent and authoritate
on a subject that they know nothing about from making fools of
themselves.

--
Jim Freeze
Ruby: I can explain it to ya but I can't understand it fer ya.

It is best to keep your mouth shut and let others think you
an idiot than to open it and remove all doubt.


Glenn Parker

unread,
May 26, 2005, 4:11:24 PM5/26/05
to
Brian Schröder wrote:
> On 26/05/05, gsin...@gmail.com <gsin...@gmail.com> wrote:
>>ES wrote:
>>
>>>http://www.ericw.org/rants/showrant.psp?rant=ruby
>>
>>"It's 5.abs for absolute value, but Math.sqrt(5) for square root."
>>
>>Good point. That bugs me too. abs is a *function*, not logically a
>>method.
>
> Why not 5.sqrt instead.

Hmmm, prefix, postfix, or infix? Functional or object-oriented?
These are bottomless questions.

One justification for sqrt(5) would be that "sqrt", works on more than
one class of objects (Fixnum, Bignum, Rational, etc). So does "abs" for
that matter, and I'm not crazy about 5.abs. As a method, sqrt would
have to be defined in every applicable class, either with new code or as
an included module. This spreads the definition out, which complicates
maintainence.

Another reason is that the prefix style, sqrt(5), is somewhat closer to
the typical mathematical notation. I can't think of any unary
mathematical operations that are naturally postfix, unless you count
C++'s post-decrement and post-increment.

This is all just criticism of library design, which is very much a
matter of style and taste. The "standard" library could stand some
attention to smooth out these style bumps, possibly by allowing either
prefix or postfix styles whenever possible. Then questions of style
would be forwarded to the programmer.

--
Glenn Parker | glenn.parker-AT-comcast.net | <http://www.tetrafoil.com/>


why the lucky stiff

unread,
May 26, 2005, 4:25:05 PM5/26/05
to
Martin DeMello wrote:

> I'd say conceptually abs belongs with floor, ceil, round and truncate.

And where do you stand in regard to .succ?

_why


Joe Van Dyk

unread,
May 26, 2005, 4:26:39 PM5/26/05
to

I think the guy's point was "omg, they said everything was an object!
"hi".length == 2 and stuff! But not sqrt(5)! Like, omg you farking
farktards are farking dumb! So much for POLS!!!1"


Josh

unread,
May 26, 2005, 5:07:59 PM5/26/05
to
Joe Van Dyk <joev...@gmail.com> writes:

> I think the guy's point was "omg, they said everything was an
> object! "hi".length == 2 and stuff! But not sqrt(5)! Like,
> omg you farking farktards are farking dumb! So much for
> POLS!!!1"

Looks like a nice summary of his whole rant. ;)

johng

unread,
May 26, 2005, 8:10:51 PM5/26/05
to
|"It's 5.abs for absolute value, but Math.sqrt(5) for square root."
|
|Good point. That bugs me too. abs is a *function*, not logically a
|method.

> The definition of abs is not questionable; it returns self, negated
> when self is negative, for all numeric value. On the other hand,
> natural sqrt() may return float or integer, or something else. That's
> the reason for sqrt() being a function in Math module.

I may be missing something, but why does it matter what the return
type is?

What is wrong with always returning a float just like Math.sqrt does?

-alternatively, although I prefer the first option-

Why couldn't the implementation of sqrt "cast" the result to an
instance
of the current self's type? So, if you ask an integer to sqrt, you get
an
integer back?

Like I said, maybe I am missing something, but it seems that
sqrt is a verb applied to numbers.

John.

ES

unread,
May 26, 2005, 8:42:35 PM5/26/05
to

Well, essentially this is all that is required:

irb(main):018:0> class Fixnum
irb(main):019:1> def method_missing(sym, *args, &block)
irb(main):020:2> return Math.send sym, self, *args, &block
irb(main):021:2> end
irb(main):022:1> end
=> nil
irb(main):023:0> 100.sqrt
=> 10.0
irb(main):024:0>

It is obviously not very robust but it took about eight seconds
to implement.

>John.

Logan Capaldo

unread,
May 26, 2005, 10:44:18 PM5/26/05
to
On 5/26/05, Glenn Parker <glenn....@comcast.net> wrote:
[snip]

> Another reason is that the prefix style, sqrt(5), is somewhat closer to
> the typical mathematical notation. I can't think of any unary
> mathematical operations that are naturally postfix, unless you count
> C++'s post-decrement and post-increment.

Just to get offtopic, factorial is one.


Jim Weirich

unread,
May 26, 2005, 11:38:35 PM5/26/05
to
On Thursday 26 May 2005 04:11 pm, Glenn Parker wrote:
> I can't think of any unary
> mathematical operations that are naturally postfix,

Factorial !

> One justification for sqrt(5) would be that "sqrt", works on more than
> one class of objects (Fixnum, Bignum, Rational, etc).  So does "abs" for
> that matter, and I'm not crazy about 5.abs.  As a method, sqrt would
> have to be defined in every applicable class, either with new code or as
> an included module.  This spreads the definition out, which complicates
> maintainence.

Actually, I think you have this backwards. It would be much more convenient
to have sqrt as a member function in order to implement it differently in
different classes. Numeric could hold the standard definition, but if a
subclass needed to redefine it, it could do so with little effort.

Look at the code in complex.rb to see how it handles enhancing sqrt to handle
complex numbers:

alias sqrt! sqrt
# ...
def sqrt(z)
if Complex.generic?(z)
if z >= 0
sqrt!(z)
else
Complex(0,sqrt!(-z))
end
else
if z.image < 0
sqrt(z.conjugate).conjugate
else
r = z.abs
x = z.real
Complex( sqrt!((r+x)/2), sqrt!((r-x)/2) )
end
end
end

If sqrt were a member function, the generic test could be completely avoided.
Although the original sqrt would still have to be enhanced to handle negative
values, it would only have to test for < 0, rather than the rather fragile
test for Integer, Float and Rational.

--
-- Jim Weirich j...@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)


Martin DeMello

unread,
May 27, 2005, 2:07:12 AM5/27/05
to

succ is definitely a method rather than a function, IMO - I can't see
myself using it in a mathematical rather than a 'programming' context.

martin

Mark Hubbart

unread,
May 27, 2005, 3:07:56 AM5/27/05
to

Robert Klemme

unread,
May 27, 2005, 4:48:45 AM5/27/05
to
Glenn Parker wrote:
> Brian Schröder wrote:
>> On 26/05/05, gsin...@gmail.com <gsin...@gmail.com> wrote:
>>> ES wrote:
>>>
>>>> http://www.ericw.org/rants/showrant.psp?rant=ruby
>>>
>>> "It's 5.abs for absolute value, but Math.sqrt(5) for square root."
>>>
>>> Good point. That bugs me too. abs is a *function*, not logically a
>>> method.
>>
>> Why not 5.sqrt instead.

+1

> Hmmm, prefix, postfix, or infix? Functional or object-oriented?
> These are bottomless questions.
>
> One justification for sqrt(5) would be that "sqrt", works on more than
> one class of objects (Fixnum, Bignum, Rational, etc). So does "abs"
> for that matter, and I'm not crazy about 5.abs. As a method, sqrt
> would have to be defined in every applicable class, either with new
> code or as an included module. This spreads the definition out,
> which complicates maintainence.

This is not true, for two reasons:

First, there is indeed a place to put functions that have the same
implementation for all numeric types - so it does not have to spread:

>> Fixnum.ancestors
=> [Fixnum, Integer, Precision, Numeric, Comparable, Object, Kernel]
>> Bignum.ancestors
=> [Bignum, Integer, Precision, Numeric, Comparable, Object, Kernel]
>> Float.ancestors
=> [Float, Precision, Numeric, Comparable, Object, Kernel]

>> ObjectSpace.each_object(Class){|cl| p cl if cl.ancestors.include?
Numeric}
Bignum
Float
Fixnum
Integer
Numeric

Second, it's most likely that you actually *want* different
implementations for performance and optimization reasons (see the recently
discovered bug with exponentiation).

> Another reason is that the prefix style, sqrt(5), is somewhat closer
> to the typical mathematical notation. I can't think of any unary
> mathematical operations that are naturally postfix, unless you count
> C++'s post-decrement and post-increment.

Well, this can remain in place as a simple forward to not break
compatibility

def Math.sqrt(n) n.sqrt end

> This is all just criticism of library design, which is very much a
> matter of style and taste. The "standard" library could stand some
> attention to smooth out these style bumps, possibly by allowing either
> prefix or postfix styles whenever possible. Then questions of style
> would be forwarded to the programmer.

True.

Kind regards

robert

Gene Tani

unread,
May 27, 2005, 6:32:59 AM5/27/05
to
The rant-writer likes ruby. From his python rant:
===========8<
Though, I must admit, Python has the least inconsistencies of any
language I've ever used, excepting maybe Ruby.

Glenn Parker

unread,
May 27, 2005, 9:13:44 AM5/27/05
to

Touché!

itsme213

unread,
May 27, 2005, 10:57:09 AM5/27/05
to
Method vs. non-method
should be totally orthogonal to
postfix vs. prefix vs. infix.

It is too bad that the two decisions are coupled.

"Logan Capaldo" <loganc...@gmail.com> wrote in message
news:4521f66805052...@mail.gmail.com...

Glenn Parker

unread,
May 27, 2005, 11:54:59 AM5/27/05
to
Jim Weirich wrote:
> On Thursday 26 May 2005 04:11 pm, Glenn Parker wrote:
>>I can't think of any unary
>>mathematical operations that are naturally postfix,
>
> Factorial !

Indeed, but this may be the exception that proves the rule.

>>One justification for sqrt(5) would be that "sqrt", works on more than
>>one class of objects (Fixnum, Bignum, Rational, etc). So does "abs" for
>>that matter, and I'm not crazy about 5.abs. As a method, sqrt would
>>have to be defined in every applicable class, either with new code or as
>>an included module. This spreads the definition out, which complicates
>>maintainence.
>
> Actually, I think you have this backwards. It would be much more convenient
> to have sqrt as a member function in order to implement it differently in
> different classes. Numeric could hold the standard definition, but if a
> subclass needed to redefine it, it could do so with little effort.

There is no backwards or forwards here.

The world is full of code and data, and we prefer languages that give us
flexibility in how we choose to organize these things. There are always
conflicting goals that we, as designers, must reconcile one way or
another. The main conflict I see is the beauty/elegance/clarity of a
library's internal organization versus the beauty/elegance/clarity of
the code where that library is used. I tend to favor the latter, on the
theory that consumers normally shouldn't have to care too much about the
internals, but it's a tug-of-war.

Jim Weirich

unread,
May 27, 2005, 12:43:54 PM5/27/05
to

Glenn Parker said:
> There is no backwards or forwards here.

As long as we are only talking asthetics, then I agree that either choice
is co-equal, neither is backwards or forwards. In fact, I would tend to
agree that sqrt(n) is more asthetically pleasing than n.sqrt.

However ...

But if we are talking maintenance (cf. "[sqrt as a method] spreads the
definition out, which complicates maintainence"), then I think it is clear
that the method implementation is (1) no more "spread out" that the
current implementation, (2) simpler to extend to for new types (e.g.
Complex). It is the stand-alone function (not method) implementation that
complicates maintainence. That is the part I thought was backwards.

Jonas Hartmann

unread,
May 27, 2005, 2:25:48 PM5/27/05
to

actually he seems to like both languages cause in the ruby rant he
refers to python and in the python rant he refers to ruby.

his choice of language is bad, some examples are stupid, and even me,
being quite a newbish, wonders why he rants about that, but some
examples are really good.

btw. isnt there a way to extend integer, fixnum and bignum with .sqrt ?

(just adding the method .sqrt arg, that again runs the sqrt method
which is possibly part of Kernel or Object, I am just guessing - is
that right?)

greetings

Jonas


Jonas Hartmann

unread,
May 27, 2005, 2:30:51 PM5/27/05
to
Jim Weirich wrote:
> Glenn Parker said:
>
>>There is no backwards or forwards here.
>
>
> As long as we are only talking asthetics, then I agree that either choice
> is co-equal, neither is backwards or forwards. In fact, I would tend to
> agree that sqrt(n) is more asthetically pleasing than n.sqrt.
oh no! its not at all!

n is an Integer object and sqrt is a method on that object so it must
be n.sqrt - you could as well implement the third square root of 8 by
typing 8.sqrt 3 (I am not such a big math-guy... so maybe you could
just send over the whole exponent - 8^(1/2) => 8.sqrt is equal to
8.sqrt .5 is equal to 8.sqrt(0.5) is equal to 8.sqrt(1/2) and so on...
well just my ideas on sqrt method - exuse me if its bs ;-(

Jonas Hartmann

unread,
May 27, 2005, 2:32:45 PM5/27/05
to
Florian Frank wrote:

> gsin...@gmail.com wrote:
>
>> Good point. That bugs me too. abs is a *function*, not logically a
>> method.
>>
>>
> What about 5.-@ ?

what should that do?

5 substract at?

(I read some parts of Why's and I cannot read out your example to get
what it does...)

Florian Frank

unread,
May 27, 2005, 2:40:30 PM5/27/05
to
Jonas Hartmann wrote:

> what should that do?
>
> 5 substract at?

The same as:

5.__send__ :-@

(no, really!) or

-5

--
Florian Frank

ES

unread,
May 27, 2005, 2:42:48 PM5/27/05
to

Yes, I already posted this. Something like this is all
that is needed (untested):

# Slightly more robust
class Numeric
alias_method :_old_mm, :method_missing

def method_missing(symbol, *args, &block)
Math.send symbol, self, *args, &block

rescue NoMethodError
_old_mm symbol, *args, &block
end # method_missing
end # Numeric

>greetings
>
> Jonas

Christoph

unread,
May 27, 2005, 2:53:39 PM5/27/05
to
Glenn Parker schrieb:

>
> Another reason is that the prefix style, sqrt(5), is somewhat closer
> to the typical mathematical notation. I can't think of any unary
> mathematical operations that are naturally postfix, unless you count
> C++'s post-decrement and post-increment.

Pretty much all non alphabetical unitary operators are typically
used in postfix notation (at least if "upper and lower postfix"
counts as post fix too) and the usage of these operators is
actually quite common in some specialized areas of math.


/Christoph


Jason Foreman

unread,
May 27, 2005, 4:14:50 PM5/27/05
to
On 5/27/05, Jonas Hartmann <Ma...@jonas-hartmann.com> wrote:
> [...]

> n is an Integer object and sqrt is a method on that object so it must
> be n.sqrt - you could as well implement the third square root of 8 by
> typing 8.sqrt 3 (I am not such a big math-guy... so maybe you could
> just send over the whole exponent - 8^(1/2) => 8.sqrt is equal to
> 8.sqrt .5 is equal to 8.sqrt(0.5) is equal to 8.sqrt(1/2) and so on...
> well just my ideas on sqrt method - exuse me if its bs ;-(

I assume by "third square root" that you mean cube root? To me, third
square root would mean sqrt(sqrt(sqrt(8))).

I think you'd want something like 8.root(3), not 8.sqrt(3). Square
root has a very precise meaning.

Also beware, 1/2 == 0 because of integer math.

</offtopic>


The article does raise some interesting questions, but certainly lends
itself no credibility due to the presentation. And I'm certainly not
going to become a 'Pythonista' due to this kids rant. You can easily
pick a few elements of any language and pick on them to your hearts
content, but it really just comes down to getting things done, and
Ruby does that for me.


Jason


furu...@ccsr.u-tokyo.ac.jp

unread,
May 27, 2005, 11:44:53 PM5/27/05
to
> First, an OT question: Is there a Firefox extension that lets me
> *quickly* disable/enable page colors?

Use Opera! :-) Shift+G toggles between the user and author modes.
Really handy. I switch to the author mode only when page colors
matter.

No offense intended, but Opera is far more feature-rich, (yet the
features
are hidden until you explicitly unleash them), a bit lighter (less than
4 MB including flash and friends), a bit snappier (may depend on you
environment), etc. What's the catch? Nothing, except for the small
add
which is displayed if you don't pay (about US$40).

Sorry I couldn't resist to the chance of advocacy. :-)
I'm simpy a fan of Opera; I have nothing to do with the company,
by the way.

Cheers,
Ryo

Linus Sellberg

unread,
May 28, 2005, 6:51:15 AM5/28/05
to
On 5/28/05, furu...@ccsr.u-tokyo.ac.jp <furu...@ccsr.u-tokyo.ac.jp> wrote:
> > First, an OT question: Is there a Firefox extension that lets me
> > *quickly* disable/enable page colors?
> Use Opera! :-) Shift+G toggles between the user and author modes.

Or be lazy and install the prefbar plugin. Has a lot of other nice
features like being able to turn on and off showing images,
animations, javascript, flash, popups etc.


James Britt

unread,
May 28, 2005, 8:36:54 AM5/28/05
to

A few people recommended "Bookmarklets for Zapping Annoyances"

http://www.squarefree.com/bookmarklets/zap.html

which works quite well for me (and thanks to those who responded).


James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys


Jon A. Lambert

unread,
May 29, 2005, 9:39:45 PM5/29/05
to
Andrew Walrond wrote:
> Despite the fucking swearing, he did come up with a list of almost
> everything that has confused or annoyed me since I started using ruby.
>

I thought so. Specifically I think he nailed some things which aren't
language artifacts that one has to accept.

You can't tell what raises what.
Half the socket routines return bullshit.
The threading model is about as useful as slamming your dick in a vise.

These are all horribly designed and can be fixed.

--
J Lambert

Mark Hubbart

unread,
May 30, 2005, 2:38:39 AM5/30/05
to
On 5/27/05, Jim Weirich <j...@weirichhouse.org> wrote:
>
> Glenn Parker said:
> > There is no backwards or forwards here.
>
> As long as we are only talking asthetics, then I agree that either choice
> is co-equal, neither is backwards or forwards. In fact, I would tend to
> agree that sqrt(n) is more asthetically pleasing than n.sqrt.
>
> However ...
>
> But if we are talking maintenance (cf. "[sqrt as a method] spreads the
> definition out, which complicates maintainence"), then I think it is clear
> that the method implementation is (1) no more "spread out" that the
> current implementation, (2) simpler to extend to for new types (e.g.
> Complex). It is the stand-alone function (not method) implementation that
> complicates maintainence. That is the part I thought was backwards.

'mathn' tries to patch the sqrt functionality, but doesn't get it
completely. look at the inconsistencies in the following examples,
remembering that precisely, sqrt(-1) should yield Complex(0,1) (aka:
"i"), and sqrt(n) is exactly the same as n**(1/2):

require 'mathn'
==>true
Math.sqrt(-1)
==>Complex(0, 1)
(-1)**(1/2)
==>Complex(6.12323399573677e-17, 1.0)
(-1)**0.5
==>NaN
Math.sqrt(-1.0)
==>Complex(0, 1.0)
(-1.0)**(1/2)
==>NaN
(-1.0)**(0.5)
==>NaN

These all should have given either Complex(0, 1) or Complex(0, 1.0).
The one with the tiny float value could be given an "A" for effort,
perhaps, but NaN? Really, now.

If sqrt was added as a method, it could be defined as self ** 0.5, and
I imagine it would be much easier to keep everything in sync.
Requiring 'mathn' would change that to self ** (1/2), and then
override **() to handle rationals.

just my 2¢,
Mark


0 new messages