On 20 Feb 2007, at 17:33, [EMAIL PROTECTED] wrote:
>> While waiting for my RB process to compile and "do its thing" I
>> thought I'd start reading up on Ruby on the web, which brought up
>> this question :
>>
>> Is Ruby quicker and easier to program in than RB ?
>
> No. I spent a day learning and working with Ruby once. It was neat
> (especially from a "language theorist" point of view), but not nearly
> as productive as RB. My first day in RB, I accomplished some real and
> interesting tasks; the same was not true for me with Ruby.
It depends on what you want to do with Ruby. If you're aiming at
developing database backed applications and don't mind it being a web
app, Ruby combined with the Rails framework will just blow RB away.
Not because RB is bad, but simply because there's no (open source)
framework for database backed applications available that is able to
deliver in a way Rails is. Rails is based on the MVC model and has
full regression testing built-in, so even the novice hobby developer
is encouraged to write beautiful code. Rails also defines conventions
("Convention over configuration") that will cut down your development
time. Still, you are perfectly able to overrule those conventions and
use your own. And because of the nice Ruby language features such as
method_missing, full introspection and a slew of other
metaprogramming techniques, Rails is able to all wrap it's complex
object relational mapping into very straightforward almost-English-
sounding code.
Now, a few years ago, we started such a framework in RB 5.5 (my
collegue Glenn Verhalle even showed it at REALworld (the first or
second edition) to the RS guys, I even believe Joe was one of those
people :-)), but after a few months of work, it just became obvious
RB wasn't up to it. Some people clearly have been able to get some
serious work done in REALbasic (LightSpeed, Revolver, …) and I
applaud them for it. But back then, for us, RB being a closed
commercial application and plagued by so many bugs to work around,
getting the framework set up the way we wanted it too was just
impossible (both in terms of time and investment). We tried a few
other environments (Java, PHP, …) but none felt right or were just
horrible to work with in the first place.
And then came Ruby and Rails. Now, you must understand that my
collegue was really into SmallTalk in his younger days and Ruby
definitely has some of its roots in SmallTalk. On top of that, Rails
is open source and the core team consists of some of the pioneers
behind new web technologies like AJAX (in particular Prototype +
script.aculo.us). And AJAX can bring some of that desktop
interactivity to the browser, which is just great (it seriously
enhances the user experience).
I must say I have never come across a bug in Rails that I had to work
around, but even if that would ever be the case, I would just find it
in the framework and fix it myself (and post the patch in Trac so it
can be committed to the framework). That will never happen with RB.
Can you develop quicker and easier in Ruby on Rails than in RB? For
our business, undoubtly yes. To give you an idea, we were able to
create a fully functional CRM/ERP application in less than 2 months.
Our customers also appreciate the fact that they only need a web
browser to access the application and because we can use AJAX here
and there, it doesn't really feel like a web application anymore. We
still use REALbasic btw, for small applications that interface with
the web application through XML. An example application would be an
appointment reminder application that alerts you of pending
appointments even if your browser is closed. So, for us, REALbasic is
a great environment for the stuff a web app isn't able to do and we
can still support MacOS, Windows and Linux (sometimes :-)). So let
there be no mistake about it, I still really love RB for its merits
as a cross platform RAD desktop app development language.
But there are quite a few things to look out for: you'll have to
become comfortable with XHMTL and CSS, and undoubtly have decent
design and Photoshop skills or be prepared to hire a webdesigner.
It's possible to learn Rails without learning Ruby, but eventually
you'll just have that urge to get to know the ins and outs of Ruby
anyway. Ruby has some really powerful stuff that RB is nowhere near
to accomplishing, some of it will probably be impossible because RoR
is a scripting language and not a compiled language. Ruby's syntax is
just wonderful to be honest, and if you know any programming
language, you'll be able to at least read Ruby and/or Rails code
without knowing Ruby or Rails at all.
Example Rails code (from one of our other web apps, too bad you won't
see the code in nice TextMate colors):
COMPANY MODEL
class Company < ActiveRecord::Base
has_many :users, :dependent => :destroy
has_many :locations, :dependent => :destroy
has_many :assigned_company_segments, :dependent => :destroy
has_many :company_segments, :through => :assigned_company_segments
has_many :albums, :dependent => :destroy
has_many :slideshows, :dependent => :destroy
has_many :agendas, :dependent => :destroy
has_many :album_images, :through => :albums
has_one :logo, :dependent => :destroy
validates_presence_of :subdomain
validates_presence_of :companyname
validates_uniqueness_of :subdomain
validates_associated :users
def admin_domain?
admin_domain
end
def self.admin_domains
self.find(:all, :conditions => ["admin_domain=?",true])
end
def self.customer_domains
self.find(:all, :conditions =>
["admin_domain=?",false], :include => :locations)
end
end
ALBUMS CONTROLLER
class CompaniesController < ApplicationController
layout 'main'
access_control
[:index, :create, :new, :show, :update, :edit, :destroy, :add_company_se
gment] => 'superadmin'
before_filter :find_companies, :only =>
[:index, :show, :export_as_csv]
def index
@company = Company.find(@current_site, :include =>
[:company_segments, :logo])
respond_to do |wants|
wants.html { render :action => "show"}
wants.csv do
render :text => @customers.to_csv(:except =>
['id','admin_domain'])
response.headers['Content-Type'] = 'text/csv;
charset=iso-8859-1; header=present'
response.headers['Content-Disposition'] = "attachment;
filename=customers_#{Time.now.strftime("%d-%m-%Y")}.csv"
end
end
end
def create
@user = User.new(params[:user])
@company = Company.new(params[:company])
# Save the company and add the first user
@company.users << @user
if @company.save
redirect_to company_url(@company)
else
render :action => "new"
end
end
def new
@user = User.new
@company = Company.new
if params[:admin_domain]
@company.admin_domain = params[:admin_domain]
end
end
def show
@company = Company.find(params[:id], :include =>
[:company_segments, :logo])
end
def update
@company = Company.find(params[:id])
if @company.update_attributes(params[:company])
redirect_to company_url(@company)
else
render :action => "edit"
end
end
def edit
@company = Company.find(params[:id], :include =>
[:users, :company_segments, :logo])
end
def destroy
@company = Company.find(params[:id])
@company.destroy
redirect_to companies_url
end
private
def find_companies
@administrators = Company.admin_domains
@customers = Company.customer_domains
end
end
Best regards
Peter De Berdt
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>