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."
No more text.
What?
It seems to be much more mature than some other language released recently... Well done, folks! It looks like the rip-off can certainly be better than the original... err... total-multi-rip-off. Yeah.
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
Apparently the poster isn't a native English speaker. Anyway, all he meant was that the tarball is about twice as big now. This is almost entirely due to the inclusion of more libs, not an increase in size of the Ruby core.
I found that amusing as well. What the hell is wrong with "is twice the size of 1.6.8?"
Here's the link to the changelog.
DNA is the ultimate spaghetti code.
Not everyone here is ... er ... Welsh, you insensitive clod! ;) Check out his posting history -- he's probably not a native English speaker. Still, his English is a lot better than Taco's.
If I'm not mistaken, Ruby is the first language to include built-in support for YAML!
Thanks to Matz for such a great language!
Can you please elaborate on what features Ruby has that Python doesn't?
Two features that come to mind immediately:
1) continuations - Python doesn't have'em. While this is a fairly obscure and difficult to understand feature, I've found it to be vary valuable in a couple of instances where without them I would have had to write a lot more code to get the job done.
2) code blocks - at first they seem trivial, but after you start using them and thinking in terms of passing code blocks around you end up using them a lot. They tend to make your code look very natural (not sure how else to explain it, they're just cool).
I suspect there are other differentiating features as well, but these are the two that come to mind immediately and Python's lack of these two features tipped the scales in favor of Ruby for me.
Oh, I suppose I can add an anti-feature that also tipped the scales in favor of Ruby for me:
Ruby doesn't consider indentation as syntax - I know a lot of Pythonistas seem to like indentation as syntax, but I never got to like it... for example, if I wanted to copy&paste some section of code into another section and they were at different levels of syntax... well, it could just get messy. I don't need those kinds of hassels.
The Ruby sessions at OSCON this year all seemed to be very well attended. Seemed to be a lot of buzz about Ruby there in certain quarters. After attending one of those sessions, I decided to learn Ruby. I'd really like to be able to quit doing OO-Perl - it's sooo ugly - and I don't think I can wait for Perl6.
For those of you who are interested, some good sites/resources for ruby: RubyForge (http://rubyforge.org)- A site using gforge for hosting project in Ruby RAA (http://raa.ruby-lang.org) - Ruby Application Archive Pragmatic Programmers - (http://www.pragmaticprogrammer.com/ruby/index.htm l) the complete book is online!!
They can be used in unique ways that are pretty darn useful. For instance, you can use them to create configuration blocks for objects, without cluttering the constructor. myServer = Server.new( socket, something ) { set_sercurity_mode 2 set_logfile_path "/var/logs/speciallogs/" } /ECO
Slashdot. It's Not For Common Sense
Don't forget some of the other unique uses of blocks, that make them very, very powerful.
They can be used in unique ways that are pretty darn useful. For instance, you can use them to create configuration blocks for objects, without cluttering the constructor.
A constructor aware of this can use this block to configure the object in ways that normally would require dozens of different constructors, with a relatively unambiguous syntax. Even better, defining those set functions for the configuration block also defines them as instance variables. 2 foe the price of one!With a little thought and use of Ruby's excellent security model, it's possible to even just dump a file into that block, and use the file as the configuration block!
Slashdot. It's Not For Common Sense
A good example of this is the lack of need for semicolons at the end of each line. Ruby has semicolons for statement separators, but you only need to use them when there are multiple statements on one line. For example:
Another example is that you don't have to use straight brackets to delimit arrays. You only must use them to clarify confusing situations.It's important to differentiate this attribute from the flexibility of the syntax. Ruby allows you to use, or not use, certain pieces of its syntax to help you adjust to it. For instance, when calling sending a message to an object, you need not use parenthesis to delimit the message parameters. In general there is a synonym for most every syntactic feature. One is the common usage (likeOne might be tempted to say that is what's wrong with Perl, and to a degree that's true. Ruby however, keeps its core syntax quite small. The synonyms exist for a clear and obvious purpose. Perl seems to lack that purpose, instead citing TIMTOWTDI.
Slashdot. It's Not For Common Sense
UNICODE support added yet?
GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
you're programming in javascript.
(I kid you not.) Imagine a C++-like language that can do all that (and more). That's javascript.
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
That's not what it says. It says that 1.6.8 is twice the size of the new release. At least the submitter has the excuse of being a non-native English speaker. What's yours?
...wearing a skin-tight topless leather jumpsuit, with cutaway buttocks and transparent crotch panel.
One of the most useful instances of blocks I've found, and the one that truly converted me to Ruby, is registering them as callbacks.
I was working on a program while learning Ruby where we wanted to filter an incoming stream of events and filter them out to handlers. Some events needed to be dispatched to multiple handlers, others could be ignored.
The traditional approach would be to modify Dispatcher (any capitalized noun will be a class in my example here) and add some filtering logic each time a new filter needed to be added. But with procs (which are real closures, not just anonymous code blocks), I can do this:
Of course, this example is trivial, but the I'll admit I've since learned a way to do this in Perl, but it's much cleaner and all in all elegant the Ruby way.
Jacob Fugal
(ps. apparently <ecode> doesn't preserve my indentation, sorry...)
Have you ever taken a look at the OO syntax of Javascript? It's damn ugly! I was really impressed at things like Function() though. If it weren't for the browser-specific parts of Javascript then it would be a pretty good language... but used to manipulate browsers it's a real pain.
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...
Ruby is a cool language, but someone has to break down and document it. There is quite a bit of not-quite-current documentation, including a great online version of Programming Ruby , but the official library reference is for 1.6 and the language reference is for 1.4. The lack of current documentation for 1.8 raises doubts about the consistency of the language's behavior, especially its more Perlish, do-what-I-mean features.
Finding out that a programming language named "Brainfuck" exists gave me a hard-on. How did I never hear of this before?
Time to learn another language...
Slashdot - where whining about luck is the new way to make the world you want.
What's Shiny and New in Ruby 1.8.0?
Despite the whimsical name, there is such a thing. It is based on a kind of string manipulation syntax akin to a Turing machine. I don't think it is meant to be a serious programming language as much as a puzzle or a kind of mental activity, hence the name . . .
last post!
--
Baby Ruby says "bwarghhhhh!"
Karma: Bad due to google bombing - Robert Watkins woz 'ere.