
Zed Shaw: The wonderful Rob Sobers did a great job translating LPTHW to Ruby - knowtheory
http://ruby.learncodethehardway.org/
======
rsobers
I started off doing this to teach myself Ruby. I enjoyed the Python version so
much and thought it would map pretty well since the languages are fairly
similar.

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.

~~~
extension
I've been working on corrections and I was actually struck by how seemingly
trivial differences in the languages can completely break large parts of the
book. For example, the python version introduces modules fairly early because
they are needed for other lessons. But I don't think there is a single library
dependency in the entire Ruby version. It can't introduce require and then
never use it, but there is very little entry level stuff in the Ruby standard
library. There should probably be a chapter on making your own libraries, but
that would have to be new material very late in the book.

~~~
rsobers
Huh? require is used quite a bit: exercises 12, 25, 43, 47, 48, 50, 52. Some
exercises depend on sinatra, some depend on test/unit, some depend on stuff
you write yourself.

~~~
extension
The problem is it's teaching you Python's module system, which is very
different from Ruby's require system.

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.

------
mikemaccana
There was an unapproved translation before, IIRC. I guess this is out because
the adapter asked Zed's permission first and kept the copyright?

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.

~~~
mestudent
This is probably another unapproved translation as zed said his book was meant
for teaching python and we need substantial changes for ruby.

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.

~~~
mikemaccana
It's approved - check the domain (same as LPTHW)

~~~
russtrpkovski
<http://twitter.com/#!/zedshaw/status/99153296811507712>

------
mikeryan
(side note, there seems to be a page linking problem)

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> ...

~~~
zedshaw
Fixed. I had to move it to ruby.lcthw.org to keep the various languages
straight, but I didn't update the jekyll _config.yml.

------
tomkarlo
Is there a single-page version of this available that I could put into my
Kindle? Alternately, I'd be quite happy to pay for a copy if it was posted to
Kindle Self-Publishing (<https://kdp.amazon.com>)

~~~
vnchr
I wanted one too, so I PDF-printed all the pages, combined them into one file
and also made a Kindle version: <http://bit.ly/o7gfMH>

It's hosted on Rapidshare. I expect Zed will have a better version soon, but
this works in a pinch.

------
tghw
I work with Rob. I always knew he was awesome, but I didn't realize he was
_this_ awesome. Great job Rob!

------
tnorthcutt
Is there a particular reason pagination navigation is not used (e.g. at the
bottom of each page, including previous/next links)?

~~~
rsobers
No particular reason. I'll probably add this at some point since it's pretty
helpful.

------
yoshyosh
I was kind of bummed before that a book with such wonderful reviews was only
available in one language. This is awesome! Thank you guys so much for doing
this :)!

------
marcamillion
Out of curiosity, is Rob Sobers pretty known in the programming community?

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?

~~~
rsobers
I'm definitely not "programming famous." My boss, Joel Spolsky, is though (I
work for Fog Creek Software).

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.

------
BadassFractal
Could someone explain the reason why the "learn x the hard way" method has
been so popular around here? I keep seeing the name thrown around, but haven't
had a chance to look into it yet.

~~~
dimmuborgir
The reason is Zed Shaw. He has a large following here on HN.

~~~
uxp
And it's a pretty decent way to learn some basic programming skills,
irrelevant of the actual language.

------
blackman
I really like the idea behind these books, it reminds me of how I learnt
originally, typing BASIC programs into my zx spectrum from the back of
computer magazines.

~~~
innes
I typed in CBM64 programs - not sure how helpful it was in learning to code
though...

    
    
      2000 DATA 103, 20, 122, 58, 53, 240, 188, 86, ...

[ctd for 8 pages]...

~~~
blackman
i'm sure it was helpful. the first skill in learning how to code is little
details, like making sure all the text is the same as the listing, and that
you pressed enter after every line ... ;-)

------
losvedir
Where is the source for the quote from Zed Shaw? The link doesn't mention it
at all.

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.

[1] <http://news.ycombinator.com/item?id=2846671>

~~~
zedshaw
Zed here, this one is different because Rob asked permission and then did a
great job actually completing the translation. It's not totally idiomatic
Ruby, but it should be a good start for people.

~~~
thoradam
I loved Learning Python the Hard Way so I think I'll do the Ruby version as
well, would you recommend anything specific after it to learn idiomatic Ruby?

~~~
zedshaw
I am not sure, but I'll ask some Ruby folks who might know and then update the
book to point people in the right direction.

~~~
zachallaun
The title _Eloquent Ruby_ has been getting excellent reviews by beginners and
Rubyists alike. And I happened to have loved reading 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.)

------
Apocryphon
This is a great resource. I'm in the process of learning Ruby, and will be
trying out Ruby Koans and Satish Talim's Ruby Learning site as well in
comparison. Does anyone know how good those tutorials are, or if there are any
other good online Ruby guides?

------
foobarbazoo
@zedshaw Would you be up for a Factor version done with the same spirit and
quality?

------
deepcode
Exercise 9:

10 There's something going on here. 11 With the three double-quotes

\- no triple-double-quotes in ruby version, actually

------
nazgob
I would buy it for Kindle!

~~~
kristofferR
Yeah, I would too.

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.

------
chefsurfing
Great thanks Rob!

------
scrrr
It would be nice to be able to copy and paste the code snippets without the
line numbers. Otherwise great job!

~~~
rsobers
The point of The Hard Way methodology is to type everything out and understand
what you're doing.

Having said that, you could clone the git repository, remove the "linenos"
option and run the Jekyll site locally.

~~~
reaganing
Regarding copy/pasting, I do agree. Not much of a point in reading if you're
just going to do that.

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.

~~~
GaltMidas
Couldn't get your way to work, it blew off the rest of the string. Managed to
get it to work by calling .to_s on each variable. Wondering if I did something
wrong. I have your same setup and I'm a complete Ruby Noob.

~~~
reaganing
to be clear, my line 10 looks like this:

puts "There are #{cars} cars available."

But, yeah, complete Ruby noob here as well so I don't really know what's
wrong.

~~~
danso
>10 puts "There are " + cars + " cars available."

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.

~~~
reaganing
Thank you, that makes sense.

~~~
getsat
Interpolation actually calls #to_s on the object, so if
object.respond_to?(:to_s) returns true, you can use use it inside #{} in any
kind of string that allows interpolation.

