
Hello Ruby – Almost there - yorak
http://blog.helloruby.com/post/123541664623/almost-there
======
pluma
I'm not sure whether Ruby is a good intro to programming.

It doesn't have first-level functions, instead it has blocks (which can take
parameters to serve the same use as functions but aren't). What would
syntactically be a reference to a method in other languages instead invokes
the method with no arguments. It doesn't have namespaced imports, instead its
imports effectively behave like includes (i.e. the "dump truck" approach to
imports). I could go on.

Ruby isn't widely used in practice (although its users tend to be vocal and
particularly prevalent in the web startup scene). Installing it requires some
amount of care and technical knowledge (don't even bother installing it with a
Linux package manager -- you're almost guaranteed to end up with the "wrong
version" of ruby and rubygems).

I understand that Ruby programmers tend to be very emotionally invested in
their programming language and that this book is probably written for Ruby
programmers looking to teach their kids programming (using their favourite
programming language) but it would be nice if there were well-written books
aimed at a more general audience.

I'm not sure what the "best" first programming language is. JS has its merits
-- it's becoming increasingly important, can be used throughout the entire
stack of a web application and all you need to try it out is a modern web
browser. Python is a lot more straightforward to learn and has consistent and
mostly unsurprising concepts that are generally very compatible with more
mainstream languages (plus it was intentionally based on a language developed
for beginners). If market use were the main concern you could probably argue
for Java or C# (although I think starting with a class-based language locks
you into the wrong mental model).

In any case, I don't think Ruby is the best choice, even with its quirky
community lore and the general emphasis on "play" and expressing yourself in
code (although this seems to have died down a bit as the community matures).

I guess it depends on whether you want to teach programming as an art form and
toy, or as a general skill (like maths, biology or chemistry). Both can be fun
and entertaining but maybe I'm just getting old and cranky.

~~~
aikah
Well ruby can be written in a very boring way if it's what you don't like :

    
    
         # nobody can say he doesn't understand that code , whatever language he is used to
    
         reducer = lambda {|res,val,array| return res+val}
    
          def reduce(array,reducer,initial)
            res=initial
            for i in 0...array.length
              res = reducer.call(res,array[i],array)
            end
            return res
         end
    
         reduce([1,2,4],reducer,0) # => 7 
    

But there is no perfect language which is a good intro to programming. Ruby
has all the building blocks needed for teaching programming.

And you're pointing namespaces but PHP has the exact same problem. Nothing
prevents developpers from using namespaces in their scripts.

    
    
         #foo.rb
         module Foo
           module Bar
              def biz
                return 10
              end
           end
         end
    
         # main.rb
         require './foo'
         include Foo::Bar
         biz() # => 10
    
    

> don't even bother installing it with a Linux package manager -- you're
> almost guaranteed to end up with the "wrong version" of ruby and rubygems

Because that's not the case for Python or PHP on linux too? I bet it is,and it
has nothing to do with the language itself.

> If market use were the main concern you could probably argue for Java or C#

The course isn't for CS undergrads.

Your opinion but some points aren't fair at all.

~~~
ssmoot
I actually found c# much easier to learn than Ruby. (I learned it before
Ruby).

The compiler helped a lot. It's also a lot more consistent. When I started
Ruby, I often didn't understand why something I wrote worked. That's not a
feeling I got very often from c#.

That's just my experience. But I'd suggest c# is probably a better beginner's
language. Especially paired with VS and an outstanding OOB debugging
experience far superior and more approachable to anything I've ever seen in
Ruby.

~~~
eropple
I write Ruby for my day job (about a year and a half now) and C# for my own
stuff (about ten years) and I'd go with Ruby as a pedagogical language ten
times out of ten. C# is a good (not great, but good) language for building
stuff you want to put in a production environment, but there's so much drag in
the language that I would seriously worry about discouraging novices long
before they get to the point where Ruby would bite them in the ass. C#,
meanwhile, forces a novice programmer to understand types at a fairly deep
level _before they actually know how to make things work_.

Ruby, on the other hand--well, SublimeLinter or equivalent provides detailed
and well-explained warnings if Ruby code doesn't make sense or is potentially
problematic. And while, IIRC, RubyMine offers a good interactive debugger if
you're willing to pay for it, Pry freely offers an interactive REPL experience
at any point in the codebase that, while less mousey, is IMO a better
exploratory tool than you get with C#--you can't just drop into your app, at a
specific breakpoint, and start whacking at things in the shell, it doesn't
work. This is a huge demerit for exploratory programming. And I would gently
suggest, and I'm not trying to rip on you in saying this, that it would be
worth introspecting to determine whether Ruby's perceived inconsistencies were
more on your preconceptions than on the language--because I felt the same way
until I internalized it a little bit and went "whoa, that makes total sense, I
was just looking at it backwards".

~~~
ssmoot
I think you have to understand Types when working with Ruby. Otherwise it's
just syntax voodoo.

That's a big part of what helps a language like c# continuously reinforce a
mental model that leads to better/easier understanding. IMO.

You can call `open` and pass it a URL in Ruby. But what does that return?
What's the Type? Where do I look up documentation for it? What's available to
me _right at this point in my code_?

Ruby makes copying examples a bit easier, but you have to hold _a lot_ more in
your head before you could be considered "proficient".

And then there's all kinds of caveats. You want to write an O/RM in .NET? Pick
up the PoEAA. You want to do the same in Ruby? Well, one of the first things I
did was write DataObjects. Because there isn't a consistent database access
API for you already.

From there you want to map Rows into Objects? Be prepared to play Ruby Golf.
Because your first shot will be unusably slow. Not because it's wrong. But
because it turns out Ruby's performance has real world implications. So you
memoize anonymous classes. You cache method handles. You run a thousand
different micro-benchmarks on the performance difference between re-binding a
cached method handle for a setter, or just calling instance_variable_set.

I think the complete lack of type declarations actually makes developing in
Ruby much more complex. Even experience programmers can end up debating wether
a breaking change between "truthy" and an actual Boolean is a good or bad
thing.

With as much experience as I have in Ruby, `extend` and the self class stanza
are still just _weird_.

Even after developing in Ruby for years I'd still run into code that was just
real difficult to understand how it worked at all.

I guess what it comes down to is I'd argue declaring all your method
parameters as `Object` in c# is not going to make writing working code
_easier_. It may make compiling _easier_ , but that's not really the goal.

It sounds like you're a fan of Pry. I never cared for it personally. I found
it much less intuitive than clicking in the gutter, running my program, and
being able to mouse over a variable to see it's value, or look in a panel to
see the full program state at this point. For a learning tool, I feel like
that's got to be light years better than the solutions I've seen in Ruby. I
managed that in c# without any help at all.

As far as exploring, Types generally tell me all I need. In Scala and IntelliJ
I just hit ^J. Or I'll jump to the source of a method I'm calling with
COMMAND+B. Or the implementation of an interface with COMMAND+SHIFT+B. These
are just things I got out of the daily tips popup.

Seeing a function called: `generateDownloadUrl: Photo => String` tells me more
in less time and space than the equivalent Ruby method or lambda ever did.
Because in Ruby you don't know the requirements until you read the source or
documentation. Whereas in Scala (which I wouldn't actually recommend to a
beginner, but the same is true in c#) you have to resort to documentation or
reading the source far far less frequently. Which for me at least is a much
lower cognitive load.

Because of checked exceptions, switch statements and FactoryFactoryFactories I
probably wouldn't suggest Java. But I think that languages that self-document
the Types at declaration points are much easier to grasp than languages that
still have the types, still require an understanding of them to be proficient,
but omit those declarations (like Ruby). In Ruby you basically have to
memorize a large chunk of the standard library before you feel proficient. The
same isn't really true for Scala, Java or c#.

It's easier to build a mental model (for me) in those languages. And that's
the biggest barrier to understanding and feeling like you grok it (at least
for me).

~~~
eropple
It's interesting that you say all that--because none of that rings true to me.
Quite literally none of it. Even the idea of understanding types is foreign to
me, because I only think of types as collections of messages that objects
respond to and use them only as shorthand for exactly that; like, my yardocs
are full of [#to_sym] as a "type" instead. Things like `extend` are trivial to
me, and I can explain both their semantic behavior and their implementation in
three sentences. I find Ruby fairly consistent and its libraries no more
difficult than .NET--and seeing as how because of plenty of bad decisions you
can't really trust IntelliSense in the first place (like, say, arrays
implementing IList<T> but throwing an exception for Add()), I find myself
Googling no less for the documentation in .NET. And _much, much less_ than in
Scala, though I am very comfortable in that, too.

I'm curious, though. When you say "Ruby", how much of that was outside of
Rails? I don't intend that as an ad-hominem, but rather in the exploration of
a theory that I've had for a while. I am wondering if the approach one takes
to learning the language and the ecosystem influences how much "magic" there
is to Ruby. What you describe sounds familiar from friends and colleagues who
learned _Rails_ , and Ruby incidental to it. I only vaguely know Rails at all,
I don't use Ruby for web applications beyond a Sinatra server as a dumb API.

(And, as I said, RubyMine has a stop-the-world, click-around debugger, much
like Visual Studio. I've only used it once or twice, because the REPL is
comfortable to me, but it does exist.)

------
knivets
Looks great.

Recently, I was trying to wrap my head around eigenclass inheritance
mechanisms and it was pretty tough. Not to mention the object model, where
classes are also objects and the Object - Module - Class relationship. I
wouldn't recommend Ruby as a first language to anyone — it may look easy at
first, but to grasp it, you need to invest much more time in future.

~~~
mikekchar
Sometimes the bias you have from learning programming one way makes it more
difficult to grasp concepts which are different. I recall a study[1] where
they questioned whether recursion is more difficult than iteration if it is
introduced first. Certainly recursion was difficult for me when I was first
learning because I had done a lot of programming using iteration first. It
seems surprising that it may have just been a bias of what was introduced
first.

I think that eigenclasses are a good example of this. Just because of the
languages I learned early on, eigenclasses were obvious to me. I had a hard
time even understanding why they had a name: OO without eigenclasses was just
another way of saying "broken OO" ;-) Again, it's a bias which is hard to be
aware of.

[1] It may be this one:
[http://dl.acm.org/citation.cfm?id=2361296](http://dl.acm.org/citation.cfm?id=2361296)

~~~
e12e
_Eigenclasse_ , had to look that up:

"A hidden class associated with each specific instance of another class."
[https://en.wiktionary.org/wiki/eigenclass#English](https://en.wiktionary.org/wiki/eigenclass#English)

[https://gist.github.com/jfarmer/2625060](https://gist.github.com/jfarmer/2625060)

Yep. Makes perfect sense that if everything is an object, and class methods
belong to a class, and a that class method has to be attached to an object --
you'd need an object to attach it to...

~~~
vidarh
And in Ruby they are only "special" because they have been intentionally
hidden from the publicly visible inheritance chain. Personally I think that's
what makes it hardest for people to grasp.

E.g. if you define class methods on class Foo, all that's happening is that
the class of the object defining Foo is no longer an instance of Class but of
a subclass of Class. But it gets confusing because Foo.class still returns
Class.

------
hopeless
The character's name is 'Ruby' but I don't expect the book itself to be any
sort of introduction to ruby-the-language!

I'm a backer — I expect the book might contain some Ruby code because it's
pretty readable though I'm bothered either way. I am full expecting it'll be
an engaging story to teach my kids some of the concepts of programming, which
have nothing to do with any particular language.

~~~
hopeless
Just to repeat and highlight this: THE BOOK ISN'T ABOUT TEACHING RUBY-THE-
LANGUAGE

I've yet to even find a mention of Ruby-the-language on the site.

~~~
sigzero
Right. It teaches programming concepts with Ruby. It's not about learning Ruby
the language.

------
gregd
What makes you think the book is ready? We've been told (KS backers) that the
book isn't shipping until October 2015. There is absolutely nothing that
you've linked to to indicate that it's ready.

Incidentally the book costs less at retail, then even the lowest tier of it's
Kickstarter campaign.

~~~
sleepychu
It's always really disappointing for me when people see Kickstarting as a way
of purchasing the end product. With economies of scale you should really
expect prices to come down for retail. What you're getting for the money with
a kickstarter campaign is the chance to help someone realise their product,
which hopefully you believe in, without the creative inhibitions that come
with strings-attached funding.

~~~
gregd
You must be disappointed a lot then?

I did believe in her product. What I didn't believe in was an utter lack of
regard to KS backers, poor communication, misdirections, a publishing contract
with Macmillan, a late delivery (while being less than truthful with KS about
it).

The author bears some responsibility for changing my mind from believing in
her product (what you call helping, "someone realise their product") to simply
just wanting the end result of what I paid for at a higher cost than retail.

~~~
sleepychu
I guess my point was two-fold.

1) The end product will probably be cheaper than the kickstarter backing. (You
seem to agree with this, at least in general)

2) People shouldn't see backing a product as a purchase. There's clearly risk
involved in any transaction where the obligation of the seller to provide
anything, let alone meet your expectation of exactly how the end product will
be realised.

It's sucky that you've had such a bad time with this KS though, the real value
in backing ought to be the opposite of what you've experienced!

------
revskill
I found Python's rule of space and tab is the most confusing thing that will
happen to a kid. They open a command prompt, then instead starting writing the
real code, they have to <space><space>, blahblah , <enter><space><space>... to
do something that they hope to run. It's a waste of time.

~~~
Sir_Cmpwn
ipython improves this quite a bit. If you haven't tried it:

[https://asciinema.org/a/2vvs3gg2dk93xizc3splrrfyw](https://asciinema.org/a/2vvs3gg2dk93xizc3splrrfyw)

------
FilterSweep
It's all fun and games until the kids reach a gem dependency conflict that
bundler doesn't fix......

~~~
MrBra
library dependacy problems could happen with any language.

------
_sword
I don't believe the book is ready to ship yet, but I'm looking forward to when
it is! I had the pleasure of working with Linda (author of this book) a few
years back and she is really a wonderful person and I'm very happy for the
initial success of Hello Ruby.

~~~
tern
Ditto, had a chance to meet and work alongside Linda a few months ago and she
has an incredible enthusiasm – looking forward to buying this for my younger
cousins :)

------
staticelf
Cool book, I hope you will get some success with it. I don't have a kid (yet)
but I will maybe buy it as a gift as I live in one of the countries with
publishers.

------
tigroferoce
Cool. Would you translate into other languages? Having kids speaking Italian I
would be interested ;-)

~~~
kevincarter22
Cool. Would you translate into other languages? Having kids learning Haskell I
would be interested ;-)

~~~
tigroferoce
I probably would. I remember once I offered to translate a kickstarter project
for baby girl engineers, so why not a book for baby programmers :-). Feel free
to get in touch if needed.

------
x0
That book is absolutely beautiful.

------
juhq
Torilla tavataan!

------
wyclif
"Its" not "its'", heads up.

