With the decent success of the last post, why not throw another opinion into the mix?
This is something that comes up every now and again on RubyTalk and other community forums, but it always starts something like this: “Wouldn’t it be great if we could start teaching Ruby in schools instead of C/C++/Java/Forth/Lisp/Fortan/COBOL/BASIC/Brainf*ck?”
A lot of these sadly get derailed. They go into issues about how other languages are more well suited for academic study, and people make a lot of good points about this. Another common thread is that the ‘Ruby way’ of doing things is often going to be wildly different than your more standard solutions, which makes it less transferable. Still, this is only true if you’re planning on teaching Ruby for professional programmers.
What I think would be the best place for Ruby to see the light of day in computer science are algorithm centric courses… Sure, for most of the algorithms, they’ll look similar in almost any language. The difference is, we can focus on things in their proper order. What I mean by that is the most annoying thing about a first or second year college course is that you’re either receiving lectures on ideas you can’t implement because you have no idea how to get a compiler to work, or you’re getting lectured on a compiler and you haven’t covered any concepts or things that actually *mean* something.
So with the success of things like TryRuby and HacketyHack which shows that we can get an environment running in a browser, and at a more practical sense something like the Ruby One Click Installer that gives you a full environment with no work at all on Windows, why aren’t we taking advantages of this for algorithm classes?
As a concrete example, here’s the wikipedia description of bubble sort
procedure bubbleSort( A : list of sortable items ) defined as: for each i in 1 to length(A) do: for each j in length(A) downto i + 1 do: if A[ j ] < A[ j - 1 ] then swap( A[ j ], A[ j - 1 ] ) end if end for end for end procedure
and here's the ruby which looks similar and is real working code
(Don't beat me up for it not looking like good Ruby!)
def bubbleSort(a) 0.upto(a.length-1) do |i| (a.length-1).downto(i+1) do |j| if a[j] < a[j-1] a[j],a[j-1] = a[j-1],a[j] end end end return a end
Sure, you're going to explain some differences. You're still going to need to dig into some deeper concepts such as syntactical correctness and other 'real' issues. What you won't need to do is explain typing, compilers, or a whole bunch of other things that are important, but not in any way tied to algorithms.
Ruby's not the only choice for bringing directly accessible programming to CS students, but it's a fine one. We should take this possibility seriously.
Heck, any one of these RubyQuizzes would make a fine homework assignment, too (depending on the course topic, of course):
I'm interested in people's thoughts on this. Is anyone out there at a University where Ruby is being used for education? How do you see it fitting in? What are your doubts?
I think that it's far more important to get these discussions out in the open than it is to come up with 'one true right plan', so any feedback is welcome.