Zed Shaw: The wonderful Rob Sobers did a great job translating LPTHW to Ruby
ruby.learncodethehardway.org
ruby.learncodethehardway.org
After about 15 exercises, I saw that it was actually coming out quite nicely and reached out to Zed. Zed was super cool about releasing it under his license as long as the end result was high quality.
I wouldn't have cared if he said not to release it because I got to learn Ruby and play with Sinatra, Jekyll, etc.
Ex. 12 introduces `require` with example code that is way over the reader's head at this point in the book, and unrelated to anything they have seen or will see until ex. 25. It also says that features are called "modules" but that's completely wrong -- Ruby modules are something else entirely. And the term "module" is used in the Python sense all over the book. All those need to be changed.
Ex. 25 asks the reader to require their own file but never explains how to get the file in the load path, so I don't think the reader has much chance of completing this exercise.
My point is that I don't think a direct per-exercise translation is going to work. Requires in Ruby are more complicated and used less often than modules in Python, and the book is very linear, so I think require will have to be introduced in a completely different way if it's going to make any sense.
There are other topics that have this problem, like heredocs. In Python they are pretty so it's ok to throw them at the reader early on. But Ruby heredocs will melt their eyeballs out of their sockets, and they are rarely used in practice, so they probably shouldn't be in the book at all.
I am working on these sorts of changes with the intention of sharing them with you to see what you think, but it's starting to snowball so I don't want to promise anything. I'll do my best.
If so, I'm cool with that. Zed can be a firestarter, but this shows he's cool with others contributing something provided they do it the right way.
The other book basically translated the code from python to ruby while keeping much of the text the same I don't know if this is the case with this one.
I don't know at that point what you mean by "unapproved"
http://learncodethehardway.org/
Also, from the linked page:
The prose in this translation is nearly 100% identical to the Python version with the exception of a few paragraphs that have been modified to be relevant to Ruby. All of the code exercises and required libraries have been completely adapted for Ruby. In other words, Zed did all the really hard work.
This isn't quite idiomatic ruby, but I think it'll be a good kick-starter for someone who knows nothing, and I'm looking to get people to help mold it to be better.
Edit: nvm, it's here folks:
https://gitorious.org/learnrubythehardway/learnrubythehardwa...
Cheers!
Clicking into http://ruby.learncodethehardway.org/intro.html and hitting the title takes me here http://learncodethehardway.org/ruby/
Clicking a link there takes me to http://learncodethehardway.org/ex00.html
It looks like that header should link back to http://ruby.learnruby ...
It's hosted on Rapidshare. I expect Zed will have a better version soon, but this works in a pinch.
I have never heard of him before, but based on the way Zed wrote about him, seems that he just might be famous and I haven't heard about him (which is very possible).
Otherwise, if he was just a 'regular' web designer that learned Python the Hard Way and translated to Ruby and Zed has given him so much credit....that would be AWESOME.
In all honesty, quite uncharacteristic of Zed - as far as I know, not being a dick (just honest) - which is why I think he is 'programming famous'.
I am hoping he was just a regular 'joe blow' though.
Anyone know?
I don't know Zed personally either. He was a bit skeptical about me doing this at first, but he was ultimately really cool about it because I respected his terms, and if at any time he told me to ditch the book, I would have.
Considering that's exactly where I was, it was perfect for me.
He shows you how to do everything...once.
ZX Spectrum rocked my world in my childhood :-)
2000 DATA 103, 20, 122, 58, 53, 240, 188, 86, ...
[ctd for 8 pages]...I know Zed Shaw railed on a previous translation to Ruby; I'd be curious to know the backstory here about why this one is different.
edit: Nevermind, in a different HN thread[1] Zed talks about it.
It is basically a book of best practices and ruby idioms. (For example, the use of a ruby object's each method instead of for..in.)
10 There's something going on here. 11 With the three double-quotes
- no triple-double-quotes in ruby version, actually
But Zed, please check the Kindle version before you approve it. The Python book for Kindle is absolutely horrible - with all the code stripped out.
"You must type each of these exercises in, manually. If you copy and paste, you might as well just not even do them. The point of these exercises is to train your hands, your brain, and your mind in how to read, write, and see code. If you copy-paste, you are cheating yourself out of the effectiveness of the lessons."
Having said that, you could clone the git repository, remove the "linenos" option and run the Jekyll site locally.
But, I was having a problem with exercise 4 and so copy/pasted it from the webpage (removed line numbers with TextMate's vertical selection easily enough). Received the same error when trying to run it as I did when I typed it myself:
ex4.rb:10:in `+': can't convert Fixnum into String (TypeError) from ex4.rb:10:in `<main>'
I'm not familiar enough with Ruby to understand why it's doing that... my googling shows similar ruby tutorials with that format, but one site I found suggested using #{variable_name} instead of the " + variable_name + " and that worked just fine for me.
Is this a real error in the book or something weird going on with my computer (OS X Lion w/ Ruby 1.9.2 installed)?
Great book, by the way.
puts "There are #{cars} cars available."
But, yeah, complete Ruby noob here as well so I don't really know what's wrong.
Yes, this will throw an error in Ruby because of line 1:
>1 cars = 100
Ruby does not allow the mixing of integers and strings. So, as mentioned, you can invoke the .to_s method. Or you can interpolate the variables as you have done so with #{cars} inside double quotes.
This seems to explain it: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/...
In hindsight, I probably should have used "Hello #{name}" style string interpolation in all of the examples since thats the idiomatic way of doing things.
I was trying to expose the newcomer to multiple ways of manipulating and concatenating strings, but since the aforementioned way is almost always best, I should stick to that.