Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby type-safe? Ruby strongly/weakly typed? Ruby pitfalls?

Reply
Thread Tools

Ruby type-safe? Ruby strongly/weakly typed? Ruby pitfalls?

 
 
rule.rule.rule@gmail.com
Guest
Posts: n/a
 
      02-06-2008
Hi,

I added some paragraphs to the Ruby article on Wikipedia:

Type system
- Is Ruby type-safe?
- Is Ruby strongly typed?

Criticism
- Lack of variable declarations
- Dynamic typing
- Overloaded operators
- Reflective and meta-programming features

Some "peer review" appreciated

http://tinyurl.com/fpwes

Please feel free to improve upon it, or post comments in this thread.

Greetings,
 
Reply With Quote
 
 
 
 
Day
Guest
Posts: n/a
 
      02-06-2008
[Note: parts of this message were removed to make it a legal post.]

On Feb 5, 2008 7:20 PM, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)>
wrote:

> Criticism
> - Lack of variable declarations
> - Dynamic typing
> - Overloaded operators
> - Reflective and meta-programming features


I find this interesting. I would count all four of these as assets. If
nothing else, I think the Wikipedia article should present the GOOD side of,
say, dynamic typing and meta-programming features (Rails uses meta-stuff
heavily, no?). I don't want to get into more wikidebate, so I'll just say
that.


Ben

 
Reply With Quote
 
 
 
 
Eivind Eklund
Guest
Posts: n/a
 
      02-06-2008
On Feb 6, 2008 2:20 AM, (E-Mail Removed)
<(E-Mail Removed)> wrote:
> Hi,
>
> I added some paragraphs to the Ruby article on Wikipedia:
>
> Type system
> - Is Ruby type-safe?
> - Is Ruby strongly typed?


Def 8 seems to be wrong; you're looking at what a variable refers to,
rather than the object type. The object type is constant throughout
object lifetime in Ruby (excepting some hacks that I think are
C-based).

Eivind.

 
Reply With Quote
 
Frederick Cheung
Guest
Posts: n/a
 
      02-06-2008

On 6 Feb 2008, at 01:49, Day wrote:

> On Feb 5, 2008 7:20 PM, (E-Mail Removed) <(E-Mail Removed)
> >

> wrote:
>
>> Criticism
>> - Lack of variable declarations
>> - Dynamic typing
>> - Overloaded operators
>> - Reflective and meta-programming features

>
> I find this interesting. I would count all four of these as assets. If
> nothing else, I think the Wikipedia article should present the GOOD
> side of,
> say, dynamic typing and meta-programming features (Rails uses meta-
> stuff
> heavily, no?). I don't want to get into more wikidebate, so I'll
> just say
> that.


Same here. They make it a lot easier to create DSLs that in turn make
your code a lot more readable.

Fred

 
Reply With Quote
 
Curt Sampson
Guest
Posts: n/a
 
      02-07-2008
On 2008-02-06 15:56 +0900 (Wed), Eivind Eklund wrote:

> On Feb 6, 2008 2:20 AM, (E-Mail Removed)
> <(E-Mail Removed)> wrote:
>
> > I added some paragraphs to the Ruby article on Wikipedia:
> > ...
> > - Is Ruby strongly typed?

>
> Def 8 seems to be wrong; you're looking at what a variable refers to,
> rather than the object type.


I see what you mean here, he should be leaving the variable referring to
the same object, and changing the object itself.

> The object type is constant throughout object lifetime in Ruby....


Well, it depends on how you define "type". It's certainly possible,
without C code, to modfy the behaviour of enough methods on an object
(via defining singleton methods), say a String, to make a reasonable
claim that it's no longer a String but a Number. If it looks like a
duck, and quacks like a duck....


>> On Feb 5, 2008 7:20 PM, (E-Mail Removed)
>> <(E-Mail Removed)> wrote:
>>
>>> Criticism
>>> - Lack of variable declarations


I'd definitely go with this one. I've been bitten so many times
by doing something along the lines of

foo ||= "blah"

Only to realize that, though it "feels" like a read of an accessor, it's
actually the creation of a local variable. (Usually it bites me in more
complex situations than this, but this is the general gist.)

cjs
--
Curt Sampson <(E-Mail Removed)> +81 90 7737 2974
Mobile sites and software consulting: http://www.starling-software.com

 
Reply With Quote
 
