Peter (having a bad day) Hickman wrote:
Not really, when someone new comes to ruby they always ask for features
from the language they know best. The common theme is that all these
requests come from ‘I am an X programmer’, where X is the one and only
language they understand
Given that one of Ruby’s main inspirations is Perl (another
being SmallTalk, obviously), and that Perl has, ahm, “borrowed”
liberally from many other languages, it’s not automatically
unreasonable to add more borrowings to Ruby. Each request should be
considered on its own merits, not dismissed on the basis that the
requestor is “obviously” only trying to make Ruby more Xlike where
X is whatever language they are coming from.
And even if they are looking for Xicity, that doesn’t mean X is the
one and only language they understand; it’s probably the language
that they wound up using because it’s the one they liked the best.
Now they’ve decided they like Ruby better but they would still like
to bring along some of the things that attracted them to language
X in the first place. That doesn’t seem unreasonable to me.
The call for pre/post increment/decrement operators is pretty frequent.
Well, that’s because they’re useful. I mean, sure, x += 1
works everywhere that ++x would, but if what you really want is
x++ then you have to break it up into two statements. Not that
there’s anything wrong with that; I’m all for legible code. But 30
years after C pushed these operators into the realm of widely-used
high-level programming languages, every programmer on the planet
should be able to understand them instantly; and when you can get
clarity and concision at the same time, that’s the way to go.
We’ve had VB programmers ask for ‘on error gosub’ because they had a
blind spot for exceptions.
Okay, well, VB programmers don’t count.
We’ve had Java/C++/Whatever programmers ask for type checking, operator
overloading, polymorphism and a whole host of compile time checking.
That would be a more fundamental change, obviously; Ruby is just not a
strongly-typed language. See Perl prototypes for an example of what happens
when you try to graft on a compromise. I mean, they’re potentially useful
and have a fair amount of power, but they’re rarely used, and when they
are it’s usually just to eliminate the need for extra parentheses
and/or backslashes in the calling code.
Now, as an O-O language Ruby automatically supports some forms
of polymorphism. And I do think it would occasionally result in
clearer code if we could define multiple methods with the same name
distinguished by number of arguments, rather than manually checking
and dispatching within a single method, but that’s a minor quibble.
Lisp programmers have enquired about macros (occasionally).
Metaprogramming in general is quite useful, though ripe for
abuse; see the recent discoveries about C++ templates. (“Hi, I can make
your compiler run arbitrary code at compile time! You don’t even have
to run my code to get infected by my virus, just try to compile it!
Ha! Ha ha ha! Mwa ha ha ha ha ha hah!”)
We’ve had programmers who wanted ‘initialize’ changed to ‘new’ so that
they would have less to type.
Again, I’m all for concision (even though I know that it’s not
a real word), wherever it doesn’t impede clarity. In this case
it would even enhance it - you call MyClass.new and that results
in MyClass#new being executed. Not only less typing, but also
a more logical connection, easier to remember, and no conflicts
since class methods and instance methods have separate namespaces.
Sorry, why is this a bad idea again?
And we’ve had tcl/php programmers who wanted elseif rather then elsif
(or was that the other way round).
You can’t make everyone happy with your spelling choices, to be sure.
Ruby uses “elsif” because Perl uses “elsif”, and Perl uses “elsif”
because it was more aesthetically pleasing to Larry Wall. Besides,
almost every time you add a suffix to an English word ending in a silent
‘e’, the ‘e’ is dropped first.
I wouldn’t object to the introduction of “elseif” as a
synonym, just to cut down on typos when people are switching back
and forth between languages. But not “elif”. Have to draw the
line somewhere.
-Mark