Kudos to all Ruby creators/enhancers/users

I can't stop myself from using 15 minutes of my work time to express my
gratitude to Matz and everyone else involved with the creation,
enhancement, and use of Ruby. This comes from a 20 yr procedural
programmer raised on Basic, Assembler, Cobol, SAS, etc... I've been
learning Ruby for the past year, singing its praises to all around me.
And my employer, having such value of my opinion, has decided to
encourage me to learn C#, as it is the standard (from his point of
view.)

C#, in my opinion, is garbage trying to smell sweet. Especially in the
area of arrays. And here is where I solicit from you your best C#
practice to emulate Ruby. It's a simple matter of how big an array is.
In Ruby, I elegantly add member to an array using "a << 'something'."
It knows how many elements there are simply by adding. When I want to
use the elements, I elegantly code "a.each{|x| whatever}".

Now, in C#, I have to declare the array of a specific type. I have to
provide a size, x. I then have to brute force assign an element to a
specific index. And if I want to use the elements of the array, I use
a foreach statement. And because it is a statement, I have to declare
the type of receiving variable because foreach doesn't know the type of
array. And when foreach executes, it is for every element up to x, not
the number of populated elements.

Is there and elegant way in C# to append members into an array, and
execute foreach for each populated member? Or do I have to code my own
extensions to class array such that it acts like Ruby? Has someone
already done this in C#?

Once again, I can't express my appreciation enough. I'm thinking of
learning C# for my company, but still implement everything in Ruby
anyway. Hell, I can prototype production ready code in Ruby so much
faster than I can translate it to C#.

Thanks a bunch,
dvn

dvn

Look at ArrayList. I think C# is the best of the RAD GUI languages,
but I still wish every day that I could open up a studio of some type,
drag some buttons around, double-click on one of them and enter Ruby
code.

Then I could probably throw away C# and just use Ruby for 99% of my work.

Les

···

On 11/9/06, donn@cmscms.com <donn@cmscms.com> wrote:

Is there and elegant way in C# to append members into an array, and
execute foreach for each populated member? Or do I have to code my own
extensions to class array such that it acts like Ruby? Has someone
already done this in C#?

--
Man's unfailing capacity to believe what he prefers to be true rather
than what the evidence shows to be likely and possible has always
astounded me. We long for a caring Universe which will save us from
our childish mistakes, and in the face of mountains of evidence to the
contrary we will pin all our hopes on the slimmest of doubts. God has
not been proven not to exist, therefore he must exist.

- Prokhor Zakharov

donn@cmscms.com wrote:

C#, in my opinion, is garbage trying to smell sweet. Especially in the
area of arrays. And here is where I solicit from you your best C#
practice to emulate Ruby. It's a simple matter of how big an array is.
In Ruby, I elegantly add member to an array using "a << 'something'."
It knows how many elements there are simply by adding. When I want to
use the elements, I elegantly code "a.each{|x| whatever}".

Ruby Array != C# array. Ruby Array = C# ArrayList. (Sort of.)

Now, in C#, I have to declare the array of a specific type. I have to
provide a size, x. I then have to brute force assign an element to a
specific index.

Made irrelevant by the above. Learn C# before criticising it.

And if I want to use the elements of the array, I use
a foreach statement. And because it is a statement, I have to declare
the type of receiving variable because foreach doesn't know the type of
array.

That has nothing to do with the fact it's a statement.

AFAIK, C# 3.0 will have type inference for local variables, so you won't
have to do that anymore.

And when foreach executes, it is for every element up to x, not
the number of populated elements.

That's the behaviour of ArrayList too. Ruby's Arrays compensate this
with the quirk that out-of-bounds access silently returns nil. (Although
I think there's a method with a stricter approach to this.

Is there and elegant way in C# to append members into an array, and
execute foreach for each populated member? Or do I have to code my own
extensions to class array such that it acts like Ruby? Has someone
already done this in C#?

Use. ArrayLists. Changing class array won't help anything, because
they're a first-class primitive datatype. Ruby doesn't have an
equivalent to them, because it uses C arrays as backing storage.

Also, C# 2.0 has lambdas. C# 3.0 will let you add methods to external
classes. I'd be very, very surprised if there isn't a library that can
do each/select/collect/inject for C# 3.0 already, unless .NET 3.0 adds
that in the framework itself. I don't follow happenings in dotnetland,
so I can't tell.

Once again, I can't express my appreciation enough. I'm thinking of
learning C# for my company, but still implement everything in Ruby
anyway. Hell, I can prototype production ready code in Ruby so much
faster than I can translate it to C#.

While Ruby fluffs are always welcome, accompanying them with an
ill-informed rant makes them taste so bitter. And if the ill-informed
rant is a flame at another programming language with a completely
different audience / area of application, their value approaches zero.

David Vallner

Just saw Qt4 with Ruby bindings... maybe the wait is over!

You can play with some of the array manipulation features you mentioned
downloading LINQ (Language Integrated Query). The upcoming version of
C#. (Microsoft Learn: Build skills that open doors in your career)
I`ve been programming with C# since 2000, but since I met Ruby, I wish
I could write every program in it.
It's by far, much more productive than C#. But there is a partial port
of Ruby to the .NET Platform called Ruby.CLR.
Lots of people says that with current implementation of the CLR would
be not possible to support such dynamic language, like Ruby.
But recently the Ruby.CLR project creator John
Lam(http://www.iunknow.com), was hired by Microsoft to integrate the
CLR Dynamic Team to help them improve the CLR Dynamic Support. There is
already a port of Python called IronPyhton to .NET world.

HTH

Felipe Garcia

···

On Nov 9, 12:36 pm, "Leslie Viljoen" <leslievilj...@gmail.com> wrote:

Just saw Qt4 with Ruby bindings... maybe the wait is over!

Leslie Viljoen wrote:

Just saw Qt4 with Ruby bindings... maybe the wait is over!

No win32 maintainers. WOE.

David Vallner

rhossi wrote:

You can play with some of the array manipulation features you mentioned
downloading LINQ (Language Integrated Query).

LINQ is an abomination, and a marketing scam to make Transact SQL coders
switch over. It's horrid abuse of a relational programming language to
handle object-oriented data, and will at best only lead to wider
adoption of the "let's transfer all data from the DB in-process and
handle them there" school of thought. Lambdas and method calls feel just
so very much cleaner in OO code, the SQL-ish syntax looks out of place
and mostly clutters things. And you shouldn't do joins on OO data anyway
because those things will kill your performance unless optimised, which
DBs tend to do better (since the query engine monitors data on input and
can prepare for queries, unlike LINQ which has to work with arbitrary
structures.)

End completely unrelated rant.

David Vallner