4 ms·
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 cl
by knivets 11y ago
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.
- Argorak 11y agoPeople can get very far without knowing anything about that.
- amencarini 11y agoWe are talking about a children's book, I don't think a reader of this book will have to maintain large codebases for a job anytime soon. Incidentally, Ruby is great for beginners thanks to its expressiveness.
- mikekchar 11y agoSometimes 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
- agumonkey 11y agoWhat troubles me the most with the iter/rec debate is that iteration is so trivial for most, but then many problems look intractable. Recursion feels awkwardly void, empty, almost nonsensical, but when you click your horizon broaden dramatically. That said, I still fail to recognize recursive patterns far to often.
- e12e 11y agoEigenclasse, 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 11y agoAnd 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.
- bhaak 11y agoThese are advanced subjects and even a proficient programmer doesn't need those very often. The advantages of Ruby as a first language IMO are that it is a pure OO language. No special cases, no unnecessary boilerplate. Much better than Java in that regard. But you could argue if nowadays you still need to focus that much on OO. I'll be interested on the book turns out. Usually, I wouldn't recommend a generic programming language as a a first language for kids. I would use something with turtle graphics and a REPL.
- mieko 11y agoI think, day-to-day, the Ruby object model can be as simple or as complex as you'd like it to be. Most dynamic or static OO languages have just as much complexity under the hood (vtables, doesNotUnderstand, metaclasses, etc). It has to be complete anyway, so it's made accessible, for better or worse. I think you're more likely to run into it in the wild in Ruby because it's better exposed than most languages. When you see reflection or meta-object APIs in a lot of (typically not-as-dynamic) languages, it's sort of a "HOLY FUCK, WATCH OUT, I'M METAPROGRAMMING" flag. In Ruby, it's easier to daintily follow the white rabbit into the object model and care about the relationships you're referring to. But on its surface level (class keyword vs. Class.new, def vs. define_method), I don't see it being any more complicated than similar dynamic languages. When you say "puts 1+1" in a blank file, I can't imagine that not grasping that you're in a binding of an anonymous singleton instance of an Object named "main" being an hindrance. What's cool is, if you need to know, there's not a weird brick wall in your way.
- atmosx 11y agoThese are the advance features. You are not required to know how inheritance works (or what the Singleton is) to write runy code. You dont have to use OO design or anything. You can write procedural code in ruby if you want. These advanced fratures are used mostly in metaprogramming. Ruby is like the guitar: easy to learn, hard to master.
- hnmodturds 11y agoSeems a shame to damage the kids learning by introducing the clusterfuck of a language such as ruby. gem install learn_a_better_language