Learning Ruby, and Ruby-vs-Lisp
netzhansa.blogspot.com
netzhansa.blogspot.com
Ruby 1.8 is interpreted, in the classic sense. Ruby 1.9, the current production version, 'compiles' to bytecode internally. TRPL was written when 1.8 was still the production version of Ruby (although it does cover most, but not all, of 1.9's syntax). Also, JRuby's JIT works well and typically yields better-than-MRI performance after a short running time.
The lack of a formal specification and the ugly grammar put me off.
It's not entirely complete yet but a formal specification, targeted for ISO, is on the way - there's a 300€ PDF floating around somewhere ;-) Due to the length of the process, it focuses on Ruby 1.8 for now, I believe. More interesting, however, is the http://rubyspec.org/ project, but the MRI core team's engagement with it isn't strong from what I've heard.
And while Ruby certainly has its warts, calling the language "ugly" is like calling a Mercedes ugly when parked next to a Ferrari ;-) Lisp's syntactic simplicity is certainly beautiful but compared to mainstream languages, Ruby fares well.
I can see the appeal of Ruby, but there seems little it has to offer to me that Common Lisp cannot provide.
Certainly. That's a good thing. If you can be more productive with Common Lisp, its ecosystem suits you, and you're not a huge OO nut (which I'm inferring), there's nothing particularly compelling about Ruby. For certain folks though, including me, Ruby has significant advantages in many areas.
But I agree that Ruby is a very good language.
I got tired of the duct-taping and syntax, then rewrote it in Lisp. Almost no problems comparatively. I'm wholly certain if I was a Rubyist coming in, the issues would have been transparent.
The post reminded that Ruby is interesting language having many merits.
But your about "rubyspec" reminded that ZS is correct that Ruby is also chock-full of BS artists. Rubyspec is a test suite - Lol. Whatever the merits of test suites, they aren't formal specifications, they shouldn't pretend to be test specifications and the people who pretend they are such are, uh ... BSing.
"Test Driven Development", meaning writing your tests as some kind of specification, is total crap. Tests aren't abstractions that get you anywhere. They are just tests and writing tests first only in systems so simple they probably don't need much testing or design anyway...
Also, Ruby expressions may not be ugly but "Ruby Syntax", as a BNF expression is super-ugly even compared to other mainstream languages.
My biggest gripe with ruby is that unlike most other languages its development is rather opaque unlike say python. I think this has to do with the primary group being Japanese.
http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_... looks to be the current status of the ISO standard, found a draft version but its in japanese, severely limiting what I can glean from it.
http://www.wiki.ruby-standard.org/index.php?title=Main_Page&... looks to have been part of the standardization process but hasn't been updated for years.
But yeah TDD is pretty heavily promoted, but primarily from the rails side of rubyists. I've used ruby for 10 years, only just now made a gem with tests in it, mainly to see what all the rage is about. Is it nice? For some things yeah, but not entirely necessary, I agree with Rich Hickey, only throw up guard rails where accidents will occur. Don't hit them all the way to the store.
Sorry for the rambling, back to my cage.
Perhaps someone else has a different view?
But yeah, marketability notwithstanding, I slightly favor Lisp.
I would expect any adroit HN reader to be comfortable in a programming language after 7 years :) What is odd is that you say "most of the syntax". Would you please elaborate (aside from what you said about function creation/passing)? I like ruby, but I'm not to the point where the syntax falls into place as easily I wish it would.
Personally I had a hard time remembering the difference between Procs, blocks, and lambdas in Ruby, though I believe this is partly due to the fact that the differences shifted in minor point releases.
- No keyword arguments
- No good syntax for creating pure functions
- Metaprogramming seems tacked on
- HERE doc manipulation is atrocious
- There is no 'fundamental unit' of a Hash
(other than a destructured key-value pair),
so mapping a function onto hash keys or values
is always a call to #reduce or a Hash[array]
- Creating a Hash with #reduce is not pretty
- Destructuring isn't so sophisticated
- Local variables become defined even if they aren't in your
current code path
- I already mentioned method passing
These are all things, by the way, that Clojure does much, much better.I wish I had learned it with this book by my side. I consider it one of the best introductions into the language and how to write idiomatic Ruby.