A r t i c l e s
Navigation

Note: This Wiki is
outdated, personal views
may have changed.
L505 A.I. bot is dead
long live THX 1138

M a i n P a g e

D i r e c t o r y

Is Ruby 457 Ways To Do The Same Thing


In ruby there are ridiculous amounts of duplication.. for example:
  if (x == 5) and (y == 6)
  if (x == 5) && (y == 6)
Or there is:
  if (x == 5) or (y == 6)
  if (x == 5) || (y == 6)
Why confuse people with many hundreds of ways of doing the same thing? Why let people choose '&&' in addition to 'and'? How does this help make a programmer's job much easier and more clear and consistent?

When we want to do something different, it doesn't look much different:

  if (x == 5) | (y == 6)
And this?
  if (x == 5) & (y == 6)
The "|" and "&" are different than "||" "&&" you're thinking. Yes, good for you... but what about AND/OR keywords? Is AND the same as "&" or is it the same as &&? I know the answer.. but it is still silly to have ALL OF THESE available. It is code that is needlessly confusing.. whether or not the person reading the code is an expert that remembers every part of the language (no programmer constantly remembers every part of a language, which is why languages must be simple and non-duplicative).

Or maybe we should add a new feature to ruby if it doesn't exist (probably does!)

  if (x == 5) |||| (y == 6)
And we should add this feature too, if it doesn't exist (probably does!):
  if (x == 5) &&&& (y == 6)

Not, or Not?

This:
  if not (x == 5) 
And this too?
  if !(x == 5) 
Why both? To be hip and cool, or?

For the sake of it!

Let's confuse people, and add terse gimmicks to the language so people have to screw around referencing back to their 5421 page ruby syntax dictionary instead of getting work done.
   x ||= "default" # value of x replaced with "default" only if x is nil or false
   x ||= "other"  # value of x not replaced if already not nil or false
For christmas sake! We should add comments beside those terse gimmicks so that other people reading our code will know what is going on. But then, if we add comments beside these gimmicks, no longer are the gimmicks terse.. the gimmicks become verbose comment scams that we have to explain to make sure the programmer knows what is happening. The comments take up more screen space than just not using the gimmick in the first place and writing proper readable code.

Why would someone deliberately want to confuse a programmer?

Do you want your head cut off, or do you want your head cut off? Pick one! Surprise us. That's what smart programmers think when they get confused for no good reason. They think of giving the language designer two options.. two of the same options: die, or die.

Defying the laws of Logic

 x = "(some fallback value)" if x.nil?
What? Now we are adding IF LOGIC after the statement has already occurred? Just for the sake of being cool and hip, yee haw! Yee haw! That's cool, I'm gonna use ruby 'cause it has all these useless feature's n'stuff, and, like, it's so cool, like so much clearer and bass ackwards man.

70 different loops? or 7 million?

How about loops? I'm not even going to start with loops. There are 7 million different ways to do loops in ruby. I can't mention them here, it would take me about 5 years to explain 10 percent of them.

How does this help the typical programmer who needs to get work done? Instead of spending time learning new different loops that some other poor programmer has chosen to be cool, we should be using consistent syntax wherever possible.

Sharing code between developers requires everyone to be familiar with a language, and if the language let's us do the same thing a million different ways, this makes sharing code between developers a diarrhea storm. A language should not take 50 million pages to explain.

Question?

Why? Enough said.. just a different way of doing the same thing! Ruby's clever little question mark trick is a useless gimmick.
    if @something.nil?
      useless_gimmick
    end

If then, If then, If then

Sigh.

We have

  x == 5 and dosomething
And we have
  if x == 6 then dosomething end
And we have
  if x == 6; dosomething
And we have
  something if x== 6
And we have
  x == 5 ? something1 : something2
And we have
  if x == 5 
    puts 'test1'
    puts 'test2'
  end
And we have
  if x == 5 then
    puts 'test1'
    puts 'test2'
  end
And we have
  if x == 5;
    puts 'test1'
    puts 'test2'
  end
Oh, and there is more, I just haven't got the effing patience to go through all 543 million of them. Sorry.

Cleaner Perl with Modula Syntax

Ruby is not simple, it is very much like PERL. It is an aesthetically pleasing version of PERL. But it ain't like modula. Well, it is, a bit - it is actually an insult to modula. Ruby stole some syntax from modern pascal and modula. And ruby at least has modules, which was a good decision.. that's probably the best thing going for ruby. But by golly, it is a (needlessly) complicated language.
Dear Ruby Devel, please don't add features to a language that aren't features.
Is ruby so complex that no one can maintain what they create with it?

"Let me put this into perspective for you: Iíve ran servers that needed to be restarted once in a year. They were written in PHP, Python, Java, C, C++, you name it. Hell, Iíve got this blog on a server Iíve restarted maybe 10-20 times the whole year.

Now, DHH (creator of rails) tells me that heís got 400 restarts a day. Thatís 1 restart about ever 4 minutes" -- Zed Shaw

See also

Does-FPC-Have-Too-Many-Features

About
Note: This Wiki is outdated, personal views may have changed.

This wiki contains info on life, health, humans, nature, programming, database, fads, paradigms, poems, principles, theories.

Articles may contain statements which some may find helpful and encouraging, or even discouraging.

Beware, I believe in the Grand Justice system.
_ _ _