Nando Sanchez
Guest
Posts: n/a
 
      02-07-2008
I see all the "criticism" items as strengths in Ruby. If you have
problems with your code, write more automated tests then. You call
something a weakness when you need to change it, but what if we get rid
of these things in Ruby? We end up with c#, VB? No way!

You have a sword with 2 blades... you may think one of those blades is a
weakness because you get hurt more frecuently, so you wish a sword with
only one blade, but may be the problem is in the user of the sword.

This reminds me about several good articles related with Dynamic typing
versus Static typing.

Just my 2 cents...

Nando
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
tho_mica_l
Guest
Posts: n/a
 
      02-07-2008
> This reminds me about several good articles related with Dynamic typing
> versus Static typing.


And how little the arguments perpetuated in these articles have
changed
since I first looked into lisp. BTW why don't we all use Lisp or
Smalltalk today?

Ruby is a pretty cool language and the perfect tool for a lot of use
cases. Some optional strictness here and there really wouldn't hurt
though.

Regards,
Thomas.

 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      02-07-2008
tho_mica_l wrote:

> And how little the arguments perpetuated in these articles have
> changed
> since I first looked into lisp. BTW why don't we all use Lisp or
> Smalltalk today?


Much of what we use derived from them. MS Windows's windowing layer started as a
Smalltalk prototype, for example.

> Ruby is a pretty cool language and the perfect tool for a lot of use
> cases. Some optional strictness here and there really wouldn't hurt
> though.


Excuse me while I mentally count the ways I know how to extend Ruby classes to
make them more strict...

--
Phlip
 
Reply With Quote
 
Austin Ziegler
Guest
Posts: n/a
 
      02-07-2008
On Feb 7, 2008 11:24 AM, tho_mica_l <(E-Mail Removed)> wrote:
> > This reminds me about several good articles related with Dynamic typing
> > versus Static typing.

> And how little the arguments perpetuated in these articles have
> changed since I first looked into lisp. BTW why don't we all use Lisp or
> Smalltalk today?
>
> Ruby is a pretty cool language and the perfect tool for a lot of use
> cases. Some optional strictness here and there really wouldn't hurt
> though.


Counter-argument: it wouldn't help, either. Many people manage to
develop lots of useful software in Ruby without it.

-austin
--
Austin Ziegler * (E-Mail Removed) * http://www.halostatue.ca/
* (E-Mail Removed) * http://www.halostatue.ca/feed/
* (E-Mail Removed)

 
Reply With Quote
 
Jari Williamsson
Guest
Posts: n/a
 
      02-07-2008
(E-Mail Removed) wrote:
> I added some paragraphs to the Ruby article on Wikipedia:
>
> Type system
> - Is Ruby type-safe?
> - Is Ruby strongly typed?
>
> Criticism
> - Lack of variable declarations
> - Dynamic typing
> - Overloaded operators
> - Reflective and meta-programming features
>
> Some "peer review" appreciated
>
> http://tinyurl.com/fpwes
>
> Please feel free to improve upon it, or post comments in this thread.


I find the section about "Reflective and meta-programming features"
strange or perhaps even wrong:

1. Just about EVERY Ruby script use meta-programming features (through
attr_accessor, attr_reader, etc), so why would these features be "poorly
suited for business or large-scale application development"?

2. The given example about difficulty to grasp a class definition just
doesn't make sense. Why would it matter how a class definition looks in
a duck-typed language?


Also, the example in the section "Lack of variable declarations"
contains the following text:
"A simple typo in a variable-name can cause erroneous output from the
program, and still go undetected for a long time."

IMO, this should be added:
"...for a long time, IF PROPER TESTS AREN'T WRITTEN."


Best regards,

Jari Williamsson

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby extension (C++) on OS X [ruby 1.8.2] and Google-Sketchup [ruby 1.8.5] Nicholas Ruby 3 01-28-2007 01:48 AM
The Ruby Edge - Digg for Ruby and Ruby On Rails roschler Ruby 0 10-15-2006 11:35 PM
ruby-talk, comp.lang.ruby, ruby-talk-google Phrogz Ruby 4 09-06-2006 06:43 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
[ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge guillaume.pierronnet@ratp.fr Ruby 0 08-31-2003 11:57 PM



Advertisments