Online Rails Development with Heroku

Posted by Timothy Fisher Mon, 17 Mar 2008 01:11:00 GMT

Heroku is a web application that provides a complete environment for writing Ruby on Rails powered web applications. With Heroku you get both a development environment and a hosting platform. Each application that you create with Heroku is also assigned a unique URL that you can use to access it.

Heroku has plenty of gems and Rails plugins pre-installed and available to any Rails application. However, if you want to use a gem or plugin that is not already installed, you can do that also. It is simple to install any gem or plugin into your Heroku Rails application. You can also upload a complete Rails application that you developed locally, into the Heroku environment. The opposite is also possible. You can export an application that you developed inside of Heroku and download its source to your local computer. As you write migrations, they are automatically detected and run without any manual intervention. You also get a built-in console for running any rake tasks that your application has. A built-in Rails console is also provided in a browser window.

Heroku also recently added an API that allows you to develop your Rails application locally on your computer and deploy to Heroku remotely through the Heroku API. The source code version control system that Heroku uses to store your source code is also exposed. The version control system used is GIT. If you have GIT installed locally you can directly access your application’s source code and make commits against it. When you want to deploy back to the Heroku servers, you do that through the Heroku API.

Heroku is probably not the host you’d select for deploying a production Rails application, but it can be a satisfactory development environment, and an excellent platform for learning. In a training environment, students would be able to develop a complete Rails application using only the Heroku web application without having to install any software on their computers. It is also easy to collaborate on an application using Heroku. Once you create an application, it is easy to add other users as collaboratorsruby who also have access to the application’s source code. Overall, I think this is a great tool that can help more people get exposure to the Rails platform.

Tags ,  | no comments

Three Great Books for Learning and Mastering Ruby on Rails

Posted by Timothy Fisher Sun, 09 Mar 2008 03:54:00 GMT

I tend to read a lot of technical books. My current passion is with the Ruby programming language and the Rails web application framework which is built on top of the Ruby language. I’m also a published technical author myself. The book that I am currently writing is the Ruby on Rails Bible which will be published by Wiley this spring. However, since that is a few months away still, I thought I’d share some reviews of some current Rails books that I find to be excellent learning and reference resources. The three books that are reviewed here are:

Two of the books RailsSpaces, and The Rails Way, are in the Professional Ruby series. Obie Fernandez, author of The Rails Way is the lead editor for that series.

Rails Space

This is a book that walks through the complete implementation of a social networking web application developed with the Rails framework. A hosted version of the application developed throughout this book is available online at www.railsspace.com. The authors of this book are Michael Hartl and Aurelius Prochazka.

This book is essentially an extended tutorial that is developed throughout the book. Some of the topics touched on while developing the Rails Space application are user authentication, image uploading, geo data, email integration, Ajax, and Restful development. As the application is written, tests are also written as each component of the application is finished. This provides excellent practical material on writing tests for your own Rails applications. You’ll find many of the techniques that the authors show you for creating tests and testing various pieces of the code to be very useful in your own projects.

Overall, I found this to be probably the best book available of its type, that is a book which serves as a tutorial focusing on the development of a large sample application. I highly recommend this book to any developer getting started with Rails. Even experienced Rails developers will enjoy this book.

The Rails Way

This book provides probably the most complete coverage of the Rails framework of any book currently out. This book is also the first book that I am aware to provide coverage of Rails 2.0. The author of this book is Obie Fernandez whom is one of the most respected Rails developers in the industry. Obie recently started his own Rails consulting firm, Hash Rocket.

The book provides excellent in-depth coverage of a wide range of technologies related to Rails development including Rails core technologies like Controllers, ActiveRecord, ActionView, the Rails routing system, Helpers, REST, Ajax, Session Management, Authentication, ActionMailer, ActiveResource, Rails Plugins and Testing. Technologies that are complementary to Rails are also covered in-depth including: testing with RSpec, Capistrano, background processing, plugins, and production configurations. The chapter on production configurations provides an excellent overview of what is necessary to get a Rails application running in a production environment. It includes example configurations for Mongrel and Nginx for serving your application and Monit for monitoring your application.

