In the latest installment of our trainer’s blog we interview Kris Leech of Interkonect, who has written and will deliver our new Ruby programming and Ruby on Rails courses.
Can you give a potted history of your coding career?
1987
I started programming BASIC on an BBC Acorn Electron. Something like:
10 print "Kris is Cool "
20 goto 10
1989-1993
After this I remember getting a Commadore 64 and later an Amiga 500 although to be honest I mostly played games until I got an PC (486 with a Turbo button!) running MS-DOS. I picked up BASIC again, this time Microsoft’s QBasic. This was my first exposure to a debugger and the game Gorillas.
1995
Shortly after the move from DOS to Windows PC’s became more affordable and appeared in libraries, cafes and schools. I briefly dabbled with C before being introduced to Borland Delphi (Object Pascal) version 4. This was my first exposure to an Object Orientated language. Shortly afterwards I got some work programming desktop applications before finishing my A-Levels in 1998.
2000
Within the next few years the Internet became more affordable and I started developing simple static websites using Macromedia Dreamweaver and Fireworks for local businesses.
My natural progression was to pick up PHP and start developing dynamic websites. I did this for many years of web development using PHP like many people blissfully unaware of HTML/CSS standards and best practices in web development. By necessity I also started to get involved in Linux server administration such as installing packages and configuring Apache.
2004
It was only much later that blogs started to become popular due to open source projects such as WordPress and posts on separation of data (HTML), presentation (CSS) and behaviour (Javascript) caught my eye and a light bulb was illuminated.
This somehow led me to my most exciting discovery to date, the RubyOnRails framework.
I think the first exposure to RubyOnRails was a short video of pre-release Rails where someone, presumably David Heinemeier Hansson, generated a scaffold application which talked to the database and generated HTML allowing you to create, edit and delete records. Pretty basic functionality but what was impressive was it only took a few minutes to complete.
So now I’ve been working with Rails for around 5 years and have no doubts I made the right choice.
What was it about RubyOnRails that appealed you?
At the time I mostly hashed together PHP code, HTML and SQL with no real structure. The most abstraction I managed was putting the database connection code in a separate file. I was not aware of a better way to manage my code base so larger projects quickly became unmanageable. This was not a consequence of using PHP but of the standard practice within the PHP community. Because code was being developed in a ad-hoc manner it made working as part of a team near impossible as each developer had their own way of doing things, there were no conventions and no coding standards. This didn’t make very good business sense. Projects were costly in terms of time and estimation was difficult in the first place. This uncertainty never inspired much confidence from prospective clients. Because one person held the knowledge needed to fully understand the code base development needed to stop to get a new developer up to speed. Not only that a completely new team could not inherit the project months or years later when the original developer may have moved on.
RubyOnRails changed this, it is a framework. A solid foundation on which to build. Everything has its place. It is modular and works out of the box. I could pick up a Rails application, even a complex one, written by someone else and completely understand it without any supporting documentation in a relatively short amount of time.
Rails abstracts away all the mundane, repetitive jobs that are common to building web applications. This really appeals because not only is coding more enjoyable but you are much more productive. You could get something up and running really quickly. It allows you to concentrate on the unique and challenging aspects of a website. I can show my client a working prototype in a few days instead of a few weeks and respond to change early on in the project.
This was also my first exposure to the highly expressive Ruby language in which Rails is written.
Has selling Ruby/Rails to clients been difficult?
Businesses don’t tend to be interested in which technology you use to develop their website, they are more sensitive about budget. Using Rails enables you to outperform your competitors in terms of time/budget and bonds well with the values of Agile project management techniques such as delivering working software early and often, not only responding to changes in requirements but embracing them. It is the features of Rails which bring these benefits.
Also I’ve done a lot of sub-contractor work for web design companies. They tend to favour PHP based solutions because there is an abundance of PHP programmers. The market is saturated especially when you consider outsourcing overseas. Of course as mentioned earlier this can be a bit of a false economy for any sizeable project if you become restricted to one developer ‘teams’.
One of the web design companies I was working for had hired me to develop an ‘energy analysis’ application for a large aggregates company. We started using PHP and in the second year the code base started to take on a lot of technical debt due to convoluted hacks and bodge jobs which were employed to keep costs down. I had recently discovered Rails and had produced a few basic applications. I introduced the idea of using Rails but it was rejected and we continued on until three months later when I really could not go on. That week I rewrote the entire application in just a couple of weeks in Rails. We never looked back. From then on development proceeded at a much quicker pace and I could answer ‘yes’ to new features without having to worry about the code becoming unmaintainable.
What was the most difficult aspect of learning Rails?
At first I used Rails without really learning Ruby, the language in which it is written. In the beginning this wasn’t really a problem because Rails allows you to get up and running straight away with some simple configuration. But once you move past this point of using Rails as is and wanting to do some more advanced stuff that’s when you need to learn the Ruby language and become familiar with some of the objects in the core and standard libraries.
Ruby also has some features which are unique, such as blocks, which don’t seem to have a parallel in other languages.
Reading other peoples code was maybe the fastest way I leap frogged my understanding not only of Ruby but the “Ruby Way”. It’s hard to put your finger on exactly what the “Ruby Way” is. It’s kind of a collective best practice as defined by the community which you pick up over time.
Aside from Ruby and Rails what other software have you been excited about recently?
Definitely ‘Git’. It’s a distributed version control system which has become popular in the Rails community. It allows you to manage your source code individually or as part of a distributed team. Git is an open source project and was started by Linus Torvalds to manage the Linux Kernel code base.
What kind of projects have you been working on with Rails?
All the websites I code are now written in Rails. We recently delivered the Information Prescriptions project, which is an NHS funded knowledge base covering a wide range of health conditions such as Neurological, Long Term, Heart, Lung and Breathing Conditions. All information is categorised using demographics such as age, gender, and location. The project has been running over 2 years now and we are continually evolving the website to better meet the needs of the people using the site.
Last year we delivered a project, ‘Evolve’, for Nottingham Trent University which allowed students to be matched with charities looking for particular skill sets. It incorporated a lot of Social Media like features such as profiles, messaging, personal blogs and the ability for people to form groups with complementary skills.
Aside from this we have developed a variety of websites in the usual categories such as Online Learning, Customer Management, loads of Content Management Systems, E-commerce Solutions and Web Services.
I have also released a few open source projects for Ruby/Rails. I have written a series of automated tasks to help transparently incorporate non-technical graphic designer’s work in to our central code repository. This gives us a history of changes to HTML templates, images, CSS and Javascript files. This allows them to work with tools they are used to such as Dreamweaver and FTP. There are also a few experimental ideas on there including a Ruby chat server which keeps a HTTP connection to the browser open permanently allowing the server to push real time data to the browser.
Difficulty of deployment and scaling have been cited as failings of Rails, whats your take?
I think deployment was an issue in the very early days when the only option was to use FastCGI which was typically a pain to setup and far from reliable. Now days however we have a wealth of deployment options including standalone servers for Rails, an Apache module which allows you to just upload your code (ala PHP) and thanks to the JRuby project interfaces to Java Application Servers such as JBoss if you need to deploy in a Java only environment.
We also have a number of deployment automation tools which allow us to setup and deploy applications in seconds without having to even log in to the server(s).
The beauty of these tools is that you can start off with a super simple light weight setup and scale up at a later date if required. You can even have your application scale automatically up/down on demand if you are deploying to the cloud such as EC2.
It’s out of the scope of Rails itself but if you are managing your own server we also have tools such as Deprec and Chef which will provision a vanilla Linux server which an entire Rails stack including the database and web server.
Can you give some examples of high profile websites which are written in Rails?
Everybody’s heard of Twitter, right?
Yell, Scribd and Hulu are other examples of very high traffic sites. There are literally tens of thousands of sites out there both big and small which use Rails.
Twitter is known to have had issues scaling and this seems to have reflected badly on Rails…
To be honest scaling has never been an issue for websites written in Rails, since it scales in the same way as every other website, at the HTTP level. If you are lucky enough to attract enough traffic you start by caching as much as possible, optimising database calls and maybe moving your database on to a separate server. This is all configurable in Rails and standard practice for any website regardless of the technology.
The bottle neck for many high traffic websites is nearly always at the database tier. This was particularly pronounced for Twitter because it accepts real time content from any of its millions of users, peaking at 300 ‘tweets’ per second. I believe Twitter now keeps a lot of their data in memory and they wrote their own data storage to handle their unique case.
You are presenting the Ruby and a Rails courses for ourselves can give us an idea of what delegates will take away with them?
The courses can be taken individually however they run over consecutive days and are designed to complement each other. I have condensed years of experience into a few days so it’s pretty action packed. I’d like to inspire developers and show them things that will make them think ‘wow’. It’s important that delegates to go away with a practical and working knowledge so we use live coding sessions, participatory discussion and practical examples to collectively explore Ruby and Rails.
The 2 day Ruby course will be an introduction to many of the unique aspects of Ruby which make it really stand out as a general purpose language. It will not be Rails specific.
We will investigate the Ruby language, its object model and how to write solid object orientated code and tools such as package management, automated build tools and documentation which come packaged with Ruby things that really simplifies life as a developer.
We will go on to look at the ‘magical’ side of Ruby which allows the Rails framework and many of plugins and libraries to be as concise as they are. This will include a look at advanced topics such as meta-programming, DSL’s and code evaluation.
The Rails course which is spread over 3 days will start from the premise of never having used Rails before and we cover a lot of ground.
In the first day we will look at each of the core modules which make up Rails and how they are wired together allowing you to easily manage your data, render HTML and send emails. By developing a working application together I hope to demonstrate practical tips and techniques which I have accumulated over many years.
The second day will start with a focus on logins, permissions, security concerns and how these are handled in Rails. This will be followed up with a look at advanced concepts within each of the core modules.
The third day will looks at deployment options, debugging and optimisation, writing your own plugins and alternatives to the default Rails core modules.
Finally, where do you see the future for Rails?
Now a lot of initial hype has died down and we are seeing large projects being deployed in Rails with substantial user traffic which are scaling well it has silenced a lot of the unfounded doubt people might have had.
We are seeing healthy competition in the plugin arena in categories such as file upload, XML parsing, authorisation, authentication and the like. There is an abundance of high end well documented plugins.
Ruby 1.9 is just around the corner which looking at the benchmarks will give some great speed improvements. The Rails core team are working hard on gaining compatibility.
I don’t think the true potential of JRuby has been realised yet. JRuby is an alternative to the standard Ruby interpreter which allows you to run Ruby code on the JVM (Java Virtual Machine) and provides a two way communication between Ruby and Java. Allowing any Java library to be used from within Ruby. This includes as mentioned earlier running a Rails app inside something like Glassfish or JBoss.