the Future of the Web
  • Home
  • Hire Us
  • Articles
  • About
  • Contact
  • Switching from PHP to Ruby on Rails

    Nov 30 2006

    Normally, I try to avoid server-side programming topics. But this time, I thought I'd share my story to perhaps inspire some of you to try something new.

    I switched to working in Ruby on Rails this month. Lots of people have done the switch, and even more have written about how Ruby on Rails makes coding web sites a lot more fun and easy (it's true!). But that's not what this story is about.

    Until I switched, I was a PHP programmer. It's not just that I did a lot of work in PHP, it's that this is what clients expected of me, or so I thought.

    Unfortunately, I was getting really bored of doing PHP programming. I've never been passionate about PHP, it's just something I know that I use to get the job done. Code Igniter had gotten me excited about coding in PHP again, but it just wasn't enough.

    I've had a lustful eye on Ruby on Rails since I first heard about it a year or two ago. Yet it stayed on my long-term To Do List, never quite becoming a reality. "When I have more time, I'll figure it out and start using it," I thought. "One of these days I'll do a small project for myself in Rails so I can learn it," I told myself for months.

    I felt like I was stuck. PHP was what I knew, what I had used for years, and what I was best at. I had never used Rails, so I certainly didn't feel qualified enough to sell myself as a Rails developer. On top of this, I had three major projects coming up that were all supposed to be done in PHP.

    Then one day, I asked myself why I was so willing and excited to work in JavaScript but not PHP. Why is one fun and the other painful? I had always thought of the difference as just client versus server, but then I figured out it might just be the language itself. So I decided the only way to keep my sanity was to switch. There was no way I would keep doing this PHP thing.

    So, I got in touch with my clients and asked if they'd be willing to build the projects with Ruby on Rails instead of PHP. They couldn't care less. All they wanted was the finished project, and it didn't matter to them how it was done. One client even said the only reason she had mentioned PHP was because it seemed like the most common, but really didn't care. They didn't even mind that I was just starting to learn, because they knew it would make the project more fun for me, and they trusted me.

    So I did it. I've been coding in Rails since the start of the month, and it's been a great time. Sure, there was a learning curve. It took me some time to figure out how to do the simplest of things. But I read through the book, I experimented, I searched the web for answers, and now I'm cruising. I'm about 80% as good in Rails as I am in PHP, except with Rails everything takes half the time so in the end it's actually faster.

    So what's the moral of the story? If there's something new you want to start doing, or if you're getting bored, just go change things. Today. Create your own opportunities. And stop finding excuses in those around you for your inability to change, because there's a good chance they will totally support you.

    Tags: server rubyonrails php switch web development
    View 20 Comments | Add a comment
  • Comments

    1. Joel Birch at 2:23am on December 1, 2006

    Very interesting - I'm trying to do the switch too. When you mention that you 'read the book', which book are you referring to? The pickaxe book? If so, isn't that book about the Ruby language itself and not Rails so much? Do you have any other tutorial or resource recommendations?

    Thanks for this post, I am so close to following your lead.

    2. Jesse Skinner at 2:33am on December 1, 2006

    Ah, right, I was talking about "Agile Web Development with Rails" from the Pragmatic Programmers, which you can find online as a pdf:

    http://www.pragmaticprogrammer.com/titles/rails/

    I haven't read a book about Ruby (although this book has an Appendix on Ruby), but I have read over the documentation a lot at:

    http://www.ruby-doc.org/core/

    And once you're really working with Rails, you will certainly want to reference the API documentation (terrible for learning Rails, but excellent for looking up functions you already know about):

    http://api.rubyonrails.com/

    and occasionally I've found some good help on the wiki:

    http://wiki.rubyonrails.org/

    Hope that helps! Have fun!

    3. Joel Birch at 3:09am on December 1, 2006

    Fantastic! Thanks for the links and such a quick response. "Agile Web Development with Rails" does look good.
    I found your site via Emil's recent blog post and I'm loving your content. Cheers.

    4. Joel Moss at 11:12am on December 1, 2006

    Great article Jesse. I have been debating the switch for ages now, but I still can't see why Rails is better, and why I can't achieve the same thing in PHP.

    Please read my blog post at http://joelmoss.info/switchboard/blog//2035:Developing_faster_with_Rails and let me know what you think.

    Should I switch?

    5. Anand at 12:26am on January 4, 2007

    Great post!  You have taken the words right out of my mind.  I'm in a similar situation as you.  And I also found Code Igniter to be excellent, but not that comprehensive and somewhat lacking in features.  Right now, I'm mainating a CI based application as well as moving toward learning Rails.

    6. Chris at 10:08pm on January 18, 2007

    Jesse, thanks for your insight. I am just getting ready to pick a framework and, like you, have had my eye on Rails for a while, but am a PHP/Lasso programmer. As such, I have been looking at Code Ignitor, PHPCake and Symfony. So far Cake has my attention.

    I am wondering if you have further insight into what it is about Rails that won you over? Specifically what does it do that others (Cake, CI, etc ) don't?

    Thanks again.

    7. Jesse Skinner at 10:36pm on January 18, 2007

    There's a lot of overlapping functionality and features between Rails, Cake, Code Igniter, Symfony and any MVC framework. I'm not very familiar with Cake or Symfony, so I'm not sure what they offer. I do really like features in Rails like migrations, Active Record, generators, development/test/production modes, plus some of the features in the libraries like built-in validation in models.

    But I think what really sold me is the Ruby language itself. Ruby is an infinitely better language than PHP in the way it handles OOP, closures, regular expressions, as well as the syntax and data type functions.

    I've started to realise that PHP still has a place in the world. I'd never build a simple web site in Rails. It would be overkill. Rails is great when you have a complex database, but for a simple site with limited functionality (ie. contact form, guestbook), PHP is much easier.

    8. Anil Philip at 7:16pm on March 9, 2007

    If there's something new you want to start doing, or if you're getting bored, just go change things. Today. Create your own opportunities. And stop finding excuses in those around you for your inability to change...

    this was the takeaway for me. Thank you for an insightful comment.

    9. Jeff at 2:29am on September 10, 2007

    Hey,

    I found this blog post on a google search. Thanks for the writing it - it was informative to me and also inspirational. I've been apprehensive about trying RoR for the same reasons you mention. I think it's time for me to take the plunge :)

    10. Mike at 6:08pm on October 15, 2007

    Hii,

    I've been using PHP for almost 4 years now and just a month ago I took a look at RoR and followed both the blog and flickr tutorial and really liked what I saw. Now I've read somewhere that all RoR web apps that are build by beginners usually contains a lot of garbage code. Is this just a myth? because I have a big project coming up and I can't wait to build it in RoR. What do you think?

    11. Jesse Skinner at 8:25pm on October 15, 2007

    @Mike - I found that there are a lot of really cool, slick, fast ways of doing things with Rails, most of which are totally not obvious. Probably the best way to learn these techniques is by reading books about Rails before you start programming. But of course, those who have more experience with Rails are going to write better, smarter code that takes advantage of all that Rails and Ruby have to offer.

    12. Alec at 8:01am on December 17, 2007

    Three questions:

    1. How hard is it to switch to RoR if

    - You don't know Ruby
    - You don't know OO

    I've written very complex stuff in PHP, but mostly procedural.

    2. Does RoR mean you don't have to work in JavaScript since it generates that?

    3. ORM or ActiveRecord is not as efficient performance-wise as a database proc. Can one continue to use those database proc's?

    13. Jesse Skinner at 3:12pm on December 17, 2007

    @Alec -

    1a. You'll have to learn a whole new language. It's not a very hard language, but some concepts can be very tricky to understand at first.. and like learning any language, you'll have to look up basic functions, like how to work with strings and arrays, for the first few months at least.

    1b. Ruby on Rails is entirely OO based, so you'll need to understand the basics of OO, at least constructors, instance variables, inheritance, parent objects, methods, etc. This stuff isn't that difficult really, but it isn't obvious either.

    2. You can get away with not writing JavaScript if you want to do some simple things, but it won't do everything for you of course. And personally I'd rather do my own JavaScript than have it generated for me (but JavaScript is my expertise).

    3. I believe you can write direct SQL as much as you want, though I'm not sure how much extra work this would be.

    14. dicky at 10:13am on March 3, 2008

    Hi, i had go through a lot of article comparing RoR and PHP. I just want to ask 3 very simple questions. If i am a newbie to web programming (knowing little bit about PHP, HTML, CSS, and Javascript, but not RoR), which language should i choose?

    The second question is, i want to create a simple web application for user to share something with simple login/database, which language is most suitable to do so?

    The third question: I had go through the introduction of "Agile Web Development with Rails", but is it suitable for beginner? Or at least i need to know the basic of Ruby language?

    Thats all my question, hope someone can answer me...Thanks.

    15. Jesse Skinner at 5:37pm on March 3, 2008

    @Dicky

    1. Well, you can learn anything you want really. If this is just something you're learning in your own time, then I'd suggest sticking with whatever you are most excited about. Explore PHP, explore Ruby on Rails, and use whichever one you enjoy working with more.

    2. I'd personally go with PHP and Code Igniter over Ruby on Rails for anything considerably simple.

    3. The Agile Web Development book(s) are aimed at people with little-to-no experience with Ruby or Rails. They assume you'll learn the Ruby language as you go (which you will). If you're new to programming this might be harder of course, but if you already know a few other languages it's not that hard to learn another new one.

    16. dicky at 12:53am on March 4, 2008

    @Jesse: Thanks for your comments. I am a .NET programmer and now i am looking chances to got for web programming. Hope i can enjoy learning CodeIgniter. Thanks again!

    17. Summer A. Munir at 5:39am on March 5, 2008

    Hi,

    My question is very simple and i think may be a very common one. Lately i had to leave my job and since then i am virtually doing nothing. Thought it would be better to learn programming. I got NO previous programming  experience. Although i am roughly familiar with certain programming concepts: i don't know CSS, PHP, VB, C# or any such thing. All i know to some extent is that logic prevails in computer sciences. However, at the same time i got sufficient user level exposure to state of the art softwares used in the banking sector. Question is: how long should it take for me to reach from point 0 to a professional programmer. Would it be months or years. I just want to earn some money and pretty desperate about it. Lately i've figured out that i am a kind of person who would prefer to sit alone and get his job done in front of a speecless computer:). Can you give me the timeline please and the best way to learn RoR? Thanks.

    18. Jesse Skinner at 4:26pm on March 5, 2008

    @Summer - It's impossible to say how long it will take you to become a professional programmer, and even amongst professionals there is a wide range of skill and experience. It all depends on how quickly you learn and how much time you devote to it. That said, I don't think it would be unreasonable for someone to go from 0 to professional within a year if they really worked hard at it.

    As for learning RoR - the best way I know of is to work through the Agile Web Development book:

    http://www.pragprog.com/titles/rails2

    19. Summer A. Munir at 7:12am on March 6, 2008

    Thanks for your kind support. I think i should start with 4 hours a day. Let see where it goes. I will definitely go through the book suggested by you- it definitely seems good to begin with. Thanks once again.

    20. Aurelijus at 10:48am on March 17, 2008

    Why are you comparing programming language and framework ?

    By the way, what can you do with Ruby (programming language, not RoR framework) that you can't do with PHP ?

    Add a Comment

    Note: HTML tags and entities will be converted so that they are displayed as you type them. This means if you type in <em>, people will see <em>, and if you type &lt;em&gt;, people will see &lt;em&gt;.

  • Request a Quote

  • Jesse Skinner

    Jesse Skinner
    • Hire Me
    • About Me
    • Email Me
    • RSS Feed RSS Icon
  • Recent Articles

    • Parse Accept-Language to detect a user's language
    • Twitter
    • Three years of The Future of the Web
    • Saving data to a file with PHP
    • Easy web scraping with PHP
    • See all the articles
    • IBM: Where and when to use Ajax
    • Code Igniter 1.6.0 Released
    • Update a Dev Site Automatically with Subversion
    • JavaScript Functions are Variables
    • See All...
  • Categories

    • javascript (37)
    • links (19)
    • about (18)
    • web (14)
    • server (10)
    • html (10)
    • css (8)
    • carnival (7)
    • browsers (7)
    • design (4)
    • seo (4)
    • ads (4)
    • standards (4)
    • events (4)
    • work (4)
  • Older Articles

    • May 2008
    • April 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • January 2007
    • December 2006
    • November 2006
    • October 2006
    • September 2006
    • August 2006
    • July 2006
    • June 2006
    • May 2006
    • April 2006
    • March 2006
    • February 2006
    • January 2006
    • December 2005
    • November 2005
    • October 2005
    • September 2005
    • August 2005
    • April 2005
    • See All...
Copyright © 2008 Jesse Skinner | CSS | XHTML | RSS | Help | Impressum | Cutie Quilts | Internet Blog Top Sites