Ruby on Rails?

Discussion in 'Web Design and Development' started by emiljan, Jul 22, 2010.

  1. emiljan macrumors 6502

    emiljan

    Joined:
    Jan 25, 2010
    Location:
    Michigan
    #1
    Hey guys,

    I just have a simple question.

    Is ruby on rails used much for dynamic web development?

    I'm taking classes in the fall to learn Coldfusion and i found out that outside of enterprise environments its not used much anywhere else.
    Also my college doesn't offer any courses on ruby or php so i have to learn those on my own but i can't make up my mind on which to learn.

    I don't want to put in the time to learn ruby and find out that i can't do much with it. I know that php is very popular and widely used but i like ruby much better.

    I'm learning ruby right now and so far its easy to pick up. The syntax is very easy to read and since everything is an object in ruby, it makes it easier to learn.
     
  2. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #2
    Ruby on Rails was designed for dynamic web applications, working with Jruby it can also benefit from the power of Java.

    Coldfusion's use is in decline though it is still powerful a lot of companies would be looking for ether PHP(With Zend Framework or Cake PHP Framework) developers or to a lesser extent Ruby on Rails(Ruby itself without rails is rare) and also ASP.net.

    Each can all do the same thing more or less without much fuss, ASP and Ruby on Rails are harder to find web hosting for and coldfusion is hard to find developers willing to pull there hair out over so you do have a good little market there in maintaining latency applications.

    In terms of difficulty in learning a new language PHP will be the easiest if you've done CF followed by Ruby.

    Just to demonstrate i'll shove in some sample PHP and Ruby code so you can see the differences.

    PHP Class
    PHP:
    class Default_IndexController extends Zend_Controller_Action
    {
        public function 
    init()
        {
            
    /* Initialize action controller here */
        
    }

        public function 
    indexAction()
        {

        }
    }

    Ruby Class
    PHP:
    class IndicesController ApplicationController
      
    # GET /indices
      # GET /indices.xml
      
    def index
        
    @indices Index.all

        respond_to 
    do |format|
          
    format.html # index.html.erb
          
    format.xml  render :xml => @indices }
        
    end
      end
    end
    Both of these do the exact same thing just using the different languages. Ether way you'll need to learn MVC(and HMVC if your doing larger projects).
     
  3. emiljan thread starter macrumors 6502

    emiljan

    Joined:
    Jan 25, 2010
    Location:
    Michigan
    #3
    It seems then to learn php since coldfusion is dying out and ruby alone is not worth it.

    Thank You!
     
  4. DJBenE macrumors member

    Joined:
    Jul 9, 2010
    Location:
    Rowland Heights, California
    #4
    +1 more for PHP.

    PHP is very easy to learn...specially if you have a background with any of the C languages. And it's really all up to you on how you deal with your PHP code. If you rather use/make objects than procedural code you can. Or vice versa...PHP is very flexible compared to most others that are not.

    But, pertaining to one of the above comments...you don't necessarily need to learn how to utilize MVC frameworks unless you absolutely have to. There are some major advancements that MVC frameworks could allow but overall MVC is really only helpful with groups of developers working on large web applications. I recommend learning the basics of PHP and then once you're comfortable with writing basic scripts check out what MVC can do for you and make up your own mind about it.
     
  5. jaikob macrumors 6502

    jaikob

    Joined:
    Jul 1, 2008
    Location:
    Freeland, MI
    #5
    Haha I disagree with the ones recommending PHP. I know PHP and Ruby on Rails very very well. And I have to say, it takes me twice the time to build a webapp in PHP than Rails. I build all of my webapps in Rails, and I love it!

    By the way, whoever wrote this in the example above:
    Code:
    respond_to do |format| 
          format.html # index.html.erb 
          format.xml  { render :xml => @indices } 
        end 
    It's not needed. You don't need to add that unless you want a JSON or RSS feed usually.

    And yes I do agree web hosting for it (shared) is sometimes hard to come by, but dreamhost supports passenger. Almost all webhosts that support rails will support Mongrel, but it costs more. If you want a free and good solution. Try Heroku.

    When developing a rails application, it has it's own embedded server. Just type: script/server (rails 3: rails server). Go to localhost:3000 and it's there. Ruby is easier to learn that PHP in my opinion.

    I strongly disagree with all of the PHP supporters, because I indeed use to be a PHP supporter. Rails and ruby is just flat out easier in my opinion, expecially ActiveBase and ActiveRecord. Those are slick. To query a database, simply: @variable = Model.find:)order => "title ASC")

    There are so many features of Rails that I can't tell you about all of them. Just know I think it is worth learning :)
     
  6. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #6
    Copy pasting lazyness. I trimmed the PHP but could not be bothered to do the same with the Ruby.
    And remember PHP has ActiveRecord now too which is pretty much as like for like implementation, indeed my own PHP framework uses PHP ActiveRecord.

    Also keep in mind Zend Framework works better for much larger projects by using HMVC which just now Ruby On Rails does not yet support.

    Oh and i have yet to work out how to use a stored procedure with ActiveRecord.
     
  7. jaikob macrumors 6502

    jaikob

    Joined:
    Jul 1, 2008
    Location:
    Freeland, MI
    #7
    Ehh. I think Zend and Rails are comparable and pretty much the same except for, of course, language. PHP is PHP and I still write more PHP than Ruby code, and I like that. Your forgetting there are large Rails applications out there like Twitter :p

    As the OP can see the answer to the question is like playing Battleship. There really is no answer to "which is better" because they are all good in their own way. I suggest you choose something, and stick with it. Ether it be PHP or Rails. You will grow to like it more than the counterpart :)
     

Share This Page