Professional Web Development Forums: ruby on rails - Professional Web Development Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

ruby on rails Rate Topic: -----

Posted 10 March 2010 - 02:04 AM (#1) User is offline   fg101 

  • New Member
  • Group: Members
  • Posts: 25
  • Joined: 10-March 10
  • Gender:Male

i have heard a fair bit about this language. if someone knows anything about it can you get back to me plz. is it similar to js or asp? id like to learn a new language
0

Posted 11 March 2010 - 12:02 AM (#2) User is offline   ElseAndrew 

  • English & Proud -__-
  • Group: Moderator
  • Posts: 1,919
  • Joined: 12-February 09
  • Gender:Male

What languages do you currently know ?
Posted Image
0

Posted 11 March 2010 - 03:34 AM (#3) User is offline   Bobby 

  • Member
  • Group: Members
  • Posts: 95
  • Joined: 01-February 09
  • Gender:Male
  • LocationNew Hampshire, USA

View Postfg101, on 10 March 2010 - 02:04 AM, said:

i have heard a fair bit about this language. if someone knows anything about it can you get back to me plz. is it similar to js or asp? id like to learn a new language


Contrary to popular misconception, Ruby on Rails is not a language of its own. Ruby on Rails is a web framework written in and for the Ruby language. Ruby itself is a rather unique language, and one I whole heartedly recommend anybody learn no matter what your needs. As far as scripting languages go its power for system applications is on par with Perl; whatever Perl has you're almost guaranteed to find a Ruby equivalent (Ruby even has an equivalent of CPAN called RubyGems). And for web development, the Ruby on Rails framework is literally redefining what Rapid Application Development (RAD) means. Long time frameworks like Zend Framework for PHP have actually begun to mimic some of the features that RoR has.

As for what language Ruby is mostly akin to- Python is the only language that really comes close. Ruby's a pretty unique language with some fundamentals and conventions that are not seen in other languages.

If you're interested I'd start out the the official Ruby web site. A good first stop would be the "Ruby in Twenty Minutes" tutorial. Once you have a basic understanding of Ruby (highly recommended before jumping into the Rails framework) then head over the Ruby on Rails site. The documentation and guides they have are top notch.
0

Posted 11 March 2010 - 04:04 AM (#4) User is offline   Bobby 

  • Member
  • Group: Members
  • Posts: 95
  • Joined: 01-February 09
  • Gender:Male
  • LocationNew Hampshire, USA

I was going to edit my last post to give you an example of the language. But I can't seem to edit it, so I'll double post.

class Greeter
  attr_accessor :first_name, :last_name
  
  def initialize
    @first_name = ""
    @last_name = ""
  end
  
  def say_hello
    puts "Hello, #{@first_name} #{@last_name}!  Your first name has #{@first_name.length} letters in it!  Those letters are:"
    print_letters
  end

  private

  def print_letters
    @first_name.length.times do|f| 
      puts "#{first_name[f, 1]}\n"
    end
  end
end

greet = Greeter.new
greet.first_name = "Bobby"
greet.last_name = "Hensley"

greet.say_hello


That's some basic Ruby syntax for you.
0

Posted 11 March 2010 - 04:48 AM (#5) User is offline   fg101 

  • New Member
  • Group: Members
  • Posts: 25
  • Joined: 10-March 10
  • Gender:Male

it doesnt look that hard. nice example too. you mentioned it wasnt a full language, so which one is it a part of? im interested in this and im looking to know if it will work on my local host set up, wampp to be exact.
0

Posted 11 March 2010 - 02:21 PM (#6) User is offline   Bobby 

  • Member
  • Group: Members
  • Posts: 95
  • Joined: 01-February 09
  • Gender:Male
  • LocationNew Hampshire, USA

View Postfg101, on 11 March 2010 - 04:48 AM, said:

it doesnt look that hard. nice example too. you mentioned it wasnt a full language, so which one is it a part of? im interested in this and im looking to know if it will work on my local host set up, wampp to be exact.


Ruby is the language Ruby on Rails was written in, and it's the language you'd be using when making a Ruby on Rails web application.

And the nice thing about Ruby on Rails is for the development purposes, especially while learning, you don't have to worry about sitting it on top of Apache (what you're using) or Lighthttpd. Ruby on Rails comes with a lightweight server called Mongrel that's literally just a single command-line entry away from being booted up while you work on your application.
0

Posted 29 March 2010 - 01:27 AM (#7) User is offline   Newt 

  • Member
  • Group: Members
  • Posts: 438
  • Joined: 18-November 08

View PostBobby, on 11 March 2010 - 04:04 AM, said:

I was going to edit my last post to give you an example of the language. But I can't seem to edit it, so I'll double post.

class Greeter
  attr_accessor :first_name, :last_name
  
  def initialize
    @first_name = ""
    @last_name = ""
  end
  
  def say_hello
    puts "Hello, #{@first_name} #{@last_name}!  Your first name has #{@first_name.length} letters in it!  Those letters are:"
    print_letters
  end

  private

  def print_letters
    @first_name.length.times do|f| 
      puts "#{first_name[f, 1]}\n"
    end
  end
end

greet = Greeter.new
greet.first_name = "Bobby"
greet.last_name = "Hensley"

greet.say_hello


That's some basic Ruby syntax for you.


Is the 'end' tag similar to the 'break' tag in JS? it looks interesting to learn.
0

Posted 01 April 2010 - 09:29 AM (#8) User is offline   Bobby 

  • Member
  • Group: Members
  • Posts: 95
  • Joined: 01-February 09
  • Gender:Male
  • LocationNew Hampshire, USA

View Postnewt, on 29 March 2010 - 01:27 AM, said:

View PostBobby, on 11 March 2010 - 04:04 AM, said:

I was going to edit my last post to give you an example of the language. But I can't seem to edit it, so I'll double post.

class Greeter
  attr_accessor :first_name, :last_name
  
  def initialize
    @first_name = ""
    @last_name = ""
  end
  
  def say_hello
    puts "Hello, #{@first_name} #{@last_name}!  Your first name has #{@first_name.length} letters in it!  Those letters are:"
    print_letters
  end

  private

  def print_letters
    @first_name.length.times do|f| 
      puts "#{first_name[f, 1]}\n"
    end
  end
end

greet = Greeter.new
greet.first_name = "Bobby"
greet.last_name = "Hensley"

greet.say_hello


That's some basic Ruby syntax for you.


Is the 'end' tag similar to the 'break' tag in JS? it looks interesting to learn.


No, Ruby also has the break method and it does the same thing as JavaScript's version (breaks the innermost loop that it's used within). Ruby's end keyword is how it terminates a block. As an example, you might have the below in JavaScript:

function say_hello ()
{
  // Say hello
}


That would translate to the following in Ruby:

def say_hello
  # Say hello
end

0

Posted 02 April 2010 - 02:06 AM (#9) User is offline   Newt 

  • Member
  • Group: Members
  • Posts: 438
  • Joined: 18-November 08

nice information there +1 rep for you.

is there any resenblance to js in ruby at all, are the loops similar?
0

Posted 02 April 2010 - 08:11 AM (#10) User is offline   Bobby 

  • Member
  • Group: Members
  • Posts: 95
  • Joined: 01-February 09
  • Gender:Male
  • LocationNew Hampshire, USA

View Postnewt, on 02 April 2010 - 02:06 AM, said:

nice information there +1 rep for you.

is there any resenblance to js in ruby at all, are the loops similar?


Honestly, no. :tongue: Ruby is a very unique language: in syntax, core language features and conventions. Here are some examples of how looping occurs in Ruby:



5.times do |iterator|
  print "Iteration number #{iterator}\n"
end

Quote

Output:

Iteration number 1
Iteration number 2
Iteration number 3
Iteration number 4
Iteration number 5



# Here's an array
my_array = ["Apples", "Oranges", "Bananas"]

my_array.each do |fruit|
  print "The current fruit is #{fruit}\n"
end

Quote

Output:

The current fruit is Apples
The current fruit is Oranges
The current fruit is Bananas



Now you can do loops using curly brackets, and you would if you're putting the loop on one line, but by popular convention you do a "do...end" block (like above). An example of using curly braces to do a one-line loop:

my_array.each { |fruit| print "#{fruit}\n" }

Quote

Output:

The current fruit is Apples
The current fruit is Oranges
The current fruit is Bananas

This post has been edited by Bobby: 02 April 2010 - 08:11 AM

0

Posted 03 April 2010 - 02:36 AM (#11) User is offline   Newt 

  • Member
  • Group: Members
  • Posts: 438
  • Joined: 18-November 08

wow nice information there bobby,

would you consider doing a tutorial in ruby on rails? id be interested in that
0

Posted 03 April 2010 - 01:50 PM (#12) User is offline   ElseAndrew 

  • English & Proud -__-
  • Group: Moderator
  • Posts: 1,919
  • Joined: 12-February 09
  • Gender:Male

Prehaps it will be included in his 'One tutorial a day' package :smile-big:
Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services