It’s a serious question concerning language philosophy and design.
I believe all of us would be pleased to know the opinion of Matz on it.
Mike S.
(Mikhail V. Shokhirev)
It’s a serious question concerning language philosophy and design.
I believe all of us would be pleased to know the opinion of Matz on it.
Mike S.
(Mikhail V. Shokhirev)
Hi,
In message “Re: Question about Ruby philosophy”
on Tue, 5 Dec 2006 15:35:37 +0900, Mike S. [email protected]
writes:
|It’s a serious question concerning language philosophy and design.
|I believe all of us would be pleased to know the opinion of Matz on it.
|> 2) Why should I not be scared by that ?
You don’t have to, when you trust other programmers, and you have time
to run test suite before deploying the software. It gives you new
possibility, possibility to do many good things, along with a few
dangerous things. Ruby makes you free. You are even free to shoot
your own foot.
|> 3) Why most C#, Java, C++ developper thinks that this approach is
|> dangerous and lead to bad practices ?
Often there are cases where we can not trust each other for various
reasons: immature programmers, discommunication between team members,
etc. Under such circumstance, it is dangerous and lead to bad
practices. Don’t use Ruby for such cases. It’s no fun.
matz.
Edwin F. wrote:
If anything, I’d just want an optional way (besides .freeze) to control
what can and can’t be extended at run-time, to prevent accidental,
ill-advised, or even malicious tampering, or to help identify it). Hey,
maybe there’s a way to do it already?
Unfortunately, Ruby’s killer app makes use of pretty much every one of
these hacks – and rake freeze:edge throws its source code right in your
own directory tree. What’s more, development mode is constantly
meta-mucking at every http request. How’s a poor interpreter to know
what’s trusted and what’s not?
(Or: what Pat said.)
Devin
On 05.12.2006 01:42, Edwin F. wrote:
The bottom line seems to be that the current crop of Ruby programmers
are responsible enough not to mess with things under the hood unless
they understand the workings.Is this an accurate assessment?
I guess so.
macros in C header files (like MIN and MAX) that would clash with other
uses of MIN and MAX and cause untold havoc. Some of these were from
mainstream companies.
Actually there are two significant differences between this and modified
Ruby core classes: C is compiled and CPP macros are gone by the time the
error shows up (it may be that modern C/C++ compilers take care of this
when compiling debug code, dunno). You can more easily debug a Ruby lib
(provided it has no native parts) than a C lib where you might not have
the source code.
Also, I believe Ruby more easily encourages the use of unit tests and it
avoids a lot other errors (famous buffer overruns) which IMHO makes up
for the potential danger of core class modifications.
It’s one thing to say “What if I’m stupid?”. It’s quite another thing to
say, “What if lots of stupid/undisciplined people start using Ruby?”
This tends to be the price of language popularity, I fear.
Maybe a bit. But I think the community will take care of this.
Probably, evolutionary forces will get rid of the poorly designed
libraries in time. I’m more worried about the beleaguered corporate IT
developer who often does not have much choice and has to use in-house
code.
I think evolution will take care pretty well.
Kind regards
robert
On 04.12.2006 23:28, Martin DeMello wrote:
On 12/5/06, Robert K. [email protected] wrote:
“dynamic typing” - there’s a ton of them. Also, IIRC there are
discussions of these issues that revolve around “rational” which used to
change the behavior of Fixnum#/ which could cause problems for some
programs.First I’ve heard of the ‘used to’! When did that change?
I was surprised myself, too:
irb(main):001:0> 1 / 2
=> 0
irb(main):002:0> 1.quo 2
=> 0.5
irb(main):003:0> require ‘rational’
=> true
irb(main):004:0> 1 / 2
=> 0
irb(main):005:0> 1.quo 2
=> Rational(1, 2)
irb(main):006:0> RUBY_VERSION
=> “1.8.5”
I believe I remember that “1 / 2” used to return “Rational(1, 2)” with
‘rational’ loaded. Is my memory wrong here?
Kind regards
robert
On 05.12.2006 10:03, Yukihiro M. wrote:
In message “Re: Question about Ruby philosophy”
on Tue, 5 Dec 2006 17:20:10 +0900, Robert K. [email protected] writes:|I believe I remember that “1 / 2” used to return “Rational(1, 2)” with
|‘rational’ loaded. Is my memory wrong here?Perhaps, you’ve confused ‘rational’ and ‘mathn’.
Exactly!
1 / 2
=> 0
require ‘mathn’
=> true
1 / 2
=> 1/2
(1 / 2).class
=> Rational
I just notice a strange inconsistency:
12:25:18 [~]: irbs
require ‘rational’
=> true
1.to_r / 2
=> Rational(1, 2)
require ‘mathn’
=> true
1 / 2
=> 1/2
1.to_r / 2
=> 1/2
The output of Rational’s inspect method seems to change depending on
whether “rational” or “mathn” is required.
Thank you, Matz!
robert
Hi,
In message “Re: Question about Ruby philosophy”
on Tue, 5 Dec 2006 17:20:10 +0900, Robert K.
[email protected] writes:
|I believe I remember that “1 / 2” used to return “Rational(1, 2)” with
|‘rational’ loaded. Is my memory wrong here?
Perhaps, you’ve confused ‘rational’ and ‘mathn’.
matz.
On 2006-12-05, Edwin F. [email protected] wrote:
How about a Ruby Q. for the funniest way to shoot yourself in the
foot with Ruby?
Years ago I posted this, to overwhelming silence:
You shoot yourself in the foot and make a really quick, clean job of
it because the gun didn’t get in the way.
You try to shoot yourself in the foot but miss because you chose the
wrong type of bullet. It’s less hassle than checking the bullet when
you load the gun.
You shoot yourself in the foot with a string of multi-part bullets.
This method is really popular in Japan.
Shoot yourself in the foot. Don’t worry how big the indentation is,
it doesn’t matter. Not like some guns we could mention.
Load the gun with anything you like and shoot yourself in the foot.
Everything’s a bullet, you see.
On 12/5/06, Yukihiro M. [email protected] wrote:
Hi,
In message “Re: Question about Ruby philosophy”
on Tue, 5 Dec 2006 17:20:10 +0900, Robert K. [email protected] writes:|I believe I remember that “1 / 2” used to return “Rational(1, 2)” with
|‘rational’ loaded. Is my memory wrong here?Perhaps, you’ve confused ‘rational’ and ‘mathn’.
Aha! I was making the same mistake.
martin
Yukihiro M. [email protected] writes:
Often there are cases where we can not trust each other for various
reasons: immature programmers, discommunication between team members,
etc. Under such circumstance, it is dangerous and lead to bad
practices. Don’t use Ruby for such cases. It’s no fun.
Do you consider Ruby a good language for teaching people that haven’t
programmed yet? Just wondering.
On 12/7/06, Edwin F. [email protected] wrote:
Jeremy H. wrote:
On 2006-12-05, Edwin F. [email protected] wrote:
How about a Ruby Q. for the funniest way to shoot yourself in the
foot with Ruby?Years ago I posted this, to overwhelming silence:
Thanks for responding - this time there’s a bit of noise at least!
Let me try one.
The short tale of a ruby warrior:
self.shoot(foot) and yield
martin
Jeremy H. wrote:
On 2006-12-05, Edwin F. [email protected] wrote:
How about a Ruby Q. for the funniest way to shoot yourself in the
foot with Ruby?Years ago I posted this, to overwhelming silence:
Thanks for responding - this time there’s a bit of noise at least!
Let me try one.
class Myself
def shoot_in_foot
foot = Foot.new(:side => :right)
hand = Hand.new(:side => :right)
gun = Gun.new(:make => “Freedom Arms”,
:type => :revolver, :action => :single,
:caliber => “.454 Casull Magnum”)
hand.grasp(gun)
hand.grasped_object do |gun|
gun.load
gun.cock
gun.aim(:at => foot)
gun.pull_trigger # => “Bang!”
end
hand.drop_object # => Thump!
self.scream
foot.inspect
end
def scream
“Arghhhhhhhhhhhhhhhhhhhhhhhh!!!”
end
end
myself = Myself.new # I feel like a new man!
myself.shoot_in_foot
=> “Bang!”
=> “Thump!”
=> “Arghhhhhhhhhhhhhhhhhhhhhhhh!!!”
=> NameError: undefined local variable or method `foot’ for
#Myself:0xb7573ee4
On Thu, 7 Dec 2006, Edwin F. wrote:
Jeremy H. wrote:
On 2006-12-05, Edwin F. [email protected] wrote:
How about a Ruby Q. for the funniest way to shoot yourself in the
foot with Ruby?
#!/bin/ruby -w
me = File.read( FILE)
open( FILE, ‘w’) do |f|
f.syswrite( me.sub( /ruby -w/, ‘sh’))
end
Although this works fairly well too…
#!/bin/ruby -w
me = File.read( FILE)
open( FILE, ‘w’) do |f|
f.syswrite( me.sub( /-w/, ‘sh’))
end
John C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand
On Dec 6, 2006, at 18:11 , Harold H. wrote:
#!/bin/ruby -w
me = File.read( FILE)
Seems to shoot irb in the foot, for various values of foot, like head.
eval? please!
Object.constants.each do |c| Object.send :remove_const, c end
–
Eric H. - [email protected] - http://blog.segment7.net
I LIT YOUR GEM ON FIRE!
On 12/7/06, Eric H. [email protected] wrote:
ahhhh, now that’s the Ruby Way.
I’m such a noob,
-Harold
On 12/7/06, John C. [email protected] wrote:
me = File.read( FILE)
f.syswrite( me.sub( /-w/, ‘sh’))
end
Thats cute.
How about this?
Object.constants.each do |x| eval( “#{x} = nil” ) end
Seems to shoot irb in the foot, for various values of foot, like head.
(:,
-Harold
Eric H. wrote:
#!/bin/ruby -w
me = File.read( FILE)
Seems to shoot irb in the foot, for various values of foot, like head.
how about this?
sudo rm -fr /usr/lib/ruby
–
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blogspot.com/
If God had meant for carrots to be eaten cooked, He would have given
rabbits fire.
M. Edward (Ed) Borasky wrote:
/ …
how about this?
sudo rm -fr /usr/lib/ruby
Gee, I hope the newbies don’t try this just to see what happens. If they
“succeed”, they might then try for the more concise, powerful form,
which I
won’t post an example of.
On 12/7/06, x1 [email protected] wrote:
As close to being shot in the foot as I could get:
irb(main):008:0> puts ENV[‘OS’]
Windows_NT
That’s missing your foot altogether and shooting yourself in the head
instead…
max
As close to being shot in the foot as I could get:
irb(main):008:0> puts ENV[‘OS’]
Windows_NT
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs