From: Francois Paul Date: 2005-11-23T19:03:15+09:00 Subject: Re: teaching ruby as cs intro? Hi Mike, maybe you could give them a small example of the concise nature of ruby by writing a small java program and then rewriting it in ruby? for example: On 10/11/05, Florian Frank wrote: >> junk5@microserf.org.uk wrote: > > >> If you start to learn programming, it's important to go step by step >> from easy concepts to more complicated concepts. In Ruby this can be >> done like this: >> >> puts "Hello, world" >> ^-- command ^--- string >> >> Easy: "puts" is a command that puts a string out on your console. >> >> Only later you tell your student about classes, methods and the whole >> OOP-Zoo. >> >> Now look at Java: >> >> public class Hello { >> public static void main(String[] args) { >> System.out.println("Hello, world\n"); >> } >> } >> >> You have to explain a dozen foreign, arcane and (at least to the >> beginner) useless concepts, only to output a string on the console. >> >> Next step in Ruby: >> >> name = gets >> puts "Hello, " + name >> >> "gets" gets a string input line from your console, which is assigned to >> the variable name. Then the string "Hello, " is appended to the string >> referenced by name with the "+" operator, and the resulting string is >> put out on the console with the old "puts" command. >> >> Now compare this to Java: >> >> import java.io.*; >> >> public class Hello2 { >> public static void main(String[] args) { >> InputStreamReader isr = new InputStreamReader(System.in); >> BufferedReader reader = new BufferedReader(isr); >> String name = null; >> try { >> if ((name = reader.readLine()) != null) { >> System.out.println("Hello, " + name + "\n"); >> } >> } catch (IOException e) { >> System.err.println("Caught: " + e); >> } >> } >> } > Mike Schwab wrote: > My school teaches intro to programming with Java or C#, intro to cs > with Scheme, then requires two semesters of C to scare us into being > good and careful. Learning about Ruby has been a way nicer > experience and I think it would draw more kids into the major if it > was taught early on. What do you think? > > Here's my draft of what I'm sending to the Teaching and Learning > committee. Suggestions welcome. > > Professors, > > Ruby is a very powerful, very concise and readable, and I think very > easy to learn language. You should seriously consider teaching this > language at an introductory level. It combines the flexibility of > scripting languages, the modularity of object-oriented languages, and > the recursive/iterative chaining of functional languages. Perhaps it > would be overwhelming to present all these capabilities to young > students too quickly; nonetheless there's enough documentation on the > web that motivated students could move beyond the problem sets and > start writing their own useful apps within their first semester (Ruby > is also rather addictive). There is an interactive shell (invoked by > /$ruby eval.rb ), so students would get instant feedback during their > initial debugging that would really help them quickly straighten out > their mistakes. > > While it doesn't run fast enough for every application, Ruby saves > quite a bit of programmer time, and it's concise nature makes it > simple to maintain. The community is very agile and develops > programs at a surprising pace. Often these releases seem to have a > very modular nature that allows them to be incorporated usefully into > other apps, so in other words, the time-saving capabilities of using > Ruby are great and increasing. I cannot wait to see what libraries, > software, and websites are available this time next year (hopefully > by then I'll be able to understand all their code too). Along with > lessons on theory, syntax and conventions, I suggest that you offer > some lessons on checking documentation and wikis, and installing and > using libraries. In fact, many wiki pages might be well-written > enough that you could lecture right off of them, reducing the burden > of preparation (also, if the lecturer ran across a question she > couldn't answer, she could post to the Google group comp.lang.ruby > and probably have an answer before the lecture was over). This > combination of simplicity, facility, documentation, and human > explanation is something Yale students could use to great benefit in > the coming decades, whether or not they take additional CS classes. > > I encourage you to investigate Ruby for your own uses - you may find > that it plays very nicely with the codebase you already have. I hope > you and your students will find it as useful as I have. > > -Mike > > http://www.rubygarden.org/ruby?RubyIdioms <- a taste of Ruby > http://www.ruby-doc.org/docs/ProgrammingRuby/ <- a free textbook > (newer version available) > http://www.ruby-forum.com <- discussion of real-world uses > http://www.zenspider.com/Languages/Ruby/index.html <- papers from > Ruby conferences > >