“JavaScript on ProtoType”
In learning Ruby on Rails, I’ve come accross this little bump of which I easy surpassed, but it seems to be a problem for many. Here’s what I’ve gathered:
Ruby is the programming language. Rails is a framework. Ruby on Rails is not a language.
This is probably on of the most difficult things for people to get over, but it’s simple if you thing of it in these terms:
Now for the part I’m still unsure about… Is Rails written in Ruby? All the other frameworks (Prototype, Scriptaculous, etc…) are all written in their respective languages. But anyways, enough about that. It’s a pretty simple thing. My new favourite Ruby website is Ruby-Lang.org.
It has some cool examples on the front page that randomly change, and just by looking at those I’ve learned a few things. First of all, in a class if you define “initialize” it will run automatically when the class is called, or upon initialization. The example they use is:
class Greeter
def initialize
@name = name.capitialize
end
def salute
puts "Hello, #{@name}!"
end
end
g = Greeter.new("world")
g.salute
This is another thing I love about Ruby-Lang. The examples it gives you to show Ruby in action are basic, but they give you a good understanding. The above example could be done in PHP, but it would be longer and less efficient, for sure.
Leave a comment
Razor
March 24th, 2007 at 7:27 PM
the php version of that code would be almost the same actually
class Greeter
{
function __construct($name)
{
$this->name = strtoupper($name);
}
function salute()
{
echo $this->name;
}
$g = new Greeter(”world”);
$g->salute;
ok its abit longer but same thing
Connor Wilson
March 24th, 2007 at 8:18 PM
Yeah the PHP version isn’t bad, but I’m so tired of PHP. I’ve been using it forever and it’s boring now for me to code. I’ll still be using it with WordPress, but Ruby will also open up things like Typo and Mephitso for me.
Razor
March 25th, 2007 at 3:29 PM
i would like to learn ruby but, what hosts support it and how easy is it to make a simple website :S
(i use dreamhost)
Connor Wilson
March 25th, 2007 at 3:31 PM
DreamHost does support it, but it’s definitely not easy to setup, or make a simple website.
It’s a lot of trouble to go through to set up a Rails app.
Login »