Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #46  
Old March 28th, 2006, 12:56 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 8,349 Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 23rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 16 h 23 m 26 sec
Reputation Power: 2538
One thing that I don't like about ruby currently (Matz says vaguely that this *MAY* be fixed in ruby 2.0, but he can't decide the best way) is how the block argument variables work. Take netytan's example here:
Code:
array = ['fee', 'fie', 'fo', 'fum']
array.each {|i| puts i }
puts
puts i

Running this produces:
Code:
fee
fie
fo
fum

-:4: undefined local variable or method `i' for main:Object (NameError)

Note that 'i' has gone out of scope correctly outside the loop and thus there is a NameError. In iterative language terms, it acts as though 'i' is merely a n argument parameter to an anonymous function. Now observe what happens if we have i declared previously.
Code:
i = 5
array = ['fee', 'fie', 'fo', 'fum']
array.each {|i| puts i }
puts
puts i

Running this produces:
Code:
fee
fie
fo
fum

fum

Note that now 'i' inside the each uses the variable outside it and unexpectedly changes the value (from 5 to 'fum'). Hence, it is very unwise to name your variables as i, j, x etc. since a block may change its value by accident.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by Fishmonger, superior perl programmer of the month

Reply With Quote
  #47  
Old March 28th, 2006, 01:01 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,569 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 9 h 38 m 8 sec
Reputation Power: 379
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Quote:
Originally Posted by SimonGreenhill
I'm enjoying this discussion folks, & I'm glad to see it hasn't turned into a "my language is cooler than yours" argument, which, lets face it, are entirely pointless ( use the right tool for the job, right? ).
--Simon

and you thought hell was going to freeze

Reply With Quote
  #48  
Old March 28th, 2006, 01:22 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 16 m 27 sec
Reputation Power: 64
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Wow she's a nice bug waiting to happen. I'm assuming this behaviour is what Matz is going to fix rather than the syntax? Personally I like the syntax for blocks so I wouldn't like that to change but this 'i thing isn't good.

I suppose the reason it's gone like this for so long is that generally things are encapsulated within the classes and modules . That and generally don't get names so generically in the main scope – I should hope – but i'll look out for it as I use the language more .

Thanks for the info Scopi,

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #49  
Old March 28th, 2006, 04:19 PM
L7Sqr L7Sqr is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: Constant Limbo
Posts: 798 L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level)L7Sqr User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 18 h 46 m 38 sec
Reputation Power: 233
Send a message via AIM to L7Sqr
Quote:
Originally Posted by Dietrich
Code:
...
list1 = ['fee', 'fi', 'fo', 'fum']
print list1  # ['fee', 'fi', 'fo', 'fum']
...


Code:
...
array1 = ['fee', 'fi', 'fo', 'fum']
...
"""
fee
fi
fo
fum
"""


Not that it hasn't already been addressed, but fyi
Code:
list = ['fee', 'fie', 'fo', 'fum']
=> ["fee", "fie", "fo", "fum"]

p list
["fee", "fie", "fo", "fum"]
=> nil
Comments on this post
netytan agrees: 'p is handy, I for one didn't know of it thanks .
Dietrich agrees: Thanks for the p thing
__________________
Some people have 20 years of experience. Some have 1 year of experience 20 times.

My personal site: Basic geek randomness

Reply With Quote
  #50  
Old March 29th, 2006, 08:12 AM
LinuxPenguin's Avatar
LinuxPenguin LinuxPenguin is offline
fork while true;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2005
Location: England, UK
Posts: 5,535 LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)LinuxPenguin User rank is General 1st Grade (Above 100000 Reputation Level)  Folding Points: 11590 Folding Title: Novice Folder
Time spent in forums: 1 Month 3 Weeks 1 Day 19 h 30 m 28 sec
Reputation Power: 1046
I'm personally heading more down the python road now. There's a lot of nice stuff in ruby, it's a lovely language... However, there's not really all that much difference in python coding styles, which is great, since if everyone is using the same coding style, there are no arguments about code.

Python may have annoyed me a few times in the past, and they may have deprecated the 'find' module, but on the whole, i'm starting to prefer it over ruby in some ways. Documentation is a key thing here, and the way third party extensions work makes it much easier to subclass in python

Reply With Quote
  #51  
Old March 29th, 2006, 11:05 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 16 m 27 sec
Reputation Power: 64
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Think we've crossed over and are going down the opposite road LP . Python is a great language and one I'll always enjoy using but it just feels too restrictive as of late.

I guess there are two ways to look at the structure Python imposes on its users – at the beginning I thought it was a good thing. After 3-4 years though I don't know, it's just less fun. I can't express things in my way I have to do it in Pythons way.

Ruby though feels more like Lisp and makes it much easier to express things if you ask me. It also lets u program naturally in a functional style, which I think is a big advantage. It's not as simple or elegant as Scheme in my opinion but just works.

To be quite honest thats my only reason for choosing Ruby over Python; it's a better Lisp .

The lack of documentation doesn't bother me as much as perhaps it should because if I have any questions I'll just ask someone in the know .

As you said there's not much in it. Advice to anyone trying to make this decision: use both and pick the one that feels the most natural.

To be fair there really isn't much point in comparing them, you just have to give it a go.

Later,

Mark.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Ruby Or Python


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek