Ruby 1.8.0 Released
waieitch writes "A long-waited new version of the scripting language, Ruby 1.8.0 has just been released. You can download from here, and the changelog is available. With many new libraries, say dRuby, ERB, REXML, this version is doubled by 1.6.8 in size."
This language is definitely worth a look. It's not just a python knock-off, as many have supposed -- it offers features python doesn't.
"He who would learn astronomy, and other recondite arts, let him go elsewhere. " -- John Calvin, commenting on Genesis 1
Smalltalk is a language which manages to be expressive, but without the amount of syntax that Ruby has.
:= Regexp new: '[0-9.]+' .
:= File open: 'copyOfGeneral.txt' .
:= Dictionary new .
.
I'm a Smalltalk-er who likes Ruby for its Smalltalk-eyness.
After all, here are 5 lines of Ruby code that give the count of unique IP numbers listed from a webserver logfile which downloaded a particular file from the server
Ruby code:
anIpNum = Regexp.new(/[0-9.]+/)
aFile = File.open('D:/Savant/copyOfGeneral.txt')
aDicti onary = Hash.new
aFile.each_line { | line | aDictionary[line.slice(anIpNum)] = 1 if line.include?("plastic_1.1_lite-UMLtool-fw.exe") }
puts aDictionary.size
and the equivalent Smalltalk
anIpNum
aFile
aDictionary
aFile each:
[ | eachLine |
eachLine include: 'plastic'
ifTrue: [ aDictionary at: anIpNum put: 1 ]
]
aDictionary size
Of course, in Smalltalk-80 there isn't a standard Regexp class, so I'd have to find one.
But I hope you all agree that Ruby's syntax is not too far off Smalltalk's elegance in this example.
p.s. Apologies for the formatting, but until I selected 'Code', Slashdot's lameness filter kept rejecting this post...