Unlike some other Rails books, this book assumes a knowledge of Ruby and does not waste pages with a long Ruby introduction. In my opinion, that is a good thing. If you are interested in learning Ruby, this book is not the best choice for you.

The book’s afterword is titled What is the Rails Way (To You)? Be sure not to skip that if you read the book. This chapter provides a collection of thoughts from a bunch of Ruby and Rails developers, quite a few of whom you will have probably heard of if you keep up with the Rails community. I found it to be a very interesting and insightful chapter.

The Rails Way is also a nominee as Best Technical Book in the Jolt Awards competition. Overall, if I could buy only one book about Rails, this would be the book.

Practical Rails Projects

This book takes the reader through several practical examples of web applications that showcase the features of Rails. The book provides a very practical way of extending your Rails development knowledge once you’ve mastered the basics of Rails development. The author of this book is Eldon Alameda. The applications that you will build over the course of the book are:

  • To-Do list manager
  • Exercise/Fitness tracking application
  • Blog
  • Gaming community site

Like the other books I’ve included in this review, no pages are wasted on a Ruby introduction chapter. Instead this book assumes a knowledge of Ruby and jumps right into building each of the sample projects. Throughout the course of implementing these applications, you’ll use several popular Rails plugins as well as some features from popular JavaScript frameworks, YUI, and ExtJS. These JavaScript frameworks are excellent compliments to the Rails framework. The book is best read from start to finish, as in some cases each of the projects builds on functionality or features developed for an earlier project.

This book does include unit testing as well, though it does not emphasize it as much as the Rails Space book does. Some of the technologies that you’ll see in this book are: developing web services, Restful development, graphing, caching, and file upload. Some of the plugins that you’ll use throughout the course of the book include: acts_as_authenticated, calendar_helper, restful_authentication, css_graphs, ziya graphs, will_paginate, and attachment_fu.

Overall, I found this to be another excellent book that can be read from cover to cover. Both new and experienced developers will learn something from this book.

Tags , ,  | no comments

Programming Languages : Use the best tool for the job

Posted by Timothy Fisher Mon, 21 Jan 2008 16:58:00 GMT

Over the weekend I finished reading the book The Rails Way. I actually enjoyed this book so much that I took the time to read it cover to cover. As good as this book was, it is not specifically the topic of this post. The last chapter of the book contains a series of statements by a bunch of developers who have grown to love Rails. They explain what it is they like about Rails. Each of the statements is interesting, some more so than others. One of the very last statements, written by Nola Stowe, talks about the lack of community across languages and using the right tool for the job. This is what I want to talk about with this post.

Developers who speak extremely highly of a single language while criticizing other languages are being very closed-minded and are shutting themselves off to some great learning opportunities. Once you’ve mastered any given language, and even before you’ve mastered a language, one of the best ways to continue to grow your expertise of that language is to learn and study a new language. You may look at how something is done in a different language and that may inspire you to rethink how you are doing things in the language that you love. The Ruby on Rails framework is a great example of how implementation ideas in one language can influence many other languages. The Rails framework is one of the most innovative web applications to come along in any language. Rails introduced a simple way of building web applications using DSLs, convention over configuration, code generators, and a robust object relational mapping layer. Much of the core architecture of Rails has since been implemented in almost every other language that is used to build web applications. Frameworks in other languages such as Grails, Cake, Django and others all have borrowed ideas from Rails. Also, this borrowing of ideas is not a one way street. Rails was not designed in a vacuum either. While it is true that Rails did alot of new things, it too borrowed ideas from other frameworks and languages.

Consider PHP, this is a language that is routinely criticized as a language that creates some really awful applications that are full of spaghetti code. Is this the fault of the language? Of course not. PHP brought web application development to the masses and I’d venture to say that those developers that create spaghetti code applications with PHP would do no better in a different language. PHP5 actually introduced a pretty good object implemenation to the language and a good developer can write very good applications in PHP, just as a good developer can write good application ins Ruby, Java, or C#. Are there things that a Java developer can learn from PHP? I think so. I believe that each and every new language learned can teach you something.

Too often when you look for language comparisons you come across alot of articles, posts, and other content that praises one language and attacks other languages. If your a Ruby or Railis developer, you’ve probablyl seen the photo of the stack of books that someone put online a couple years ago. The photo shows a large stack of Java books sitting next to a stack of two Ruby and Rails books. The idea behind the photo being that Java is so complicated it requires tens of books to fully understand, while with Ruby and Rails you can get all you need with 2 books. Such a picture wouldn’t fare so well today. I’d venture to say that today Ruby and Rails related books are coming out at an equal or faster pace than Java books. Having alot of books out about a language and its various frameworks and libraries is in my opinion a positive thing. Java has a huge open source following and there are libraries available for Java that do almost everything you want. Having books available about these frameworks and libraries is not a bad thing and does not in and of itself make developing with the language more complex. With the surge in popularity that Rails brought to Ruby, the libraries are gettin better for Ruby but they still can not compare with what Java offers. In a similar vein, more recently there have been a series of videos that promote Ruby while mocking another language. These types of language hype may be entertaining but they are detrimental to the software development community at large in that they usually only breed more distrust and negative feelings across specific language communities. I believe that anything that discourages a young developer from learning a new language is a bad thing.

In the enterprise consulting world, you often hear that comment that such and such company is a Java shop, or a .Net shop, meaning that everything they do is in that language. I think that being characterized as a Java shop or a .Net shop, or a Ruby shop is not something a company should be proud of. For example, Rails has shown tremendous productivity improvements over other languages when developing database-backed web applications. A company that traditionally builds all of their applications in Java or .Net would be foolish to simply ignore this fact because they are a Java shop or a .Net shop. Similarly, Ruby is one of the coolest languages to be using right now. It has a dynamic and rapidly growing community, and the hottest framework on the planet in Rails. However, a project may come along for which there is an existing library implemented in Java which would allow you to complete the project quickly using Java, whereas in Ruby you would have to write this same library. Don’t choose to use Ruby because it is cool or the funnest language to use right now. Use a language because it makes sense for the projects your team is working on. JRuby brings even more interesting twists and scenarios. With JRuby it becomes easy to combine Java and Ruby on the same platform and within the same application. You could use the wonderful Java libraries while writing your new code in Ruby.

Neal Ford speaks of something he calls Polyglot programming. Polyglot programming is the concept of using many different language together even on a single project. The idea is that you should always be focused on using the best tool for the job. Today it is actually rare to write a web application using a single langauge. Your business logic may be written in Java, but consider other languages that you probably use without a second thought, JavaScript, SQL, perhaps a Perl script or too for maintenance tasks. The two primary platforms of today, the Java platform and the .Net platform, are both able to support a growing number of languages. For example the Java platform today supports Java, Ruby, Groovy, Scala and probably a bunch of lesser known languages. Each language may have strengths in a given area. Don’t be afraid to mix and match your languages even on a single project. Use the best tool for the job at hand. We should all be Polyglot programmers. Every good developer should expand their knowledge of languages beyond the one or two that they feel comfortable using. Even if you continue to use a single language, you may find a whole new way of thinking about that language when you’ve studied other languages.

Don’t let positive or negative hype turn you off from learning a programming language that may be outside of your comfort zone. I know that at first glance Ruby can seem very different to Java programmers. It is a dynamic, scripted language and that is a different world to many Java developers. I had been doing Java development for nearly 10 years before I learned Ruby. Now I advocate for Ruby every chance I get. I have not met too many developers who have given Ruby a real trial and have not come away with a positive experience, even if they choose not to use Ruby going forward. So in summary, don’t choose a language simply because thats what your company has always done or because thats the only language you know. I agree that those may in fact be important factors in what is the best choice for your team, but evaluate your optioins and use the right tool for the job.

Last week I attended a conference in Ohio called CodeMash. The theme of this conference is to bring together developers with different programming language backgrounds and have them learn from each other. I think the concept of the conference is wonderful. This is the second year that I’ve attended it and I will continue to do so in the future. We need more community across languages as opposed to just single language user groups and conferences. It would be great to see more user groups of different languages hold combined meetings with topics that are common to multiple languages. I think both groups can learn alot from each other.

Tags , , , , , ,  | 2 comments