Live data from Hacker News

Hello Ruby – Almost there

blog.helloruby.com

91–100 of 128 posts

Re: Hello Ruby – Almost there

#91
post #80
post #71

Earlier quoted context omitted.

> That's really messed up... No, it's a brilliant use of polymorphism. "null" in Ruby is not a value, it's like everything else an object. So it have methods. Just because you are not used to it doesn't make it messed up.

It's the wrong way to think about organization of logic. It's not a number's place to know how to do looping, it's not an object's place to know whether it's nil or not. Why would every single object have a "nil?" method? You can make it work, but it's just not good style ( and it doesn't serve the purpose of implementation efficiency or machine-sympathy, which I would give exception for). (also, special characters i…

> It's the wrong way to think about organization of logic.

This is not an objective statement, it is one of subjective preference, about which people (demonstrably, by the very existence of Ruby) disagree. The right way to think about organization of logic is not an objective fact, and...

> You can make it work, but it's just not good style

...neither is "style".

Re: Hello Ruby – Almost there

#92
post #22

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 truc…

Is this book actually teaching programming using the Ruby language? It's a pretty fundamental assumption, but I actually can't tell, given the web site.

As far as I can gather, Ruby is the name of the main character, and it explores programming concepts in general, but does not actually 'teach coding'.

I can't actually find the text of the book, though...

Edit: other comments in the thread seem to indicate that it does not teach actual coding, and does not use the Ruby language.

Re: Hello Ruby – Almost there

#93
post #22

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 truc…

I'm sure I can agree that Java, C#, Python, or Javascript are any better than Ruby in terms of difficulty of installing and maintaining the "right" version on your system, or in terms of quirks that are not present in other languages. Python's block definition syntax can be extremely confusing to beginners. Idiomatic Javascript is very difficult to explain to a newbie. And Java and C# are overloaded with so much boilerplate syntax that someone trying to learn the basics gets overwhelmed in the first 10 seconds.

I don't think there's one "right" language to start learning to program in. Different languages appeal to different mindsets and are good at doing different things. There's no limit to what you can accomplish in Ruby, Python, C#, or any other language, so if you find something that works for your brain, go with it.

Re: Hello Ruby – Almost there

#94
post #80
post #71

Earlier quoted context omitted.

> That's really messed up... No, it's a brilliant use of polymorphism. "null" in Ruby is not a value, it's like everything else an object. So it have methods. Just because you are not used to it doesn't make it messed up.

It's the wrong way to think about organization of logic. It's not a number's place to know how to do looping, it's not an object's place to know whether it's nil or not. Why would every single object have a "nil?" method? You can make it work, but it's just not good style ( and it doesn't serve the purpose of implementation efficiency or machine-sympathy, which I would give exception for). (also, special characters i…

The number doesn't know how to loop. `100.times` returns an enumerator that can then be iterated upon. In real code, that particular method doesn't get used all that much, but its existence tells you nothing about Ruby's design.

Why shouldn't every single object have a 'nil?' method? It can be very useful. Think about operating on a collection of objects with `map` or `collect` or whatever your favorite language calls it. No need to write code, just send the `:nil?` message to every object, which you can do with one line.

You're right that "everything is an object" is not the most performant way to build a runtime, but it suits the purposes for which Ruby was designed very well. Just because you don't value those priorities doesn't mean others do not.

Re: Hello Ruby – Almost there

#95

Earlier quoted context omitted.

Installing a program is not too many hoops. You have to setup a computer for ruby too and the kids aren't doing that part.

If I'm on a Mac there is no setup; Ruby is pre-installed. Also, if they are just starting out and they don't want to keep things around there is tryruby.org. For kids using Windows I usually have them sign up for a free account on Cloud 9; again virtually no setup required. Also, now you are trying to compare LINQPad, a tool, to just using a language? In your example you used `Console.WriteLine("Hello World")`, excus…

The kids could also not have Macs and there are similar services for running C# online, so those reasons don't hold any water with me.

What you're argument boils down to is that `10.times.do` is better than `for(int i=0; iNow on that point alone, I'd say that `10.times.do` is certainly easier to parse, but easier is not better. Why teach them a bad habit? Learning `for(int i=0; iI guess you could also say that there is a reason we make things slightly easier for beginners of any age. Like having training wheels. But that is so you don't get hurt and the computer is not going to hurt anyone if the program doesn't compile. I also honestly don't think age matters here after they've been through the second grade.

EDIT: Also, yes, you can leave the semi-colon off in a LinqPad expression. But I also don't see a problem with explaining what a semi-colon is to a second or third grader, in the context of programming. I could also say "good luck explaining those oddly placed periods to those same kids" and it would make as much sense.

Re: Hello Ruby – Almost there

#96
post #84

Earlier quoted context omitted.

> To me that appears to be the strangest way to express a loop in any language I've used (and I've used a lot of them). Well, given that repeating some piece of code N times involves only two "entities", the code to be repeated and the number of repetitions, i see it as a very natural OO design decision to put that looping logic on a method on one of those two entities. The other possibility would be to make the "cod…

If you don't know the type which a name references (or whether it is nil), you have to figure that out before you call any methods on it, in an "external" way. So you have to do " == nil" or "typeof(mything) ==" or "isinstance(mything, type)". This is true for almost every method (except "nil?" in ruby.) Ruby has a lot of these special cases where there's a gimmicky way to do something which is not the general purpos…

This isn't a gimmick or a special case. "nil" is an object of type NilClass, which is a subclass of Object: http://ruby-doc.org/core-2.2.0/NilClass.html

In fact, everything in Ruby is an object. Languages that treat "nil" or "44" as not being instances of a class are the ones making special cases.

Re: Hello Ruby – Almost there

#97
post #70

Earlier quoted context omitted.

I learned to code at age 7 with QBasic, deconstructing Gorrilas in DOS, and later SmallTalk. Both languages are horrible, but were incredibly easy to learn. No one taught me, I played with them until I learned, and back then there was no internet. There are so many aspects of Ruby that make it well suited for teaching kids about programming that go WAY, WAY beyond the ridiculous observations you've made. You might as…

To me that appears to be the strangest way to express a loop in any language I've used (and I've used a lot of them). It also really bothers me that in ruby you can invoke a function on a null value to see if its null (myvar.nil?). That's really messed up...

It only seems messed up because you know about pointers, which are an implementation detail. In an object-oriented language it makes perfect sense. I assume Smalltalk did something similar.

Re: Hello Ruby – Almost there

#98
post #84

Earlier quoted context omitted.

If you don't know the type which a name references (or whether it is nil), you have to figure that out before you call any methods on it, in an "external" way. So you have to do " == nil" or "typeof(mything) ==" or "isinstance(mything, type)". This is true for almost every method (except "nil?" in ruby.) Ruby has a lot of these special cases where there's a gimmicky way to do something which is not the general purpos…

This isn't a gimmick or a special case. "nil" is an object of type NilClass, which is a subclass of Object: http://ruby-doc.org/core-2.2.0/NilClass.html In fact, everything in Ruby is an object. Languages that treat "nil" or "44" as not being instances of a class are the ones making special cases.

The absence of an object is not a special case.

To indicate that with a "nill" object is a special case?

Re: Hello Ruby – Almost there

#100
post #22

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 truc…

I think that for learning basic programming the best language might be Haskell. A lof of people doesn't have in mind that program is "mostly" simple tranformation of data that can be composed of many functions. I think haskell with it's purity and strong type system teaches it fast. REPL helps. But I also believe in educational power of simple C, although it doesn't have REPL or anything like that, but combined with some simple introduction how computer really works - maybe RAM model gives quite an insight. But learning is fastest when you can see cool things happen fastest and I don't think any of 2 mentioned above is good at this. But yeah - for very basics of programming I would rather pick Haskell over Ruby.
Post reply on HN