What Puts New Developers Off Of Learning Ruby?

How Can It Be Overcome?

For a while now I have been spending my Tuesday evenings mentoring people to learn coding skills at Codebar Brighton. Students can bring along their own projects or work through tutorials in HTML, CSS, JS (Javascript) or Ruby.

I’ve noticed that barely anyone wants to learn Ruby.

I’ve been thinking about why this is and how it can be changed.

Ultimately I think its use may not be clear enough, so if you are a Codebar student or aspiring developer and are not sure whether to venture into Ruby development, I hope this helps!

...............

Sometimes in casual conversation over pizza at the start of the workshop people ask me what I do at work. I say that mostly I work with others to build web apps using Ruby on Rails. They ask me what it is and I tell them a bit about it, primarily that Ruby on Rails allows you to control the front and back end of a web application.

Often the difference between Front End and Back End isn't obvious to someone starting out. So incase you are not sure -

Front End - What you can see on the screen displayed in the browser.

Back End - Means that users can submit data into the website and you can store it and do things with it.

To illustrate a bit; you know when you create an account on a website… say Facebook? You log in and you see all your friend requests and messages and a newsfeed and this is personalised for you. If you only had the front end there would be no way of differentiating the content for the viewer because you don’t have a record of who is visiting the site. If a user had to log in and create an account then their information is stored in a database. You can then display different content for each user in the database when they log in.

You don’t necessary need to have a site where a user creates an account for it to have a back end. Say for example if you were creating a contact form and wanted to store their contact info in a database, you would need something built in the backend (‘server side’) to grab that info and store it for you.

So this is all well and good… anyone would agree that this would be useful, but this involves learning Ruby on Rails (or another back end web language and framework). There is still quite a learning curb to embark on from HTML, CSS and front end JS to creating an app in Ruby on Rails (and I mean creating one and understanding what everything does - not generating commands from a  tutorial, though that is where everyone starts).

You (or at least most Codebar students) are already being faced with having to learn how to make things work and look good on the front end with HTML, CSS and JS, you are just about managing that and are then told there is a whole other load of stuff you can do - it is overwhelming. If I say to someone who is really new to coding that I do mostly back end development there is often a reaction of ‘Wow that must be really hard’ but I honestly don’t think it is harder or any more impressive - it's just different. They are both hard. When I buy HTML/CSS/JS templates I think "Wow how did they manage to make this", so I don’t think front end development should be viewed as less difficult. Basically don't pass yourself off as not being able to do it.

I went to a Kickstart Your Developer Career talk by my boss Ali Najaf yesterday and he mentioned that often people shy away from stuff that doesn’t straight away look visually as inviting. You need to use a text editor and your computer terminal to write and run Ruby code and automatically this may put new people off.

To install Ruby you need to run commands in the terminal and if you have never used it there is this fear of “What if I somehow delete everything from inside the computer”. Setting up the environment (aka installing Ruby) can be annoying especially if you are using Windows or an old mac (you need to be upgraded to Mavericks at least). But if all runs smoothly and you are using OS X you should be able to do it by opening the terminal and copy and pasting 2 commands:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew
/install/master/install)”

and then

brew install rbenv ruby-build

I knew this from googling and finding this: https://gorails.com/setup/osx/10.10-yosemite

Using the terminal isn’t too visually inviting at first but as long as you are not copying in commands from old dodgy forums or not being careful with commands that permanently delete files (both of which are going to be a rareity... probably) you will be ok. Mostly the terminal is used for navigating through file structures (check out my blog from a few months back ‘Don’t fear the terminal, a quick introduction to bash’) and entering a command that will run the program, so really not anywhere near as difficult as may be assumed.

So the point in this post now is really to answer the questions: Why start learning Ruby? What even is it and how does it turn into a website?

The main point in disconnect comes I think at this point. Before you build websites with Ruby you kind of need to off-website. HTML, CSS and front end JS are used to create websites, that is what they are for.

With Ruby you don’t have to make stuff for the web. You can write scripts (little programs) that you will run on your computer and do something for you. Often when you are starting out, the result of these programs will be printing (outputting to the terminal) a message - the age old 1st programming example would be “Hello world!”.

You could write a program that copies files from one folder in your computer to another or write a script to calculate and print what the values of £s to euros would be for a number you type into the terminal. You could move on to perhaps making use of an open source library (Ruby gem) to connect to an API and have all of the latest tweets about a certain current topic print straight to your terminal. None of these involve building a website but they are still things you can build to learn how to use the Ruby programming language.

I think the difference between building small scripts in Ruby and using Ruby to make a website may not make much sense to people at first. It might be hard to see how working out how to build a program which figures out the temperature in fahrenheit converted to celsius is ever going to help them achieve their final goal which is probably to make web apps that millions can use.

I can relate to this in that the very first time I was taught programming at uni many years ago and we were taught Java. We had to make a program which printed the results of a student entering money into a vending machine depending on a criteria. At the time I really couldn’t understand why I was learning this and found it really dull. It is especially disheartening if you are struggling for ages to get a result that you are not particularly excited by.

When I started my job I spent the first 3 months learning as much Ruby stuff as I could before I started using it with the Rails framework (for an intro to Rails checkout my screencast below ;) ). In month one I learnt UNIX command line, Git (ok not everything but at at least the basics) and worked through a book called The Well Grounded Rubyist which I highly recommend.

In terms of writing scripts, my boss put together a training program for me. I started by writing tiny programs that copied files from one directory to another and then made a program that wrote output to those files. I learnt how to write my own templating engine in Ruby.

This basically means that I had a directory with html pages in, I then wrote a script that grabbed the content from the pages and displayed that between a header and footer. I then used a Rack ruby gem to serve the site. I then replaced the hand rolled templating with ERB (a pre made version) and then eventually Sinatra (a ruby framework smaller than rails) to do the templating for me so I could see how Ruby was being used within a framework. I think having this incremental approach was very valuable as whilst I was copying files, and outputting stuff to the terminal and other standard stuff I was moving in a clear direction toward what I would ultimately be working on day to day. 

The weird thing is, I thought the further away I moved from writing basic scripts and outputting to the terminal the more I would consider it to be dull, like I had done at the start of uni. In the last few weeks i’ve been making the effort to go over Ruby without Rails (is good to keep refreshing until you think you can write things from memory - which I am still working on) and I am finding it more interesting than ever.

I think over this year my interest has shifted a lot from wanting to output a cool thing to really enjoying designing a program and and wanting to understand the constructs in much greater depth (though to be clear I am definitely not saying that Ruby can't output cool stuff). 

When I first started the job I would read tasks and I literally wouldn’t have a clue how to go about building them and that is where a lot of the fear kicks in (cue wild goose chases through Google), but after a few months of this you start to know at least where in the file structure to write the code (yes even this is a struggle at first) and which components of the language you can plug together to make something happen.

I like the idea of abstracting something happening ‘a piece of the world’ and creating it out of nothing to do something that people can interact with. When you learn basic Ruby constructs (which you don't yet know are linked to building websites) you are given building blocks to help you create and build ideas. I guess the point I am trying to make is to try and remove the block of ‘why am I learning this?’ and rather than focusing on the output which could be something boring like “Hello world” think, how is that happening? How can I use this to do something else? What could I build from that? There is always so much more to learn but the foundations will always be the foundations so even if it does take you ages to write a script to copy a file, I assure you the reason why you are doing it rather than just dragging in the finder will make sense in due course so don’t be disheartened.

Putting time into learning Ruby will ultimately mean that you can learn about object oriented programming for which knowledge is going to be transferrable in learning loads of other languages including Java, Python, C++ and C#. It will also mean that you can create the HTML, CSS and JS front end within an app but also expand it to be able to handle user input, creating infinite possibilities.

Over the next few posts I will write about some Ruby constructs that I think are useful to learn/that I need to refresh on, but I wanted to write this so that if you are maybe wanting to learn 'back end' web dev but are not sure if it will be too hard, or a Codebar student who is not sure why they would learn Ruby then this gives a bit of a better idea of what it is. There is a brilliant Ruby community online and offline and tonnes of help available so brave the installation, buy a book and get started!