Three Books About the Ruby Programming Language
DJSpray writes "I've written a review of three books about the Ruby programming language, available on my weblog here. The three books are Yukihiro Matsumoto's Ruby in a Nutshell from O'Reilly, Hal Fulton's The Ruby Way (Sams), and Programming Ruby: The Pragmatic Programmer's Guide by Dave Thomas and Andrew Hunt (Addison-Wesley). Note that the third book is available online here for those who prefer that sort of thing. Executive summary: while I have found several of the other O'Reilly Nutshell series books to be excellent, this one is riddled with errors, confusing writing, and omissions, and does not live up to O'Reilly's usual standards. Fulton's book is filled with good cookbook examples and well-written explanatory material, as well as solid tutorial examples, but it is not structured as a reference. The Pragmatic Programmer's book works well as a reference and covers language features in increasing depth, but with fewer examples. Ruby beginners may find that the latter two books actually complement each other nicely, while I can't recommend this edition of the Nutshell book at all."
I like what I've seen of Ruby. There's just one snag: no UNICODE support except via libraries.
I already know Perl. I'd like to learn something cleaner, and Ruby looks like exactly what I'm looking for. However, I'm not prepared to put in effort learning yet another language that doesn't have native multilingual text support.
Doing everything via library calls to get UNICODE support is an ugly hack... and like I say, I know Perl, so my ugly hack requirements are already adequately met.
GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
Ruby is a competitor to both Python and Perl. In some sense, it is an attempt to combine the best features of each. My belief is that it succeeds well at this goal. It offers an even purer OO approach than python, while offering much of perl's strong syntactic sugar.
note: these books are all several years old; nothing new here
Many people who might like ruby better are happy enough with perl and python. Perl has a much larger class library because it's the established player. Many people who were dissatisfied with perl's loosy-goosy style and OO approach probably already left and went to python.
At some point many potential switchers say "OK, maybe ruby is slightly better at this and has this other advantage, but I can live without that slight advantage because I get a bigger community and class library to draw from by staying with [perl|python]"
Personally, I don't find that argument persuasive because I think it's good to know more langagues and I give my first look to ruby and fall back to python or perl only if I need class libraries that I don't want to write myself.
However, I think the Practical Programmers' book is much better than you give it credit for. It does a credible job of introducing an experienced programmer to the Ruby Language (although it's really not for those who are not familiar with an Object-Oriented Language). I have found that that is my standard Ruby resource.
Incidentally, I only picked up Ruby a few months ago, and have found it to be a great language. Unfortunately, some of the support is not yet there. I've ended up doing my latest project in Java because I don't want to lock myself into a language that will not support high-end scalability features.
"He who would learn astronomy, and other recondite arts, let him go elsewhere. " -- John Calvin, commenting on Genesis 1
I'd place ruby somewhere between "a cleaner python" (at least, in terms of design-- ruby learned the lessons of Python for free, that Python had to learn the hard way...) and "a saner Perl"... (of course, Perl's insanity is half the fun!)
It's got all the LISPy goodness of Python (and supports true closures & continuations, which IIRC are only to be found in experimental implementations of Stackless Python), the regexpy powerfulness of Perl, and the dynamic-OO cleanness of Smalltalk.
I find it really makes programming fun again, and it's very easy to write extensions for it in C (or C++, if that's your bag, baby)... in fact, using ruby as the "brains" behind a bunch of C modules gives you the silly-fast speed of C, while correcting C's worst deficiencies (you get free GC, safer string handling, namespaces, OO, etc.)
Ruby's "chock-full of heady goodness", and definitely worth adding to your repertoire.
A 4th book on Ruby that I kind of like is _Ruby Developer's Guide_ by Robert Feldt, Lyle Johnson, Michael Neumann (Editor), Lyle Johnson, Jonothon Ortiz.
This has a series of chapters on more applied topics that would be good for the Slashdot programmer audience: DBI, XML, SOAP, Performace, Parsers, etc... The book is a little wordy, but the topics covered are very useful and it imparts a lot of useful information for people who don't want to relearn basic syntax.
I use it for all my basic scripting needs though, and like I said, I really love it. It's OO makes a lot of sense, the block-passing stuff is awesome, and you can do perl-esque stuff like easy regular expressions.
Basically I was looking for a good OO language, and although Python is okay, and I like the whitespace blocks, the language doesn't "feel" right to me. Also it seems to be changing every now and then so I'll probably wait until a few more evolutions before I look at it again.
I have the O'reilly book and yes it does read like it was translated from Japanese but I haven't found any factual errors. I use it regularly for reference.. I don't think I'd avoid it like the reviewer does.
The Pragmatic Programmer book is probably the best one, I have the paper copy and I'm currently trying to reformat the HTML version to fit on my Zaurus.. there is an XML version but it's really weird. For instance it uses
between paragraphs rather than AROUND them.........
Anyway if anybody out there is interested in a good OO language and is getting impatient waiting for Perl 6, check out Ruby.. I'd love for it to mature some more and move in from the fringes................
please don't suggest that non-compiled languages aren't "real" ... there's so much run-time dynamic stuff happening with compiled languages and modern CPUs, and so much pre-processing in "scripting" languages that the distinction will become more and more blurred as time goes on.
I use Ruby, Perl, and C for ALL my programming these days, and I don't distinguish between them in those terms any more.
The original poster inquired about the usage of Ruby, not the features. For example:
;-)
- I am writing a Windows desktop application with Internet connectivity. It needs to have a GUI, ease of installation and general portability among Win32 platforms. Can I use Ruby?
Yes.
- I am writing a low-level routine to be embedded into MP3 player hardware to increase the functionality and add some features to the hardware piece. Can I use Ruby?
Probably, though you'd want to do the low-level stuff as a C extension.
- I am writing a large content management system for the Web, it will be accessed by about a dozen journalists and editors, some routine features like ability to edit and comment on an article are required. Can I use Ruby?
Definitely.
- I am writing a large application the main purpose of which is generating the database reports and distributing the data from the wirelessly to multiple platforms within the organization. Can I use Ruby?
Yawp. You're a natural candidate for this language, y'know...
And so on. Perl is an obvious choice for CGI, C for low level stuff, Java for server-side enterprise, C# for desktop apps. Where can I use Ruby?
I use ruby for CGI, database stuff, as a smarter replacement for shell scripts, and general application programming (and it's easy to extend ruby with C modules, so even the low-level stuff is covered); call me a language bigot, but for me ruby has become the language of choice.
Try it.
Ruby's "chock-full of heady goodness", and definitely worth adding to your repertoire.
.NET is absolutely not the answer to this, as .NET is really multiple facades of the same thing wrapped up in a single-vendor bend-'em-over solution from a un-trustworthy company. The fact is that there is no good solution.
Where should Ruby rank among the other 4385 lanugages and APIs that everyone says are worth learning?
I really don't mean to troll, but the fact that programming languages are still so volatile is good evidence that programming languages are still in their infancy. By volatility, I mean that every 6 months or so, a brand new "must see" language is invented, develops a "growing userbase" of neophytes and zealots, becomes "production quality", gets several books written about it, and is adopted by a few risk-taking companies in real projects.
I've seen software get written in such languages (Lisp, then Perl, then Java, then Python, etc.), where all that work will not carry over when the "next big language" is invented and becomes popular among interns (because who wants to learn something unfashionable like Lisp?).
This is probably why most software is still written in C and C++, even though they are bug-magnets, because they are most definitely not going anywhere for a long time.
Healthcare article at Kuro5hin
I am not knocking Python, but I have been investigating Ruby specifically because there were aspects of Python that I didn't like. I'm probably much more anal-retentive than the average developer; purity and consistency in the language design means a lot to me.
I've got a number of gripes with Ruby, but fewer than I had with Python. Among the many features I didn't like in Python were the lack of a consistent Boolean type and the lack of standard closure semantics. Instead, we get values evaluated in a Boolean context, which reminds me of all the things I didn't like about Perl. I also have been consistently given the impression that Guido is not really friendly to the functional programming community and the language will not evolve to be more supportive of the functional programming paradigm.
For context, my favorite programming languages have been Apple's NewtonScript, which was a very small language with an exceptionally clean design, and Dylan, which is not so small, but which makes Lispish programming paradigms available with a very clean Pascal-like syntax. Yep, I back the winners : )
Ruby also seems to represent a good merging of functional and object-oriented style; everything is truly an object, with no distinction between classes and types (Python is getting around to erasing this distinction as well, it seems).
Ruby has a lot of minor inconsistencies and things I don't like. I'm hoping perhaps I can get my voice heard on some of these issues. I'm not really in favor of including a lot of the Perlisms as part of the core language, but it seems like an excellent project to support.
In addition, I've been able to link Ruby into my C and C++ application code easily as a runtime support library and set up calls back and forth. That impressed me. Deploying Python this way has seemed harder, although maybe it can be done and I just haven't figured out how yet.
Try the FOX toolkit. (If you're using the standard Windows build, you'll find it's already there, along with tons of example programs.)
Well said!
My programming language has the speed of C, regex of perl, portability of Java, and every goodie of every language before it. Better learn it because it makes development SO fast and intuitive. So many programmers are flocking to it.
But doesnt that make my language LESS faster than C, LESS portable than Java etc??
The market is so variable, new niches are created and old ones destroyed. Cobol WAS a good language for what people did once upon a time. That entire niche has disappeared, automated and all its tasks fully programmed into other libraries that are simply imported and used. Software structures have changed so Cobol is no longer needed. Yet the pressure on
C will sit tight. Even C++'s use is shaky and its market has had huge lumps bitten off by java and now C#. But C is the very basic language over the assembly and everyone and his grandfather knows it. It is so simple as a language, its like riding a bycicle, you dont forget it.
But what is Ruby?? Where does THAT come in? Make a language as pretty as you want, market it better than C# but that doesnt change the markets needs. Pythons found a small foothold next to perl, partly into installations part in GUIS using QT, but is Ruby trying to nudge Python now to hold on one toe?? I can already see Ruby in freefall... screaming... screaming stories of its goodness on slashdot.
"Give orange me give eat orange me eat orange give me eat orange give me you." -Nim Chimpsky
Language Bigot!!
"Give orange me give eat orange me eat orange give me eat orange give me you." -Nim Chimpsky
Where should Ruby rank among the other 4385 lanugages and APIs that everyone says are worth learning?
:-)
I'd put it pretty high on that list...
I really don't mean to troll, but the fact that programming languages are still so volatile is good evidence that programming languages are still in their infancy. By volatility, I mean that every 6 months or so, a brand new "must see" language is invented, develops a "growing userbase" of neophytes and zealots, becomes "production quality", gets several books written about it, and is adopted by a few risk-taking companies in real projects.
Ruby originated in Japan in 1993. It's been pretty stable interface-wise for at least the past 3 years.
This isn't flash-in-the-pan stuff. Perl, Python and Ruby simply aren't going to disappear, so put your fears to rest.
But doesnt that make my language LESS faster than C, LESS portable than Java etc??
Well, with any interpreted language you've got a certain unavoidable overhead. But when you can easily integrate it with compiled C code it quickly becomes a non-issue. Ruby programs run the same across the ports to various OSes, which is something that Java was supposed to do.
The market is so variable, new niches are created and old ones destroyed. Cobol WAS a good language for what people did once upon a time.
If you enjoy programming in COBOL, perhaps ruby is not for you.
*grin*
Does the latest FORTRAN standard still allow you to assign to constants (pass "3" to a call-by-value parameter and you risk getting that number redefined!)? I'd think that 50 years is plenty of time to fix that particular design bug, but you never know!
But doesnt that make my language LESS faster than C,
:-)
The standard Pythonista answer is that in most programs, 80% of the time is spend in 20% of the code. Profiling and careful optimization usually gets the performance hit down to the magic phrase "less than noticable".
The other half of the Pythonista answer is that working at a very-high level makes rapid application development possible. Your programs end up well factored because it's easier to rearchitect things.
Kent Beck calls it "First Make it Work, Then Make it Right, Then Make it Fast" and Don Knuth says "Premature Optimization if the root of all evil in programming". I think in the long run, C will end up occupying the same niche Assembler once held: You use it to extract extra performance when you need it, otherwise you use the higher level language.
(Caveat: I recently read the Debugging chapter in Python in a Nutshell. Most of the arguments are paraphrased from Alex Martelli's excellent writing. I'm simply not this intelligent usually...
My father is a blogger.
Umm ... once you start using it:
* You're probably using an editor that'll auto-indent (from emacs to Visual Python), so you don't have to do it consciously
* It looks just like properly-indented code, so you don't have to read the whitespace. Believe me, you're not there saying "Hmm. This is indented so far, so I think it goes with that!"
In other words, the whitespace in Python doesn't have as much meaning as you seem to attribute to it.
Almost no one has to hit the spacebar 16 times (unless you're using Notepad for all your coding). And good C, C++, Perl, Java, Visual Basic, etc. is indented in blocks anyway.
Joe
http://www.joegrossberg.com
Just picked it up at Borders a couple weeks ago and I'm only a few chapters in, but so far it's very well written and succeeds in anticipating the programmer's questions. The book claims it can't teach you Ruby, but they underestimate themselves. Granted Ruby's "just another language" for me, so if you're a new programmer this isn't your book, but if you're an experienced programmer this book does a great job.
My God, it's Full of Source!
OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
Let me get this straight...above you ask what ruby is and then proceed to make pronouncements about it's "freefall" and imply that it's some sort of slashdot fad. The damn language has been around for 10 years. Rather than waxing prolific about the obvious uses of C/C#Java/Perl/Python why don't you take a look at Ruby? If don't care or don't want to, fine. Making sweeping generalizations about market forces as applied to programming languages as a means to discredit a language you admittedly know nothing about is pendantic at best.
Matz has made it clear that the design of Ruby is based first and foremost on making it easier for him to do his own work, which he has stated is primarily in the Japanese Unix encoding EUC-JP. He says "EUC-JP is good enough for me" and "Ruby's internationalization strategy is whatever doesn't interfere with my Japanese work".
.Net or Java Strings might be a great tool if the performance could be made acceptible.)
Well, if EUC-JP good enough for him, then he clearly doesn't build globalized apps. It's the Japanese equivalent of a US language designer saying, "I want my language to be optimized for 7-bit ASCII, which is good enough for me." (Which, of course, is the history of many old programming languages from the days of standalone, unconnected computing, but he still takes that approach today in the era of the WORLDWIDE Web.)
His provincial attitude about Unicode tells me that though Ruby's design is full of great ideas and he is a gifted language designer, ultimately Ruby can't be taken seriously as a production platform if you have any international ambition at all.
(On the other hand, something like a Ruby.Net or JRuby that used
"Those who have never entered upon scientific pursuits know not a tithe of the poetry by which they are surrounded."