Some help against the raging hordes of 'J' fanatics

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-less-is-more/

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.rubyrailways.com

On Wed, 25 Oct 2006, Peter S. 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?

Why do you need to do this? If they choose another language over
Ruby, no-one is harmed by that. People will learn it if there is
a compelling reason for them to do so, but they must see it as
compelling, themselves. Many have seen Rails as such a reason.

When choosing a programming language one also needs to know about
available libraries, platforms, experience of others in the team,
whether support contracts are needed, and lots more. Sometimes
something else is the right answer.

    Hugh

Peter S. 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 B.

“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

James B. wrote:

Peter S. 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.

Peter S. 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.

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-less-is-more/

I read it but was turned off by what I saw as technical errors.

  • neither the empty Java program nor the empty Ruby program does
    ‘literally nothing’.

  • it loudly states that it is only covering ‘features of the
    language’ and not libraries, but requires ActiveSupport for half
    of the examples.

  • attr_accessor is not that big of a deal. even C programmers can
    do something very similar.

  • there is a disclaimer that it’s not language bashing, but the tone
    clearly comes across to me as language bashing.

I understand where you’re trying to go–and agreed with you before you
even started!–but I’m not getting there from the text. I read your
section on arrays for example and think to myself ‘yeah, Ruby has
dynamic lists, like Perl, Python, Lisp …’.

I have almost no knowledge of Java idioms, so I can’t help there. The
guy who is claiming you can do everything with reflection sounds like
he’s on to something, but I have some doubt that anyone is really
using “byte code enhancement” instead of typing 2 method definitions.
Gratuitous use of reflection in Java strikes me as code smell.

Steve

Peter S. 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-less-is-more/

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 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 V.
Your Unfriendly Neighborhood 'J’ava Fanatic

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.rubyrailways.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs