×

Announcing: Slashdot Deals - Explore geek apps, games, gadgets and more. (what is this?)

Thank you!

We are sorry to see you leave - Beta is different and we value the time you took to try it out. Before you decide to go, please take a look at some value-adds for Beta and learn more about it. Thank you for reading Slashdot, and for making the site better!

The Ruby Way

samzenpus posted about 8 years ago | from the way-she-goes-boys dept.

81

Tim Hunter writes "Hal Fulton's The Ruby Way, Second Edition doesn't try to be the only book a Ruby programmer needs. It tries to be a book every serious Ruby programmer needs, and it succeeds. The Ruby Way is a book about programming with Ruby, the object-oriented programming language from Japan. Ruby is free software and runs on Linux, Microsoft Windows, Apple OS X, and other operating systems. It is available for download from its web site, www.ruby-lang.org or its companion site www.rubyforge.org. Read the rest of Tim's review.

I read the first edition of The Ruby Way when it was published in 2002, not long after I starting programming in Ruby. I was a member of the discussion group Fulton organized during the writing of this edition. I am also the author of RMagick, one of the libraries described in this book, and did the technical review of that section.

This is a review of the second edition of The Ruby Way. The first edition described the then-current Ruby syntax and libraries and showed novice Ruby programmers how to perform common programming tasks. In the past four years Ruby has evolved and its community has grown immensely. Consequently, the first edition was starting to look a little long in the tooth and the Ruby community has been eager for the appearance of a new edition. This edition is almost a complete rewrite. Saying that it's 260 pages longer minimizes the actual scope of the changes. There are a dozen new chapters. Some of the new material expands on topics that were present in the older work, like regular expressions and data structures. However, much of the new material covers topics that simply didn't exist 4 years ago, such as Ruby's XML and RSS libraries, RubyGems (Ruby's answer to CPAN), and Rake, the Ruby version of make.

The Ruby Way doesn't try to teach how to program in Ruby. For that, you need Dave Thomas' Programming Ruby: The Pragmatic Programmer's Guide or a similar book. The goal of The Ruby Way is nothing less than describing the universe around the Ruby programming language. In one 800+ page volume, it describes Ruby's design principles, history, syntax, built-in classes, standard libraries, 3rd-party add-on libraries, related development tools, and user community. The examples and Fulton's explanations emphasize Ruby programming best practices, hence the title.

Fulton describes The Ruby Way as an "inverted reference." A typical reference book for a programming language lists the libraries, classes and methods by name, which you can use to discover their purpose. The Ruby Way, on the other hand, groups Ruby's libraries, classes and methods by purpose, from which you can discover their names. Section titles tend to describe tasks, such as "Tokenizing a String" and "Interacting with an IMAP Server". The sections then describe the split method in the String class and the net/imap library, respectively. Several chapters group Ruby libraries by related tasks. For example, Chapter 15 describes Ruby libraries used to process specialized data formats such as XML, RSS, images, and PDF. In this chapter you will learn that XML processing in Ruby is typically done with REXML and that PDF files can be created with PDF::Writer, etc. Organizing topics by purpose or function instead of by name makes it easy to discover what parts of Ruby you need to complete a task.

Unlike many of the 2-inch thick books about programming for sale lately, there is no fat in The Ruby Way. It hits the ground running with an introduction to object oriented programming and a whirlwind tour of Ruby syntax. It covers Ruby's built-in classes in considerable depth. The String class gets an entire chapter, as do regular expressions. Array and Hash rate yet another chapter. Fulton continues with an in-depth survey of Ruby's extensive standard library. Interested in object persistence? Chapter 10 describes Ruby's YAML library. Wondering about unit testing? Go to Chapter 16 to read about the Test::Unit library. One of the most frequently asked questions to the ruby-lang mailing list is "what GUI libraries are there for Ruby?" Chapter 12 supplies sample applications that demonstrate graphical interface libraries such as Ruby/Tk, FXRuby, and QtRuby. Chapter 19 is dedicated to web application development tools ranging from the famous Ruby on Rails to the lesser-known but equally useful Nitro. Chapter 22, "The Ruby Community," tells where other Ruby programmers hang out. Catering to his programmer audience, Fulton peppers each section with code snippets and complete example programs. (The source code for the book can be downloaded from Fulton's web page.)

Although Ruby is thought to be a "Linux-centric" language it also has a large audience in the Microsoft Windows community. Fulton addresses these users' needs with a description of the "One-Click Ruby Installer" for Windows. This description is accompanied by a section about the Ruby libraries available for scripting on Windows. For example, Fulton shows how to open a file dialog box using the Win32OLE library.

Fulton says that he doesn't expect anybody to read his book from front-to-back. Nevertheless The Ruby Way is quite readable and (if not for its considerable weight) would make a good book for browsing while waiting for the bus, or between classes. Some sections contain a surprising amount of general background information, such as the remarkably in-depth description of Unicode in Chapter 4. Not content to simply educate the reader, Fulton continues his practice in the 1st edition of entertaining the reader with thoughtfully chosen quotes, geek humor, and personal observations.

Is there anything not to like about this book? Well, to be perfectly honest I occasionally found myself wondering if sometimes Fulton spread himself too thin. The amount of coverage for individual classes and libraries varies widely. Some of the standard libraries, like REXML, get several pages of description and an accompanying example while others, such as open-uri, get only a cursory introduction and a pointer to the on-line documentation. At 4 pages, the section on Rails is perfunctory and, given the number of very good books already available on the subject, redundant. (Fulton himself says the material is "cursory.") I have to wonder if it isn't there simply because "everybody" expects books about Ruby to say something about Rails. Similarly he devotes a single page to ActiveRecord, which, as a part of Ruby on Rails, is capably documented elsewhere. That page would've been better used to double the number of pages spent on Og, another Ruby ORM which is not so richly documented.

I recommend this book to any programmer who has already learned the basics of Ruby syntax and its built in classes and who wants to learn more about using Ruby to accomplish typical programming tasks. While it will be particularly useful to the novice Ruby programmer, it is a handy reference for Rubyists at any level of experience.


You can purchase The Ruby Way, Second Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

Sorry! There are no comments related to the filter you selected.

BREAKING NEWS! (-1, Offtopic)

Anonymous Coward | about 8 years ago | (#16771321)

Rumsfeld is resigning!!!!

Re:BREAKING NEWS! (-1, Offtopic)

Anonymous Coward | about 8 years ago | (#16771361)

I'll be damned. No, not about Rumsfeld, but that an AC posted the news and it's not a troll!

Re:BREAKING NEWS! (-1, Offtopic)

Anonymous Coward | about 8 years ago | (#16771567)

It's a sad day for trolls everywhere

Re:BREAKING NEWS! (0)

Anonymous Coward | about 8 years ago | (#16772097)

If Bush had done this six months ago, the GOP would still have the House.

Voters will be terrified when they find out who they have elected to House speaker--ultra-liberal, "San Francisco values" Nancy Pelosi. Full-on illegal immigration, abortions for all, tax hikes, and more await us.

Re:BREAKING NEWS! (-1, Offtopic)

The Great Pretender (975978) | about 8 years ago | (#16772227)

The pendulum swings

Re:BREAKING NEWS! (0, Offtopic)

GigsVT (208848) | about 8 years ago | (#16772975)

I think you are right, no one actually likes Pelosi. However, Bush and his crew are such extreme fuck-ups, people felt they had little choice but to do anything possible to get rid of them.

Re:BREAKING NEWS! (-1, Offtopic)

FrostedChaos (231468) | about 8 years ago | (#16775711)

We already have abortions for all, and huge illegal immigration.

Technically there haven't been any tax hikes, but we have tremendous deficit spending and tax breaks for the rich, which make tax hikes for the rest of the country pretty much inevitable.

So tell me again what the difference is between Democrats and Republicans? Oh yeah, the Repugs are against pollution controls and gay people. Also the Dems favor some hugely impractical socialized medicine scheme. Don't blame me, I voted for Kodos.

I Really Like Ruby and Rails (2, Interesting)

Zarniwoop_Editor (791568) | about 8 years ago | (#16771383)

I only became aware of Ruby and Rails a few short weeks ago. Since then I have already built my first Ruby/Rails website http://www.f1newstoday.com/ [f1newstoday.com] and it was the most enjoyable experience I've had for some time. The site seems to perform well so far and developing it with Rails was very very quick and easy.

Sure, It's a shameless plug for my site but I'm just so jazzed about Ruby and Rails lately I just had to share.

Re:I Really Like Ruby and Rails (1)

amightywind (691887) | about 8 years ago | (#16771541)

Sure, It's a shameless plug for my site but I'm just so jazzed about Ruby and Rails lately I just had to share.
<b>F1:</b> Nakajima Jr. Lands Williams

Sweet!

Re:I Really Like Ruby and Rails (0)

Anonymous Coward | about 8 years ago | (#16771855)

"It's a shameless...site"

Your missing a proper DOCTYPE [w3.org] in your HTML... shame

Re:I Really Like Ruby and Rails (-1, Flamebait)

Anonymous Coward | about 8 years ago | (#16772603)

if you are going to plug your site, make sure it doesn't have the feel of a mambo canned-template or a geocities generated crap. the design created on my TP after i wiped my ass from my last shit has more style than that...

Re:I Really Like Ruby and Rails (1, Troll)

Shohat (959481) | about 8 years ago | (#16772643)

You just plugged an automated MFA(Made for adsense) site into Slashdot. Congratulations. Moreover J Mark, your hosting company,Superb Internet - doesn't offer Ruby, that is unless you get a dedicated server of course. I think you are a liar.

Re:I Really Like Ruby and Rails (1)

rhizome (115711) | about 8 years ago | (#16772929)

Moreover J Mark, your hosting company,Superb Internet - doesn't offer Ruby, that is unless you get a dedicated server of course. I think you are a liar.

Busted!

I think the best part is the logo with the shadow and reflection. It's like he can't decide between Web 1.0 bubble or Web 2.0 bubble! Use them both!

Re:I Really Like Ruby and Rails (1)

Ford Prefect (8777) | about 8 years ago | (#16773019)

I think the best part is the logo with the shadow and reflection. It's like he can't decide between Web 1.0 bubble or Web 2.0 bubble! Use them both!

Actually, it's the output from one of the GIMP's logo scripts - they're instantly recognisable after a while. ;-)

The good news is that he doesn't have an index.php [f1newstoday.com] , unlike certain other sites [rubyonrails.org] ...

Re:I Really Like Ruby and Rails (2, Interesting)

misleb (129952) | about 8 years ago | (#16774819)

The good news is that he doesn't have an index.php [f1newstoday.com], unlike certain other sites [rubyonrails.org]...


Please note that rails is a framework intended for web applications, not web sites with small bits of dynamic content. So it isn't necessarily damning that the Rails website is written in PHP. Use the right tool for the job. For simple, dynamic content PHP works just fine where Rail would be overkill.

-matthew

Re:I Really Like Ruby and Rails (3, Informative)

Zarniwoop_Editor (791568) | about 8 years ago | (#16773117)

I assume you are accusing me of lying about the site being ruby/rails based?
It's hosted on their cheapest dedicated server ($59), running freebsd, apache with fast-cgi and ruby / rails.
Wasn't really interested in getting involved in a flame war.
Best to be sure of your facts before calling someone a liar.
You are however entitled to your opinion. Truth is I'm really enjoying playing with ruby/rails.

Re:I Really Like Ruby and Rails (1)

Shohat (959481) | about 8 years ago | (#16773595)

I sincerely apologize for calling you a liar. You know , I looked at the packages on the hosting company, haven't seen a .rb file, and it's MFA, so I (probably) made a bad call.
Cheers.

Re:I Really Like Ruby and Rails (1)

Zarniwoop_Editor (791568) | about 8 years ago | (#16773913)

Fair enough. I know the site looks like crap so I can see why you might have come to the conclusion you did. Truth is I'm a coder not a designer, I can't build anything that looks good but the whole site took about 2 hours to build in rails and I'm just kinda impressed at how easy ruby/rails makes building a db driven website.
Cheers.

Re:I Really Like Ruby and Rails (0)

Anonymous Coward | about 8 years ago | (#16775783)

Just a quick FYI: with rails, there never are ".rb" files.

Re:I Really Like Ruby and Rails (1)

tcopeland (32225) | about 8 years ago | (#16772985)

Here's our Rails site: getindi [getindi.com] . Even uses RJS for those thingies in the sidebar, good times. On the backend, Apache 2.2 + mongrel_cluster + PostgreSQL. Good times...

Re:I Really Like Ruby and Rails (2, Funny)

HeroreV (869368) | about 8 years ago | (#16775391)

Good Times!
Any time you meet a payment.
Good Times!
Any time you need a friend.
Good Times!
Any time you're out from under.

Not getting hastled, not getting hustled.
Keepin' your head above water,
Making a wave when you can.

Temporary lay offs.
Good Times!
Easy credit rip offs.
Good Times!
Scratchin' and surviving.
Good Times!
Hangin in a chow line
Good Times!
Ain't we lucky we got 'em
Good Times!

Re:I Really Like Ruby and Rails (2, Funny)

tcopeland (32225) | about 8 years ago | (#16775641)

10.times { puts "Good times!" }

Re:I Really Like Ruby and Rails (0)

Anonymous Coward | about 8 years ago | (#16777967)

Mod parent down for BS. How he have a /. number that low and not have heard or Ruby.... Duhhh!

Anyone Do... (0)

Anonymous Coward | about 8 years ago | (#16771429)

Anyone do an Oggcast on this?

Perl Out, Ruby In - Thank God (4, Interesting)

Anonymous Coward | about 8 years ago | (#16771477)

My god do we love Ruby here in our company. We've been slowly dumping all of our old and messy Perl scripts and replacing them with Ruby versions.

Such a nice clean feeling. There were a few Perl specific libraries that held up the process, but the Ruby libraries have rapidly come of age and I don't know of anything now that would keep someone from completely migrating from Perl to Ruby.

I just cringe when I come across Perl code these days.

Re:Perl Out, Ruby In - Thank God (2, Informative)

archen (447353) | about 8 years ago | (#16771701)

Ruby at it's core is a nice language. I started migrating from Perl (after deciding I didn't like Perl6) about 2 years ago. I just recently became serious about it within the last few months. I think at this point Ruby's main weakness is in it's libraries. I came up with some deficiencies in dbi, but mostly got it working.

Then I started working with cgi.rb . Didn't have any problems until I tried uploading files. What kind of data do you get back? That sort of depends on if your script receives a GET or POST, and if the post is over or under 10k. Also fun trying to detect those objects because it will toss you back something like a Tempfile object even though you haven't "required" it. I was actually really amazed (and pissed) that such garbage could be included as a core library - especially for a language that is supposed to make your life so easy.

Ruby has a lot of work in the library department, and a HELL of a lot of work in the documentation department.

Re:Perl Out, Ruby In - Thank God (2, Insightful)

thejrwr (1024073) | about 8 years ago | (#16771889)

it's new and needs more people onboard thats all

Re:Perl Out, Ruby In - Thank God (3, Interesting)

chromatic (9471) | about 8 years ago | (#16772867)

A language that came out slightly before Java did is new?

Re:Perl Out, Ruby In - Thank God (1)

Paradise Pete (33184) | about 8 years ago | (#16778165)

Wulfram 2 -- Free Online 3D game

I've never understood why this sort of game goes out of its way to use unreadable fonts just to acheive a "look."

Re:Perl Out, Ruby In - Thank God (0)

Anonymous Coward | about 8 years ago | (#16771901)

please quit talking about two years ago. two years ago was two years ago.

Re:Perl Out, Ruby In - Thank God (1)

miletus (552448) | about 8 years ago | (#16772555)

Reading stuff like this is why I'm still sticking with Perl. Sure, it has a syntax which is easy to abuse, but give up CPAN? Not yet.

Re:Perl Out, Ruby In - Thank God (0, Redundant)

bruciemoose (319876) | about 8 years ago | (#16772791)

Not sure why you'd want to use a cgi library directly...

Rails everything! Yes, almost.

Re:Perl Out, Ruby In - Thank God (2, Interesting)

misleb (129952) | about 8 years ago | (#16775399)

Ruby has a lot of work in the library department, and a HELL of a lot of work in the documentation department.


I never really understood the documentation complaint about Ruby (I use Rails, mostly). Most everything I need to know about the core libs is in http://www.ruby-doc.org/ [ruby-doc.org] and http://api.rubyonrails.com/ [rubyonrails.com] is nearly complete. It is no worse than the PHP online documentation. Actually, it is better. I find RDoc much faster to search (CTRL-F). And you can get the first edition of the book, Programming Ruby: The Pragmatic Programmer's Guide online at http://www.rubycentral.com/book/ [rubycentral.com] to get more in depth knowledge of how Ruby works. The IRC channels are very active and helpful (I help lots of people there myself). There is a great mailing list/form at http://www.ruby-forum.com/forum/3 [ruby-forum.com] And there are a million Rails tutorial out there. I learned Ruby/Rails to a point where I could do useful things in like 5 days without any prior exposure with no hassle. So what is missing, exactly?

-matthew

Re:Perl Out, Ruby In - Thank God (1)

archen (447353) | about 8 years ago | (#16784129)

And that's half the problem. Everything documentation-wise you dig up on the web is RAILS centric. And "no worse than PHP" does not make it good. Look at the cgi documentation again (as I'm WELL versed in that example now). You have "how to get a variable", and how to "upload a file". Notice how they don't present you with any examples of textfields AND a file at the same time? I don't need to know how ruby works, I already know that - but I'm finding myself digging through the source code of these libraries to figure out what they're actually doing because they are not working as expected.

Anyone with prior programing experience can learn rails within a day or two. Hate to tell you this but the ruby world is a lot bigger than rails (Not that I find rails documentation to be so awesome either, but it has improved). Less than 10% of the work I do with ruby has anything to do with rails.

Re:Perl Out, Ruby In - Thank God (1)

ShOOf (201960) | about 8 years ago | (#16773115)

There were a few Perl specific libraries that held up the process, but the Ruby libraries have rapidly come of age and I don't know of anything now that would keep someone from completely migrating from Perl to Ruby.

Ruby isn't thread aware, and for anyone trying to host several websites built in Ruby and having to spawn several FastCGI or Mongrels processes per website just so more than one person can access it at the same time. Then you will understand why Ruby still has a ways to go, untill Ruby becomes thread aware and mod_ruby can do what mod_perl can do from the SysAdmin side Ruby is crap.

Re:Perl Out, Ruby In - Thank God (1)

evil_Tak (964978) | about 8 years ago | (#16773929)

Yeah, because until one language is exactly like another, it's crap.

Re:Perl Out, Ruby In - Thank God (1)

Best ID Ever! (712255) | about 8 years ago | (#16774029)

Ruby isn't thread aware

Ruby has threads [rubycentral.com] . Not sure how you got the idea it doesn't.

Wrong kind of threading (0)

Anonymous Coward | about 8 years ago | (#16777501)

Ruby has an internal threading library that works cooperatively. Ruby does not provide access to OS level threads. You are pointing at the former and the previous poster wanted the latter.

What is the practical difference? Well, a lot. Ruby's threads are useless if you want to use more than one CPU. Ruby's threads are useless when you make a blocking I/O call. (For instance if you're running a long database query...) Ruby's threads are useless when calling any library function that is slow.

I don't know what the original poster wanted out of Ruby's threads that they aren't good at. But their non-usefulness for blocking I/O and multiple CPUs are the usual big complaints.

Re:Perl Out, Ruby In - Thank God (1)

ShOOf (201960) | about 8 years ago | (#16784159)

Ruby has green threads, being thread aware means having threads at the system level, the Ruby interepeter can only see it's own threads per that one process.

Re:Perl Out, Ruby In - Thank God (1)

sigzero (914876) | about 8 years ago | (#16774175)

Migrate to Ruby because it is the slowest of them all? Because its threading model sucks? Oh, migrate because of Rails. I tried Rails on a "legacy" Oracle database. Man does Rails suck at that.

Re:Perl Out, Ruby In - Thank God (1)

sigzero (914876) | about 8 years ago | (#16774297)

You have messy Perl scripts because YOU made messy Perl scripts. Perl didn't do that. I happen to write clean Perl code that I can read 6 months from now thank you. Don't blame the language for your shortcomings.

Re:Perl Out, Ruby In - Thank God (0)

Anonymous Coward | about 8 years ago | (#16778111)

Perl code that I can read 6 months from now

Assuming, of course, that you get started right away.

Re:Perl Out, Ruby In - Thank God (0)

Anonymous Coward | about 8 years ago | (#16775139)

I've been coding Perl for a long time and I don't understand why people are so polarized for or against Ruby. The fact is, they are so similar to code in that it seems almost silly to be so pro or con. Sure, Ruby is a "true" OO scripting language, but it's just as easy to write Perl objects. And Ruby is so much newer than Perl that it doesn't even come close to having the modules and libraries available to it. I can find anything I want in Perl. I'm not saying that Ruby isn't a great language, it's just not different enough to get so anti-Perl over.

Ruby! (1)

thejrwr (1024073) | about 8 years ago | (#16771537)

Ruby Seems ALOT like Perl, Atlest to me, anyway lets hope this doesnt flop like other projects in the OSS wild

Re:Ruby! (2, Interesting)

sammy baby (14909) | about 8 years ago | (#16771689)

Perl and Ruby have a lot in common, but they also have some extremely big differences. Probably the biggest is that Ruby is a real, honest to god Object Oriented Language. Perl ain't - it's object support is essentially bolted on. Good if you're not a big fan of objects, bad if you're not.

For a better list of differences/similarities, try here [ruby-lang.org] .

Re:Ruby! (1)

Decaff (42676) | about 8 years ago | (#16772271)

How is Ruby bad if you aren't a fan of objects? You don't have to use it in an OOP manner; you can code procedurally (although that would be a real waste of its capabilities).

Re:Ruby! (1)

sammy baby (14909) | about 8 years ago | (#16772569)

Well... honestly, I don't know. I hadn't thought about it. I like objects. :)

I guess what I meant was, "Good if you're a fan of objects, whatever if you're not."

Re:Ruby! (1)

Decaff (42676) | about 8 years ago | (#16774431)

My apologies; in that case I have no issues with what you said :)

Re:Ruby! (0)

Anonymous Coward | about 8 years ago | (#16781827)

My apologies; in that case I have no issues with what you said :)

What's with all the politeness on /. today? This is /. isn't it?

Don't you guys realise? You are supposed to feel mortally wounded by little details of what the other said, which could be vaguely taken to be an attack on your line of thinking and then you have to attack each other with verbal abuse which quickly escallates into online war!

Come on guys. Do /. proud! Fight! Fight! Fight! Fight! Fight! Fight! Fight!...

(I can't believe that I have actually witnessed two reasonable people run into each other on /..)

Re:Ruby! (0)

Anonymous Coward | about 8 years ago | (#16782035)

My apologies; in that case I have no issues with what you said :)

"Thank you."

"No, no, THANK YOU."

"Oh no! Thank YOU, REALLY."

"Oh, I thank YOU!"

"And I thank you."

"You are most welcome."

"And you are most welcome too!"

(Opens door) "After you..."

"No, no, after you...."

"Oh, no, please; after you!"

"Oh no, I insist: After you...."

"Shall we go through together?"

"If you will permit..."

"Thank you!"

"Not at all; THANK YOU....."


Are you guys both British chipmunks?

Re:Ruby! (2, Interesting)

Cafe Alpha (891670) | about 8 years ago | (#16771933)

I think of Ruby as being more like common-lisp, without the horrible, unreadable S-expression syntax (good as that is for automated code analysis, it's hell on humans). It does have regular expressions though, which I suppose seems familiar to Perl programmers.

Re:Ruby! (1)

ramunasg (973228) | about 8 years ago | (#16772523)

..it's hell on humans

It's hell on some humans. And S-Expressions is not only for automated code analasys, it's syntax very easy (grammar has only few rules) and easy to understand for humans. When I come back to Lisp I never wonder how to write statemens, forms etc.

Basically programmers gave up Lisp not because of syntax, but because they aren't eager to learn new ways of programming. Lisp introduces many concepts weird for avarage programmer used to imperative languages.

Re:Ruby! (1)

I Like Pudding (323363) | about 8 years ago | (#16775199)

Sexp syntax is so dead simple that it is difficult to visually parse.

(big-wad (of stuff (wibble (blargh foo) lambda (foghat) (baz bork bork) bork ))

Re:Ruby! (2, Insightful)

Procyon101 (61366) | about 8 years ago | (#16775731)

(big-wad
    (of stuff
            (wibble (blargh foo)
                            (lambda (foghat)
                                  (baz bork bork)
                                  bork))))

You were misleading by eliminating any formatting. That's like me saying java is hard to visually parse:

class blar:implements boobies{private int foo;private String bar;public boobies(){bar="I'm in ur code. Obfuscating ur lines."}}

Re:Ruby! (1)

Raenex (947668) | about 8 years ago | (#16780867)

Basically programmers gave up Lisp not because of syntax, but because they aren't eager to learn new ways of programming.

Don't discount the syntax issue. When your average programmer has been ingrained with years of Algol-like syntax, coming to Lisp is not easy. And yes, the overload of parenthesis can make the language harder to read, because there are fewer cues to pick up on. Consider that humans work by visually scanning and picking out noticable features: Preattentive Processing [ncsu.edu]

Don't just take my word for it, as an admitted non-Lisper. Read what an industry insider thinks, and why he coded his own "if" macro: http://www.franz.com/~jkf/coding_standards.html [franz.com]

It has been noted that a program is written only once yet read many times. Thus program readability has to be a primary concern of the programmer. It's likely that the person reading your code will have far less knowledge of how you've solved the problem at hand than you have at the time you wrote the code. Thus you must strive to make your code readable by someone with little knowledge of the code.

I've found that the key to readability in Lisp functions is an obvious structure or framework to the code. With a glance you should be able to see where objects are bound, iteration is done and most importantly where conditional branching is done. The conditionals are the most important since this is where the program is deciding what to do next. Bugs often occur when the conditional can't handle all possible cases. If you're planning on extending the function you need a clear idea of the possible inputs it's willing to accept and what you can assert to be true for each branch of the conditional.

Re:Ruby! (2, Informative)

JerkBoB (7130) | about 8 years ago | (#16772037)

Ruby Seems ALOT like Perl, Atlest to me, anyway lets hope this doesnt flop like other projects in the OSS wild

Umm... Ruby has been around for a decade. It's huge in Japan, where it was created. It has gained prominence here in the West because of Rails, but it's a great general-purpose language.

As for its similarities with Perl, I describe Ruby as the lovechild of Perl/Smalltalk. I've made some good money hacking in Perl, but after having discovered Ruby two years ago Perl is just painful to look at, much less program in.

Re:Ruby! (1)

Rotund Prickpull (818980) | about 8 years ago | (#16774097)

Umm... Ruby has been around for a decade. It's huge in Japan, where it was created
I call bullshit. Why isn't it called "Luby"?

Re:Ruby! (0, Offtopic)

lewp (95638) | about 8 years ago | (#16774223)

What a coincidence. I am also huge in Japan.

Re:Ruby! (4, Interesting)

Enahs (1606) | about 8 years ago | (#16772143)

I think once YARV is ready for general consumption, it'll take off like wildfire. They're doing a lot of cleanup, and it'll be considerably faster than the current Ruby.

Once you look beyond Rails, you find it's a great language. Whether it'll overtake Perl and/or Python remains to be seen, but for what little scripting I do on a regular basis, I'd die if I had to use anything other than Ruby.

Re:Ruby! (1)

misleb (129952) | about 8 years ago | (#16775601)

I think once YARV is ready for general consumption, it'll take off like wildfire.


Good luck on that. As far as I can tell, YARV has been all but dead the last few months. I've had the svn repo checked out and have seen very little activity. Very discouraging. I've had to give up using Ruby for a couple projects because of serious performance issues compared to, say, Python. And that is too bad because I can't say I care much for Python.

-matthew

Re:Ruby! (2, Interesting)

Cafe Alpha (891670) | about 8 years ago | (#16778025)

There are alternatives.

I'm starting a project adapting the strongtalk vm [strongtalk.org] to Ruby.

The strongtalk vm is based a very sophisticated new technique called type-feedback, where statistics are taken on the program while it runs, and inlining, specialization and other optimization take placed based on what types are seen to be the common cases in running code.

Probably the most exotic thing the VM does deoptimize running code (for debugging and when the definitions of classes change in a way that invalidates the optimizations), because it actually transforms the activation records on the stack (rewrites the stack!) in order to match the transformation of the object code.

Currently Strongtalk only runs on Windows, and it's not entirely debugged, but it is working and fast. It would need some extensions for Ruby, but even YARV lacks support for continuations...

Another much-better-than-most compiler that I may adapt to Ruby is Steel Bank Common Lisp. [sbcl.org] It runs on all Unix platforms and is the fastest lisp. It's a more conventional compiler than the Strongtalk VM. I think it's optimizations are all static, and so it can't do much with optimizing polymorphic calls, unlike strongtalk, but it's static optimizations are very good.

Re:Ruby! (1)

Hao Wu (652581) | about 8 years ago | (#16778709)

I pray that RUBY will take hold. I pray directly to God, swear blood in oath with my brothers and sons, we must try every thing capable to make it so.

A man with out RUBY is like a teenage waste-land.

Re:Ruby! (2, Interesting)

porkThreeWays (895269) | about 8 years ago | (#16772317)

Ok I know no one is actually going to discuss the book and just discuss Ruby so I'll partake!

I'm going to come out and say it. Ruby is a badass language. Forget Rails. Ruby isn't Rails. Ruby was badass way before Rails ever became popular. It's nice to see a usable, clean language that truly is 100% object oriented. So many other languages claim to be object oriented but are actually a hybrid language (Java, Python, C#). The fact that Ruby's creator had enough insight to weave regular expressions right into the language (via ~ operator) is very important. It's annoying to compile regular expressions and have to deal with raw strings and other gotchas. I like to match with =~ and have it return $1 $2 $3. Object oriented regular expressions still exist and actually ~ is just a shortcut. I also like the convention using exclamation marks for in place modification. So chomp returns the chomp'd argument while chomp! modifies in place. Other languages it can be a guessing game whether it's going to modify in place or not.

All in all Ruby is one of the most fantastic languages I have ever dealt with.

Now for the bad news... While the language design was magnificent, there are pragmatic issues that keep me from using it a lot. I'm going to compare it to Perl and Python because Ruby would be most attractive to that crowd. While the language itself is mature, it wasn't until a few years ago that Ruby was translated to English (the documentation anyway). So even though it's been around awhile, it's only picked up steam recently. This means the actual implementation of Ruby isn't nearly as mature. It's much slower than Python and much much slower than Perl. There are serious projects in place to solve this issue, but as it stands today it's somewhat slow. Also, (and this is the biggest reason) there just aren't a whole lot of supporting libraries out there (compared to Python and Perl anyway). Since it is somewhat new in popularity you can't really assume it's easy to get. So code that has to run on a lot of machines (usually Unix and Linux flavors), it may be a lot of work for them to install it. We have some older Linux and Unix installs, and most have Python and they all have Perl. None have Ruby and very few have a native package available.

But there is hope! All the above mentioned problems are just due to Ruby's youngness. Python was in a very similar situation a few years ago. Ruby has a pretty good snowball it's building. It's immensely better than just 3 years ago, and I think 3 years from now it will have reached mature Python status.

Re:Ruby! (0)

Anonymous Coward | about 8 years ago | (#16780497)

"...code that has to run on a lot of machines (usually Unix and Linux flavors), it may be a lot of work for them to install it."

No, it's not a lot of work. Ruby comes with OSX. And is easy to add on *BSD and most distros of Linux Simply,
$ pkg_add
$ apt-get install

to name a few

Re:Ruby! (0)

Anonymous Coward | about 8 years ago | (#16781937)

Yeah, it does look like Perl, though there are differences. Personally, I think it's like Python created by a Perl programmer, or maybe Perl created by a Python programmer.

It's an interesting language, but we've evaluated it at work and found no logical reasons to move from Python to Ruby. It's slow, a little clumsy, and not as mature as Python for our needs. Ruby on Rails is likewise interesting as a quick rapid prototyping tool, but speaking to others who develop Rails-based websites it can be a bit of a maintenance headache in the long term.

Such a toy (-1, Troll)

Anonymous Coward | about 8 years ago | (#16771553)

Ruby == Toy

Seconded - it's a good, solid book, but.. (4, Informative)

Peter Cooper (660482) | about 8 years ago | (#16772211)

The reviewer is right, it's a good book. It has a few inaccuracies (confusing a TIME server with an NTP server, for example) but generally it contains hundreds of code snippets that allow anyone experienced with OOP or other dynamic languages to pick up Ruby pretty easily. As he says, it's not a 'learn Ruby' book but it could be ideal for those who want to learn without being 'told' what to do.. it's just got hundreds of code examples that are written in the clean, most acceptable Ruby style, and if you can learn from code examples, it's the best book to buy right now.

Be warned, however, it doesn't go into much detail about things like libraries or Ruby on Rails, so it's not a bible to the whole Ruby ecosystem, but for the Ruby language by itself, it's great.

Apple OS X? (0)

Anonymous Coward | about 8 years ago | (#16772565)

... I guess Mac OS X?

My Way (1)

Doc Ruby (173196) | about 8 years ago | (#16772707)

"Documentation". Thus spake Doc Ruby, entirely in pun.

Thanks, Sticking With PHP (2, Funny)

ooh456 (122890) | about 8 years ago | (#16773391)

I am sticking with PHP.

It's the language of the people.

Why?

- PHP has a million free downloadable apps (and 10 good ones).
- PHP has thousands of built-in functions (15 of which I can consistently remember).
- The syntax is great (compared to Perl).
- Fixing other people's PHP code keeps me well paid (if not well laid).

What does Ruby have?

- Good syntax
- Sound principles
- A terrific vision

What has that ever gotten anyone except shot, hanged, or crucified?

Re:Thanks, Sticking With PHP (1)

heroofhyr (777687) | about 8 years ago | (#16775121)

Like most arguments over "whose programming language is bigger," comparisons between Ruby and PHP don't take into account that PHP is meant for the web, whereas Ruby is not (although it can certainly be applied to that platform, but then any language with an output stream and the ability to read environment variables can be used for web development). I'm actually surprised to see how often people use the word "Ruby" when they really should say "Rails." I've never tried Rails, but I use Ruby maybe 2 or 3 hours a week because very often it's the fastest way to do proof-of-concepts and tests on alternative algorithms that I then rewrite in a lower-level language. It's much easier to come up with an idea for a work-related project and then quickly spit out a Ruby implementation of it, make sure it works, and then port it than to do it all in C/C++ first. I had never even heard of it until a year or so ago when one of FreeBSD's automated scripts crapped out due to me moving a directory and not realising it would have any effect, spewed some Ruby exceptions to my monitor, and forced me to take a long, hard look at myself and ask , "What in the hell is 'Ruby' and how long has it been on my machine?" As for the book, I haven't read it and probably won't, although Ruby is the most productive language I've ever used for exploring and testing new ideas, second maybe only to Prolog. I actually opened this article because I was a bit misled by the post and thought it was saying that the book can be downloaded for free from those sites. But I guess I got all excited about the possibility of free information for nothing :(

Ruby is SLOW (-1, Troll)

Anonymous Coward | about 8 years ago | (#16773783)

It had to be said.

mo3 up (-1, Troll)

Anonymous Coward | about 8 years ago | (#16774611)

propaga8da and

Save $5.60 by buying the book here! (0)

Anonymous Coward | about 8 years ago | (#16774989)

Barnes and Noble is selling this book for $31.99, but Amazon.com is only selling it for $26.39!
 
Save yourself $5.60 by buying the book here: The Ruby Way [amazon.com] . That's a total savings of 17.51%!

Is Ruby less popular now, or just less hyped? (1)

walterbyrd (182728) | about 8 years ago | (#16776947)

It seems like Ruby was supposed to take over the world two years ago. Now, I just hear about Ruby once in a while.

Maybe Ruby is a more established language now, so it doesn't get the same hype?

Cheaper on Amazon (1)

Timex (11710) | about 8 years ago | (#16777509)

I found it on Amazon [amazon.com] for about $26.06 US, which came to just under $30.00 including shipping.

Yes, the second edition. :)

more than rails (1)

ErisCalmsme (212887) | about 8 years ago | (#16777911)

I love rails, don't get me wrong... But I think it's about time for people to see that ruby has more to offer than a great web dev framework. There's just so much! Glancing at the table of contents for this book gives you an idea :)

Some dissatisfaction with Ruby (1)

MarkWatson (189759) | about 8 years ago | (#16779355)

From my blog today:

I use Ruby a lot for small database tasks (love ActiveRecord!) and for using Rails for some web applications (not with scaffolding, mostly generating controllers and writing my own code).

That said, for a lot of what I do, Ruby is much more than an order of magnitude slower that compiled Common Lisp. I find myself still using Ruby and Java when appropriate, but for most tasks, I am going back to using Common Lisp. Better language, and the learning curve is not so bad (I have been using Lisp for over 25 years, and I am already up to a 'moderate' level of competence :-)

Re:Ruby! (1)

porkThreeWays (895269) | about 8 years ago | (#16780961)

Ok.... now time for reality. Red Hat 7.2, the last releases of NCR Unix, old versions of SCO Unix, old versions of Sun OS, United Linux 1.0. You know how much work it would be to get Ruby on these machines? You know what the reaction would be if I brought Ruby programs to the admins of these machines? They would look at me like a moron. And I would be a moron for assuming they'd be able to quickly and easily install Ruby on an 8 year old OS.

Re:Perl Out, Ruby In - Thank God (1)

misleb (129952) | about 8 years ago | (#16786153)

*shrug* Whatever. I have done Ruby work outside of Rails and I really have not had any problems with documentation except for specific libraries (usually beta stage). Maybe the CGI libraries are a special case? I don't think the documenation situation is nearly as bas as you suggest. But I guess I'm coming from the Linux world where documentation is generally lacking. Perhaps I am just used to diving into code now and then.

-matthew
Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?