Ruby Document

Hi all in this discussion,

My comments on the document of Ruby is actually an abreaction of my unsatisfaction toward C++.
In my mind, a good language should have 2 features:

  1. Easy to use and highly efficient programming (such as ruby)
  2. Easy to learn and hard to forget even you don’t use it for a long time (such as C and Pascal,
    but not C++ and delphi).

I learned C++ in 1993, I thought I can programming using the language. But I was wrong. During these
years, C++ is changing rapidly, and become more and more incomprehensible. I think a good language
will depend on it’s internal mechanism, not on some piculiar “syntax sugar”.
For example, C++ introduced the use of template, which seems very
interesting and efficient, but it required me to learn the new syntax of
how to use template. As a contract, Ruby’s polymophism achieved the same
effect, and more elligently. So Ruby is better on this comparison.

I hate piculiar symbols to express some obvious meanings. for example:

in C++ ~ means destructor. While in delphi, there’s a keyword
"destructor", which is much clearer. A lot of my example are anti-C++…

And in ruby, attr_reader :name, and def name… end, while in Delphi, it
is “property name”. Again delphi is easier to comprehend, and hence
harder to forget. Of course, when you know the meaning of attr_reader it
is as simple as “property”, but for beginer, like me, who knows oop, but
new to ruby, it doesn’t make sense at the beginning.

Regards,
Shannon

“Shannon Fang” xrfang@hotmail.com wrote in message
news:20021130202456.EFB2.XRFANG@hotmail.com

Hi all in this discussion,

My comments on the document of Ruby is actually an abreaction of my
unsatisfaction toward C++.

Please follow the D project at news.digitalmars.com, it has many of the
things we would like in C and C++ instead of what we have. D is not just
another D language, Walter behind D wrote the legendary Zortech compiler. I
expect a lot from D, but currently it is in an early stage of development.

I learned C++ in 1993, I thought I can programming using the language. But
I was wrong. During these
years,
I learned it a few years earlier. I used to follow the evolving standard
closely and did eargerly dive into the cool templates that first got
introduced in Borland C++.

C++ is changing rapidly, and become more and more incomprehensible.

I eventually gave up on understanding C++ - I feel I have a fairly good C++
knowledge, but I can’t be bothered with the latest development in
templates - no matter what you do it is either not implemented, implemented
partially, implemented incorrectly and certainly not portable between
compiler vendors or even between compiler versions in either direction. Then
add stupid scope incompatibilities such as for(int x;—) where is the scope
of x?.
A recall a FidoNet argument on constructor behavior back in the mid 90’ties.
Turns out calling a constructor inside a constructor results in a) a new
temporary object, b) recursion, depending on your compiler (VC vs. Borland).
It’s just inherently difficult to make a precise definition of C++,
apparently much like HTML.

will depend on it’s internal mechanism, not on some piculiar “syntax
sugar”.
For example, C++ introduced the use of template, which seems very
interesting and efficient, but it required me to learn the new syntax of
how to use template. As a contract, Ruby’s polymophism achieved the same
effect, and more elligently. So Ruby is better on this comparison.

But Ruby isn’t an easy language - I thought so initially - there are many
complex aspects, most adds to the power of the language, while other
behavior happened in the course of development (which is why we always
invent new languages).

I hate piculiar symbols to express some obvious meanings. for example:

in C++ ~ means destructor. While in delphi, there’s a keyword
“destructor”, which is much clearer. A lot of my example are anti-C++…

Doesn’t really matter. What matters is features such as using class name as
constructor versus using the self keyword as constructor. Which code is the
easier to maintain, or to manage with macros if you want to make it ugly?
This is one thing fixed in D. Whether you use ~self or destructor amounts to
the same thing. I agree destructor is nicer, but things can also be too
verbose, and as I said, this aspect hardly matters.

And in ruby, attr_reader :name, and def name… end, while in Delphi, it
is “property name”. Again delphi is easier to comprehend, and hence
harder to forget.

Yes, I also find it putting tolls on my limited onboard RAM capacity (it’s R
as in Random) - which is why I hooked up with computers in the first place.
However, attr_ has a wider scope than just properties - if only I could
figure out exactly how it works.

Mikkel

Shannon,

Note that:

class Foo
attr_reader :bar
end

is only the same as:

Type Foo = Class
Property bar: Variant Read getBar;
End;

For a read/write “property”, you need:

class Foo
attr_accessor :bar
end

Both attr_reader and attr_accessor are methods which produce syntax
sugar. It is no different than doing:

class Foo
def bar; @bar; end
def bar=(b); @bar = b; end
end

Considering the attr_* methods to be the same as Property values in
Delphi (or C#) is, IMO, a mistake.

-austin
– Austin Ziegler, austin@halostatue.ca on 2002.12.01 at 09.34.18

···

On Sun, 1 Dec 2002 05:27:58 +0900, Shannon Fang wrote:

And in ruby, attr_reader :name, and def name… end, while in
Delphi, it is “property name”. Again delphi is easier to
comprehend, and hence harder to forget. Of course, when you know
the meaning of attr_reader it is as simple as “property”, but for
beginer, like me, who knows oop, but new to ruby, it doesn’t make
sense at the beginning.

Hi Austin,

Considering the attr_* methods to be the same as Property values in
Delphi (or C#) is, IMO, a mistake.

I understand that I am only a user of the language, I may not know the
detail of it. My way of understanding attr_reader as property in delphi
is only very superficial “surface level”. i.e., I only concern what it
does for me, not what it did underneath the code…

Correct me if I’m wrong. Tks.

Thanks
Shannon

···

On Sun, 1 Dec 2002 23:41:29 +0900 Austin Ziegler austin@halostatue.ca wrote: