43 ms·
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
by pluma 11y ago
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.
- claudiug 11y agois for kids. I found you post quite strange. Every language has good parts or bad parts. so, because ruby does not have first-level functions is a bad languages, also because does has block is bad. The same for namespace. But let me put it this way. Are you an expert in language design and are you an expert on how children learn new stuff? Or you just don't like ruby as a language. Also, Ruby developers tend to be emotionally. Again very biased against the people that use ruby
- aikah 11y agoWell 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.
- Sir_Cmpwn 11y agoYour example is understandable, but not the norm. Most ruby in the wild is much more esoteric (and that's what you get when googling). >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. I don't know about PHP, but the Python situation is very workable. It's basically just 2 or 3, and you can write code that is portable between them, or better yet - it's not difficult to only use python 3.
- MichaelMoser123 11y agoWhat i don't like about Ruby is that undefined variables can be accessed without error (just like javascript); Python is better in this regard; However pythons indentation think is not so great for teaching intro to programming. i have my own small project - the pooh language; it probably has other features which might annoy some people (downside is that it does not have all these libraries that the grown up languages have ...) http://mosermichael.github.io/cstuff/all/pooh-lan/2012/12/11/pooh-intro.html http://mosermichael.github.io/cstuff/all/pooh-lan/2012/12/11...
- pluma 11y agoI find that Python's indentation is actually useful for beginners. It forces them to format their code and as long as they use an editor which shows invisible characters and can be configured to convert tabs to spaces, they tend to get used to it very quickly. I say that as someone who has repeatedly had to help JS beginners with what I like to call accidental indentation (basically the result of copy-paste and accidental programming -- throwing code at the compiler until it works). Consistent indentation can go a long way for making code parseable by humans.
- nateberkopec 11y ago> What i don't like about Ruby is that undefined variables can be accessed without error (just like javascript) What do you mean by this? Can you give an example?
- cremno 11y agoAccessing undefined/unitialized global or instance variables (like: @i) is not an error and nil will be returned. With -w a warning will be emitted. The weird class variables must be initialized. Local variables (lexically scoped) must be defined and are default-initialized to nil. (Global and class variables are usually not used.)
- yedpodtrzitko 11y agoanother example: > a=a => nil but then: > a=b NameError: undefined local variable or method `b' for main:Object
- 15155 11y agoClojureScript could be decent: easy setup (now), extremely simple primitives, unassuming features.
- foz 11y agoAs someone who has taught several beginners (non-programmers) Ruby, I would say the uptake is good. Teaching at events like RailsGirls, I've had complete beginners start to "get it" and deploy their own websites using Rails and Heroku within a day. My personal experience has been that it makes a great first language, It's very natural to write, and easy to type. You start with super-short examples that are easily understood, using a bare-bones editor. Explaining blocks and iterators is a challenge of course. There's quite a lot of approachable and creative content about learning Ruby out there, which makes it helpful for beginners looking to self-study. Books like "Hello Ruby" are great for kids starting from zero, who need more motivation and fun compared to the "For Dummies" or "From Scratch" approaches. That being said, I agree with your feelings about the language as intended for beginners. However, I tried to teach my 9-year-old daughter Java (using an online course for making Minecraft Mods). And although she was able to get through it, Java is still perplexing. The IDE, strictness and verbosity were overwhelming. Similarly, I tried to teach my nephew Javascript (we made a game together) in a browser. Trying to explain `.this` and dealing with input handling was pretty hard to get through. He didn't take it much further. Re: learning to code... I believe it's not so much about what language you choose to teach. It's about the quality of the course materials, and how quickly the concepts can be understood. Ruby has a lot going for it there.
- mojuba 11y ago> It's very natural to write, and easy to type. You start with super-short examples that are easily understood, using a bare-bones editor. Explaining blocks and iterators is a challenge of course. Same can be said about Python, Swift, JavaScript, Lua, i.e. any high-level language polished and mature enough. And an anecdote for you: my kids tried some of the above, they liked Lua most and Ruby least of all. Why? I guess the question is as complex as why some games are more popular than others, there is no clear explanation to these things really.
- Argorak 11y ago> I'm not sure whether Ruby is a good intro to programming. > It doesn't have first-level functions, instead it has blocks Hold it right there. If first-level functions, blocks and module systems are the first thing that springs to your mind when talking about teaching people with _zero, none, absolutely no_ previous experience with coding, you are speaking at a completely different level. That reads far more like an attempt to discredit a language you don't like then actually caring about the subject matter at hand (teaching coding to kids).
- dopamean 11y agoI taught code at a programming bootcamp for a little over year to people who mostly had no experience programming. For the first 12 months the curriculum was mostly Ruby. I found it incredibly easy to teach Ruby to people and my students were able to build cool stuff relatively quickly with Ruby. I taught over 100 people in that time and the vast majority of them are doing just fine now. Many are programming in some other language (Java, c#, python, js are common ones). Something about Ruby worked for them.
- bigtunacan 11y agoThis is a book for teaching young kids. Trying to start them off with a language like Java or C# would be a terrible idea; not because they are bad languages, but because they have such a high learning curve. With something like Ruby we can start the child right off with puts 'Hello World' Immediately they have a positive feedback cycle. At this stage they don't need to know that a top level object has been implicitly created for them and this statement is part of that object. We'll get to that stuff later. Start off basic with some simple lines of working code. Move up to conditionals, loops, add in methods later in a sort of procedural fashion. Eventually higher level concepts will be introduced. Also to this point of yours, "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)." That is one of those things that comes from someone that hasn't spent enough time with the language. While the treatment is slightly different, the outcome is the same. Ruby supports closures and passing methods to methods. Before you retort with, "But blocks/procs aren't 'really' methods", you might also want to step back and realize that Ruby also allows any method to be passed as well using &Object.method(:method_name); that basically says "Oh hey; pass this method just like a block".
- WorldWideWayne 11y agoSure, C# has a terrible learning curve because you'd have to type `Console.WriteLine("Hello World")` instead of `puts 'Hello World'`. `Console.WriteLine` is also totally unclear as to what it does compared to `puts`, which basically says exactly what it does. /s
- matchu 11y agoThe difference isn't the actual print operation; it's all the boilerplate that has to go around it. In Ruby, `puts "Hello World"` and you're done. The most you have to explain is puts and string literals. In C#, you have to create a class with a static main method. You're then left to choose between explaining classes and methods ("what's static? what's void?"), or skipping that and just treating them as the magic incantation for running a program. Pedagogically, neither is satisfactory. Ruby wins the Hello World simplicity contest, hands down. The question is whether the long-term benefits of C#'s program structure are worth the increased overhead in the Hello World experience.
- rubiquity 11y agoI don't think it's just that Ruby isn't a good intro to programming. I don't think Object Oriented languages are a good intro to programming. OOP is just way too abstract. In the teaching I've done (some adults and kids) they tend to get the basics of FP where everything is just a list much better than the weirdness of objects.
- claystu 11y agoI think objects are intuitive. After all, we live in a world made of objects. What confuses newcomers is the computer science vocabulary that everyone insists on using when teaching objects. I am a big fan of object oriented programming, but the vocabulary and terrible metaphors of introductory books reads like punishment. The only language that has done a worse job explaining a simple concept is Lisp with macros. My God! It's like they're trying to keep Macro's a secret.
- dragonwriter 11y ago> I think objects are intuitive. After all, we live in a world made of objects. We do not live in a world made of object in the OOP sense. (On a more fundamental level, we don't live in a world made of objects at all so much as a world we are prone to arbitrarily -- and not always consistently -- break up into objects for the convenience of thinking about it, but those objects still aren't OOP-style objects.)
- claystu 11y agoYour "OOP sense" is exactly what I meant about confusing things with computer science jargon. To a beginner, treating objects as structs with functions is all they need to know.
- kailuowang 11y agoJS will probably mess up my kid's mind as much as ruby. My choices for intro programming language would probably be Haskell and Coffeescript - both has a simple but coherent set of concepts and a straightforward syntax designed around those concepts.
- fokinsean 11y ago> Haskell seriously? I had a semi difficult time understanding FP a year and a half into my CS degree
- dragonwriter 11y agoI think Haskell -- and FP in general -- is probably easier as an intro to programming than it is for people to pick up after they've been conditioned by imperative programming. Though I wouldn't use Haskell for kids; I don't think the tooling, resources, and compiler error messages are great for that.
- userbinator 11y agoI'm probably in the minority here, but I think that starting with the low level - bits, data representation/interpretation, and logic (which leads to CPU operation) - is the best path to go when starting to learn programming, because it really dispels a lot of the "magic" and mystery behind computers that can confuse beginning programmers when their code doesn't work as they expect. The idea that computers are conceptually very simple and logical in operation, and that any surprising behaviour is really the result of interacting layers of complexity rather than an intrinsic property of the machine, is something that should be firmly kept in mind whenever programming, or even just using, a computer.
- eropple 11y agoI'm sympathetic to this approach, though it's not necessarily the one I'd pick anymore. I think there's real value to understanding systems at this level, and I find that it informs my everyday work. I'm not sure, however, that it's necessarily the best way to get somebody engaged and interested. I'm sure there are personalities that dig this sort of thing (mine does) but loads of people I've worked with or taught seem to be most engaged by the fast iteration cycle of something like a REPL. Personally, that makes me lean towards teaching with Ruby or Python (probably Ruby, as I think it has more to teach). I guess it's horses-for-courses.
- codingdave 11y agoI'm not sure programming is a good intro to programming. It isn't the actual coding, or syntax of languages that trip people up, at least not when first learning. At any age, it is the logic that needs to come first. How code flows, branches, how to work with variables, and build up to more complex structures. It is the same as learning math - you learn how to count to 10, then 100, then start manipulating them via basic addition. Or to read, we first learn the alphabet. For teaching kids to code, first they need to understand the very basics. There are many products coming along that are working on ways to teach these basic concepts to children, using literal blocks in some cases, to give kids a base skill set before ever actually getting into what could be called "code".
- userbinator 11y agoIs something like Nand2Tetris ( http://www.nand2tetris.org/ http://www.nand2tetris.org/ ), but for a younger audience, what you have in mind?
- zoidb 11y agoWhen I was young the paramount thing to consider when picking a language making something cool that my friends/parents/anyone could play with. I could easily share little text adventure games and it was cool enough that I actually got other people to play them.. same thing with TI-85 programs. For this reason I wonder if Ruby will really get kids excited to program but I'm not sure (like you) what the alternative is.
- saneshark 11y agoI 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 well have pointed out the performance limitations of Ruby too. Installing Ruby is as easy as opening a macbook. It's already there. It's not like little kids, learning the language for the first time are provisioning servers and installing from scratch. It's not a matter of Ruby programmers being emotionally invested. It's a matter of Ruby, very often, being the right tool for the job. And for teaching purposes, I don't think anything else comes close. The fact that just about everything in Ruby is an object makes for some very interesting syntactical niceties that a child's mind can easily grasp. For children, the higher level the language, the easier it will be to grasp and remember. It doesn't get much easier than 100.times do Whether or not a programming language has 1st level functions or is production ready is not a consideration most people make when teaching a child. Learning how to code isn't about performance and elegance, it's finding your creativity, perseverance to stick with a problem, flexibility to adapt and change based on new constraints. After all these are the young minds that will be building the higher level programming languages of tomorrow.
- ploxiln 11y agoTo 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...
- byroot 11y ago> 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.
- 11y ago
- hellbanner 11y agoI've gotten several people into programming. I have them start with Python & Ruby. They always think Ruby is simpler and easier to understand. Why's Poignant Guide to Ruby is a great read, too.
- mirceal 11y agooh wow. there are a couple of things here I strongly disagree with. > Ruby isn't widely used in practice. Rails, Chef, Puppet, Homebrew, Cocoapods, Vagrant, Jekyll... The list goes on. > Ruby programmers tend to be very emotionally invested in their programming language. replace Ruby with any programming language and the statement it's true. human beings just work this way. > I'm not sure what the "best" first programming language is This misses the point completely. There is no best first language. People think they have all the answers, when in reality the experience of each individual is unique. Anything that gets you interested in programming / lower the entry barrier is a win in my book.
- pluma 11y ago> Rails, Chef, Puppet, Homebrew, Cocoapods, Vagrant, Jekyll... Most of these are primarily tools that can be used without being a Ruby programmer (even if treating the DSLs as black magic is worrisome). Rails is popular but despite how vocal its users tend to be it's not as widely used as you may think it is. Ruby is disproportionately widely recognized considering its actual "market share" (just like e.g. Haskell). > replace Ruby with any programming language and the statement it's true. human beings just work this way. Different programming language communities are different. I've met plenty of dispassionate PHP, C#, Java and JS programmers. I've yet to meet a Ruby programmer who doesn't hold the opinion that Ruby is the best thing since sliced Jesus, every language should always be replaced with Ruby and that Ruby is pretty damn close to perfect. I haven't met any dispassionate Python programmers either, but they tend to be far more nuanced about their opinion of Python. Heck, the Ruby community came up with Haml so it could pretend to write Ruby when writing HTML, Sass (proper Sass, not the new-fangled more conservative SCSS) so it could pretend to write Ruby when writing CSS and CoffeeScript so it could pretend to write Ruby when writing JS. They even use Ruby for configuration files "because DSLs are easier" (unless you don't know Ruby). Let's also not forget that the reason Codes of Conduct for conferences (and even open source projects) had to become a thing (e.g. the brogrammer culture) primarily originated in the Ruby community (before it spread to others). And also the entire _whytheluckystiff and Zed Shaw dramas. You can fish for equivalents to these things in other communities but the scale and ubiquity is simply exceptional in the Ruby community. Just like PHP is exceptional in how much bad PHP code there is, Ruby is exceptional in what its community is like. > People think they have all the answers, when in reality the experience of each individual is unique. I'm not sure why you think we disagree about this. That's precisely what I'm saying: that Ruby programmers tend to love Ruby doesn't mean it's always the right choice for teaching absolute beginners.
- shostack 11y agoAs an early programmer, I love Ruby. Not just in an emotional way, but rather a practical one. I started out wanting to learn RoR and took a step back to learn the underlying language. What I found was something that read smoothly and just. Made. Sense. Beyond that, community support and overall tutorial quality tends to be very high, which I largely attribute to my continued usage of it.
- sethammons 11y agoFirstly, I think the project looks beautiful. Personally, I just can't stand Ruby, so my opinion will not be balanced. I think the optional parenthesis will be terrible for a new programmer. I think the optional return statement will cause confusion in some cases. The absolute worst is the once or twice I've pasted code into the editor, and when run, I get a cryptic error. Using a hex editor, I discovered that some unicode whitespace got in there and was interpreted as a method or variable. wtf. For my daughter, we started with Python (and bpython from the command line for explorability). She got caught up on classes, but I think that is natural. She is starting to look at javascript now and we will see how that goes. I think both of these are interesting first languages to learn (not without their warts for sure!). For my youngest, we started looking at Scratch from MIT.
- deleted 11y ago[deleted]
- Yen 11y agoIs 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.
- pluma 11y agoCheck the website: http://www.helloruby.com/about http://www.helloruby.com/about I can't find any explicit mention of the Ruby programming language being used as an example, but it's pretty clear that the name of the protagonist is not an accident. The book itself doesn't seem to dive too deeply into actual code, though.
- skywhopper 11y agoI'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.
- claystu 11y agoI would say Python and Javascript are both easier to install--you don't even have to install Javascript--and Python is easier to get coding in thanks to 1) fewer high level concepts that Ruby gets from Smalltalk and 2) Idle. Having said that, Ruby is the superior language to Python once you get going, in my opinion, because of what it steals from Smalltalk.
- machiaweliczny 11y agoI 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.
- yellowapple 11y ago> It doesn't have first-level functions, instead it has blocks Ruby also has lambdas, which if not first-level functions, are pretty darn close. > It doesn't have namespaced imports, instead its imports effectively behave like includes (i.e. the "dump truck" approach to imports). I can't tell if you're talking about `require` or `include`. `require` is strictly meant for loading source files. If you want things to be restricted to a particular namespace, you should use `include` to pull in a particular module (once the module's code has been `require`d or otherwise `eval`d or defined). > Ruby isn't widely used in practice What? Ruby on Rails is ridiculously popular as a web framework. > Installing it requires some amount of care and technical knowledge On Macs and many GNU/Linux distros, Ruby is already preinstalled. > 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 Um, what? The only thing I can think of is a really old packaged Ruby. Otherwise, it's actually pretty hard to go wrong, in my experience having installed Ruby on pretty much every GNU/Linux distro known to man. > but it would be nice if there were well-written books aimed at a more general audience. O'Reilly and Pragmatic Programmers both publish a wide variety of excellent Ruby programming books that are very much "aimed at a more general audience". > I'm not sure what the "best" first programming language is. JS has its merits Oh good god no. > and all you need to try it out is a modern web browser. If that's what matters to you, then you can do the same with Ruby. Take a look at tryruby.org, for example.
- pluma 11y ago> What? Ruby on Rails is ridiculously popular as a web framework. This is the typical HN bias. If you ask someone on HN what framework they think is most popular, they'll likely say Rails. But is this actually true? In comparison to, say, Django or the various node frameworks, sure, it's popular. But in comparison to the "big guys" (the various frameworks for PHP, Java, C#) it barely registers.
- yellowapple 11y ago> But in comparison to the "big guys" (the various frameworks for PHP, Java, C#) it barely registers. [citation needed] [citation needed] especially for C#; the only .NET-based language I know of that registers as even a blip in web development is, for better or worse, ASP.NET. [citation needed] also for PHP frameworks; most PHP web "applications", in my experience, don't use any sort of "framework" at all, instead opting to use CGI with direct manipulation of HTML tags in order to do anything. Facebook is the only significant exception that I'm aware of.
- MrBra 11y ago> Ruby isn't widely used in practice I paused reading to write this: waaat?
- MrBra 11y ago> I guess it depends on whether you want to teach programming as an art form and toy or as a general skill. So learning it as a general skill excludes the notion of art and gaming? What? If coding wasn't intrinsecally A LOT about PLAYING with ideas and concepts and designing them in the most simple/efficient, beautiful and creative way (art) then IT wouldn't have got where it is now. > maybe I'm just getting old and cranky From what you say and how you speak, yes you are. And you are also half conscious about it. You could have reached some kind of saturation point. Maybe you need to do something different for a while and find other stimuli somewhere else.