I've read a ton of comparisons that compare one framework to another,
and one language to another. There's so much conflicting advice out
there that it's hard to know what is best. Did I make the right
choice choosing Rails for my first web project? I guess we'll see.
The only reason why I'm hesitant is that a lot of the big name sites
use php (facebook, wordpress, joomla, etc). At some point I'd like to
write plugins and extensions for them and integrate with their API's
with my site, will Rails will do the trick?
No worries on the API front; as others have noted, writing plugins may
be harder. But given some of the amazingly sneaky things that have
been done in Ruby (case in point - GitHub - tenderlove/phuby: phuby wraps PHP in a loving embrace
: a PHP runtime in Ruby), anything's possible...
Also, I looked into django, the framework for python. I was sorta
intrigued by python because that's what google uses and I believe
yahoo as well. However, there is 0.00% chance of my little ol' web
app ever reaching their seismic proportions, but from what I've read
django is quite comparable to ruby and quite a bit faster. I guess
that's the only reason why I'm still hesitant about choosing Rails.
From what I've gathered is that Rails lags in speed and performance.
There's a lot of discussion about who's faster; what gets lost is that
while there may be some raw differences in speed, the application code
makes far more difference. Bad programmers can write slow apps in ANY
language... Also, keep performance pretty much out of your thoughts
when you're starting out - obviously, don't do *clearly* bad things
(like doing a find(:all) and then searching the results...), but
optimization comes later.
Personally, I've always found Python harder to read, but that may just
be years of C/C++/Perl bias.
So, why did I choose rails? It seems to be the easiest to code it in
and it's very well documented. I hope that doesn't come back to bite
me 'cause I'd rather put in extra work upfront to ensure the longevity
of my site and the least amount of headaches in the future. So the
next few months all I'll be doing is eating, drinking, breathing
Rails, and I just wanted to say hi and sorta introduce myself to the
community. Thanks guys for all the documentation already out there
and all the support you guys provide.
Well, it's well-documented right up until you hit the bits that
aren't.
As far as general advice, here's some stray ideas:
- as others on this thread have noted, test. Test test test. I'm not
entirely partial to the "test absolutely everything" school, (example:
checking that a plain belongs_to association works) but any time
you're doing something out of the ordinary in a model, test. At the
very least, write enough functional tests to smoke-test your
controllers and views. And any time you find yourself typing the same
thing into a form to see what happens, write a test - it's quicker,
and serves to check that things are still working.
- learn source control. Most here favor Git, and most Rails plugins
are hosted on Github now. Even if you're working by yourself, source
control is useful (as you'll discover the first time you 'rm' a file
that you wanted to keep...)
- the design of Rails is focused on making doing 'the right thing'
easy. If you find yourself fighting against the framework and writing
lots of messy code to work around it, take a step back and look at
what you're doing. Nine (or more) times out of ten, there's a more
straightforward way to do it. Of course, that one time, it's a bug in
Rails...
- read lots of code. Understanding the Rails source, for instance,
will teach you an amazing amount about good Ruby coding. I'd
recommend, however, starting with something *other* than ActiveRecord
- there's some remarkable stuff there, but the metaprogramming /
method generation stuff is tough going at first.
- get comfortable with ruby_debug. This can help you starting out, as
you can drop a 'debugger' statement almost anywhere (even in views!)
and look at the context your code is executing in.
Hope this is helpful - welcome to the community!
--Matt Jones