[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Some help against the raging hordes of 'J' fanatics

Peter Szinek

10/24/2006 5:58:00 PM

Hello,

Maybe some of you already came across my latest blog entry - it's about
the comparison of a few Ruby vs Java idioms. Basically I wrote it
because I just learning Ruby and I was astonished by it's power, and
well, I just blogged about a few tasks I solved recently. It can be
found here:

http://www.rubyra.../sometimes-les...

Of course I have thought some Java guys will be pissed off by it, but I
sat back and laughed at them. However the last bit was this comment:

I set up a tree in Ruby with this code (method_missing behind of course)

tree = a {
b { d e }
c { f g h }
}

And somebody said this is crap and can be done much nicely in Java. He
also provides some kind of code...

Arghhh... This is now really... How to say...

As 98% of the comments is like 'yeah Ruby is maybe cool, but Java is
about equal or better' and there is not even one real Ruby answer, I
would like to challange some members to add some Ruby spice to the
thing, too. I think the Ruby community is also cool enough to argue a
bit about this, on Ruby's behalf...
What do you say?

__
Peter
http://www.rubyra...

6 Answers

Hugh Sasse

10/24/2006 8:01:00 PM

0

James Britt

10/24/2006 8:12:00 PM

0

Peter Szinek wrote:

> I think the Ruby community is also cool enough to argue a
> bit about this, on Ruby's behalf...
> What do you say?
>


I say that the Ruby community is cool enough not to argue about this.



--
James Britt

"I must create a system, or be enslaved by another man's;
I will not reason and compare; my business is to create."
- William Blake

Tim Hunter

10/24/2006 8:32:00 PM

0

James Britt wrote:
> Peter Szinek wrote:
>
>> I think the Ruby community is also cool enough to argue a
>> bit about this, on Ruby's behalf...
>> What do you say?
>>
>
>
> I say that the Ruby community is cool enough not to argue about this.
>
Yes, yes, yes, yes, yes, yes, yes, yes, yes. Please let us be forever
free of the need to argue about "my language is better than yours." Then
we can spend all that energy on helping each other.

Phlip

10/24/2006 8:38:00 PM

0

Peter Szinek wrote:

> As 98% of the comments is like 'yeah Ruby is maybe cool, but Java is
> about equal or better' and there is not even one real Ruby answer, I
> would like to challange some members to add some Ruby spice to the
> thing, too. I think the Ruby community is also cool enough to argue a
> bit about this, on Ruby's behalf...
> What do you say?

There is no honor in preying on the weak.

--
Lt. Worf
http://www.greencheese.u... <-- NOT a blog!!!


David Vallner

10/25/2006 1:59:00 AM

0

Peter Szinek wrote:
> Hello,
>
> Maybe some of you already came across my latest blog entry - it's about
> the comparison of a few Ruby vs Java idioms. Basically I wrote it
> because I just learning Ruby and I was astonished by it's power, and
> well, I just blogged about a few tasks I solved recently. It can be
> found here:
>
> http://www.rubyrailways.com/sometimes-les...
>

The post is such blatant trollbait I won't even bother. Anecdote * 10 !=
evidence.

Then again, I have a reputation of a troll to keep, so here goes. (For
my defense, I only troll back.)

I'll try to touch on some points your commenters missed.

Ruby lets you write less code because the language is much, much, much
larger. The Java policy is to defer non-basic things to tools so you can
mix and match approaches. With some notable exceptions around singleton
classes which aren't possible with Java's object model, but I find those
somewhat of a hack, basically they seem to classes like lambdas are to
named functions. Fun for one-off throwaway code, annoying to find bugs
in if non-trivial, and you could as well make a generic object
parameterised by a lambda or two to replace them without too much of a
kludge (this pattern can also be implemented in Java-like object models
with varying larger amounts of kludge). There's also the varying design
principles where on one side, you try and keep a clean (-ish) separation
between the language and its artifacts (the libraries), and on the other
you blur the boundaries of those. Understanding the latter completely is
a much larger learning curve, even if the early "oh, wow, neato-whiz
shorthand" shiny objects dangled in front of your nose hide that fact.

A lot of the examples you show are using dynamic code generation of
sorts, which would require either XDoclet or load-time bytecode
enhancement in Java to implement. Believe or not, that extra step is a
virtue in circumstances. Dynamic code generation is basically Dark Magic
(to wit: the umptillion metaprogramming threads that have people
groaning over one gotcha or another), it requires more skill from a
programmer to both write and read again. And while you might yet
blissfully ignore the fact that the real world needs programs that are
a) maintainable, and that b) by muppets, I find it a very hard fact. No
matter how god damn smug you are, if your code will have to be
understood by a student coder, there is no place for metaprogramming
unless it's damn well contained, tagged with big red neon signs saying
"This works, do not touch".

Summarising: just because you can't see a point to verbosity doesn't
mean there is never none. Well, except for declaring types of locals,
inference of those is on my personal Java 7 wishlist. (As optional
syntactic-sugar for type checks / DbC and a standard library that plays
along nicely with that is on the Ruby 2 one).

PS: Noone gives a flying *bleep* about attr_accessor or public static
void main, that's what IDEs or editor templates are for. I can
IDE-generate default member accessors in (four) less keystrokes than
typing "attr_accessor" takes. (Alt+Ins Down Down Down Enter Shift-End
Enter. From memory.) Which is a non-argument too, but I'll leave it as
an exercise to the reader to spot it. If you're too cheap for IDEA and
hardware to run it, sux2bu.

PPS: The comparing Java arrays to Ruby arrays because you can't
initialize lists in one statement is braindead beyond all belief. Redo
from scratch. HINT:
List<String> strings = Arrays.asList(new String[] {"bing", "cabbage",
"womble"});
By the way, a Stack is a List, and a List is an array for any purpose
you might need (the List contract is an extension of the array one).

Now, can I PLEASE have the constructive Ruby community that didn't give
a damn about any other programming languages either from a year ago or
so back? I feel faintly disturbed by how much noise various programming
language expatriate whiners are able to generate.

I also object to the overgeneralising blanket fanatic descriptor. You
start with a shallow troll and then call people that defend against it
fanatics? Sad.

David Vallner
Your Unfriendly Neighborhood 'J'ava Fanatic

Peter Szinek

10/25/2006 8:29:00 AM

0

Hi all,

Thanks for the comments. The outcome was quite different from what I
have been expecting :-), but anyway your suggestions were (mostly)
eye-opening and helpful in many ways.

Cheers,

__
Peter
http://www.rubyra...