#52WeeksOfCode Week 7 – Ruby on Rails

Week: 7

 

Language: Ruby on Rails

IDE(s): TextWrangler

Background:

Wait a minute, didn’t we talk about Ruby back in Week 5?

Well, yes. But this isn’t so much about Ruby as it is about Rails. Though programming in Ruby is pretty friendly, creating a Web service traditionally is not. Rails is a software framework designed to bring the friendly nature of Ruby to Web programming.

Discussion:

Should everyone learn to code? This is a question I’ve seen pop up in the past but with projects like Code Year, Hour of Code and Code for America, it’s getting more attention these days. Given how Depending on what point in my career that you asked me this question, my answer would range from ‘yes’, ‘no’, ‘who cares’ and ‘maybe’. At this point I think it’s kind of complicated and I plan on addressing it in future.

For now, though, I’d like to talk about the resources for learning how to program.

“Programming is, among other things, a kind of writing. One way to learn writing is to write, but in all other forms of writing, one also reads. We read examples—both good and bad—to facilitate learning.”

Excerpt From: Gerald M. Weinberg. “The Psychology of Computer Programming: Silver Anniversary eBook Edition.” iBooks. https://itun.es/us/H5erA.l

I first learned how to program back in 1977. The language was Fortran and

we wrote our code on punched cards. (And no, I didn’t have to walk to school barefoot through a blizzard, uphill both ways, in case that was your next question.) Personal computers were just being introduced at that time and they were strictly for hobbyists. The way you learned to code was either through taking a class (as I did) or through self-instruction. Either way you needed to read a lot of other people’s code.  If you were lucky enough to get unfettered access to computer time (not an easy thing back in the days of mainframes) you could just try out code and see what happened.

The USENET discussion board system came online in 1980 and with it you could connect with other programmers and hobbyists, trade code, ask questions and share experiences. But it still came down to reading other people’s code, looking through books and trying stuff to see what worked.

Cut to today.

Each week I do research on the language or framework I’m supposed to use and so far I’ve been very impressed by the sheer volume of openly available information available online. Not only that but that some people were doing some innovative things with online education. Here was the sequence of my training:

  • TryRuby.org – This site provides an interactive tutorial that lets you try out Ruby code in your Web browser with no additional software required. It’s a little slower than doing it ‘natively’ but it’s very well done and quite handy. There is a similar site for Haskell that I referenced last week.

  • Rails for Zombies – A very clever tutorial hosted by Code School, a site that specializes in offering online training for programming students. They have some free content (Rails for Zombies, for example) but to get access to all of the content requires a monthly subscription. This was an excellent example of the active learning style of instruction. The student watches a short instructional video and then is presented with series of programming challenges where they get to apply what they’ve learned. If they succeed, they earn ‘points’ and move on to the next level. (The overall goal is to code a version of Twitter to be used by zombies). You can download a copy of each video along with the presentation slides (in PDF form) if you wish to have them for reference. Hints are available but if you use them too much, you lose points. The combination of short, targeted lessons with an amusing back-story and the overall gamification of the lesson made this a lot of fun while still giving me a good background on Rails.

  • Getting Started with Rails – This is where it all came together. While you might think that this is where I should have started, I don’t think I would have done as well if I hadn’t covered the material in Rails for Zombies first. Once again, this site provides a decent but not excessive amount of hand-holding while it walks you through setting up a simple web application. Each step adds a bit more and since at any point you always have working code, it’s easy to figure out what happened if something goes south on you. This is hosted by the main Ruby on Rails community site and also contains screencasts, documentation, other tutorials and other links to connect up with other Rails users.

I’m not suggesting that we ditch traditional learning and move everything online. However, there are many different learning styles and I’ve found that you need to push knowledge out over multiple channels for maximum effectiveness. But a Web page is not the same as a textbook and a video lecture is not the same as an on-ground instructor.

That’s why I’ve been pleasantly surprised to see so many online instruction providers ‘giving back’ by providing resources for teachers as well as students. Code School, Khan Academy, Wolfram Alpha and others all provide materials and tools for the traditional classroom.

Epilogue:

My web application this week continues with my tradition of doing goofy things with the classic “Hello World” program. This time I built a web application that allows me to post different versions of the phrase “Hello World”, along with the language used. Here’s a screencap to show you what I mean:

It’s very silly but it was easier to build than I expected and I had fun. If you’re interested, here’s a link to the code. (You’ll have to install Ruby and Rails in order to run it.)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s