Senior & Expert RoR Developers Discussion Forum by Nyros Technologies

HIRE Ruby on Rails Expert Developers Programmers Coders From India
Ruby on Rails PHP .Net Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

Background & Introduction of ruby

 
Post new topic   Reply to topic    Senior & Expert RoR Developers Discussion Forum by Nyros Technologies Index -> The Mechanics of Ruby programming
View previous topic :: View next topic  
Author Message
Divya



Joined: 14 Sep 2009
Posts: 57

PostPosted: Mon Mar 08, 2010 12:59 pm    Post subject: Background & Introduction of ruby Reply with quote

What is Ruby ?

Ruby is a pure object oriented programming language.And it is dynamic interpreted language which has many strong features of various languages.

Ruby is a very efficient and effective programming language that can perform tasks in a faster way when compared with other programming languages. It was created in 1993 by Yukihiro Matsumoto of Japan.


Ruby features:

* open source

* Object oriented

* Single inheretance

* Dynamic Typing

* Garbage Collection

* Fimilar Syntax


---- Object oriented Vs Procedural programming languages:

-- Object oriented programming Language :

* Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of datafields and methods
together with their interactions, to design applications and computer programs.

Object-Oriented Programminglanguage Examples:

Ruby,java,c++,c#,python,Eiffel,smalltalk,perl,visual basic.

Advantage :

* One of the principal advantages of object-oriented programming techniques over procedural programming techniques is that
they enable programmers to create modules that do not need to be changed when a new type of object is added.

* A programmer can simply create a new object that inherits many of its features from existing objects. This makes object-oriented programs easier to modify.

--- A procedural programming language :

* It Provides a programmer to define precisely each step in the
performance of a task.

* The programmer knows what is to be accomplished and provides through the language step-by-step instructions on how the
task is to be done.

* Using a procedural language, the programmer
specifies language statements to perform a sequence of algorithmic steps

Procedural language Examples:

BASIC, C, FORTRAN, and Pascal.

Basic Oops Concepts:

* Objects:

Objects are the basic run time entities in an object oriented system.When a program is executed , the object interacts by sending messages to one another.


* Classes:

Classes are data types based on which objects are created.
Objects with similar properties and methods are grouped together to form a Class. Thus a Class represent a set of individual objects. Characteristics of an object are represented in a class as Properties. The actions that can be performed by objects becomes functions of the class and is referred to as Methods.

---For example consider we have a Class of Cars under which Santro Xing, Alto and WaganR represents individual Objects. In this context each Car Object will have its own, Model, Year of Manufacture, Colour, Top Speed, Engine Power etc., which form Properties of the Car class and the associated actions i.e., object functions like Start, Move, Stop form the Methods of Car Class.

No memory is allocated when a class is created. Memory is allocated only when an object is created, i.e., when an instance of a class is created.

* Inheritance:

Inheritance is the process of forming a new class from an existing class or base class. The base class is also known as parent class or super class, The new class that is formed is called derived class. Derived class is also known as a child class or sub class. Inheritance helps in reducing the overall code size of the program, which is an important concept in object-oriented programming.

* Data Abstraction:

Data Abstraction increases the power of programming language by creating user defined data types. Data Abstraction also represents the needed information in the program without presenting the details.

*Data Encapsulation:

Data Encapsulation combines data and functions into a single unit called Class. When using Data Encapsulation, data is not accessed directly; it is only accessible through the functions present inside the class. Data Encapsulation enables the important concept of data hiding possible.

* Polymorphism:

Polymorphism allows routines to use variables of different types at different times. An operator or function can be given different meanings or functions. Polymorphism refers to a single function or multi-functioning operator performing in different ways.

These are the basic oops concepts.


--- Interpreted languages Vs Compiled Languages :

Interpreted language :

* In computer programming, an interpreted language is a programming
language whose programs are not directly executed by the host cpu
but rather executed (or said to be interpreted) by a software program
known as an interpreter.

* Initially, interpreted languages were compiled line-by-line; that is,
each line was compiled as it was about to be executed.

Advantages of interpreting a language:

* Interpreting a language gives implementations some additional flexibility over compiled implementations.

* Features that are often easier to implement in interpreters than in
compilers include (but are not limited to):

- platform independence (Java's byte code, for example)
- reflection and reflective usage of the evaluator (e.g. a first-order eval function)
- dynamic typing
- smaller executable program size (since implementations have flexibility to choose the instruction code)
- dynamic scoping

* Disadvantages of interpreted languages:

The main disadvantage of interpreting is a much slower speed of
program execution compared to direct machine code execution on the
host cpu.

Some of the Interpreted languages are:

* Perl,PHP,Ruby,Python ect....

Compiled Language:

* A language that requires a compiler program to turn programming
source code into an executable machine-language binary program.

* After compiling once, the program can continue to be run from its
binary form without compiling again.

* Compiled languages/programs tend to be faster than interpreted or
p-code languages, but require compilers (which can be expensive),
and are often more difficult to program in than interpreted and p-code languages

------ Ruby comparing with other languages:

Ruby vs Php:

* PHP requires semicolons at the end of lines and generally requires
curly brackets to enclose blocks of code.

* Ruby, on the other hand, uses newline characters to denote the
end of a line of code and many code constructs such as function
definitions, and various loops are ended with the word “end” rather
than being surrounded by curly braces.

* In Ruby, you don’t have to specify the return line as the return
value of the last evaluated line is returned automatically.

Ruby Vs Java

* The real difference between the Ruby and Java programming languages
lie in the method of executing code.

* Java code is first translated to a virtual machine language
(that is, converted to a machine language for a simulated computer).

* Code executed on this virtual machine executes faster than
Ruby's interpreted code.

Questions that have been raised are:

* Which type of languages, whether interpreted language or compiler
languages are fast ?

Ans: -- A compiled language runs faster than interpreter language because in compiler converts source code into machine code.

Programs are written in various programming languages but these languages can't be understood by computer directly.
So they are first converted into machine language.

-- An interpreter is also a program that translates a high-level language into a low-level one, but it does it at the moment the program is run.

You write the program using a text editor or something similar, and then instruct the interpreter to run the program.

It takes the program, one line at a time, and translates each line before running it: It translates the first line and runs it, then translates the second line and runs it etc.

The interpreter has no "memory" for the translated lines, so if it comes across lines of the program within a loop, it must translate them afresh every time that particular line runs. Consider this simple Basic program:

* The main advantages of compilers are as follows:

-They produce programs which run quickly.
-They can spot syntax errors while the program is being compiled

* The main advantages of interpreters are as follows:

- There is no lengthy "compile time", i.e. you do not have to wait between writing a program and running it, for it to compile. As soon as you have written a program, you can run it.

- They tend to be more "portable", which means that they will run on a greater variety of machines. This is because each machine can have its own interpreter for that language.

* what are the features of ruby?

- open source

- Object oriented

- Single inheretance

- Dynamic Typing

- Garbage Collection

- Fimilar Syntax

* Write an class example ?

class Example

def test

puts "hi"

end

end

object=Example.new
object.test

* What is polymorphism ?

- Polymorphism allows routines to use variables of different types at different times. An operator or function can be given different meanings or functions.

Example:

a= 3
b= 4
puts a+b
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert RoR Developers Discussion Forum by Nyros Technologies Index -> The Mechanics of Ruby programming
Page 1 of 1

 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts validates_multiparameter_assignments plugin usage:
0 vijayalakshmi 27 Wed Jul 28, 2010 4:24 am
vijayalakshmi View latest post
No new posts paperclip plugin usage in rails:
0 vijayalakshmi 23 Wed Jul 28, 2010 4:07 am
vijayalakshmi View latest post
No new posts Polymorphism
1 phani.galla 46 Tue Jul 27, 2010 3:27 pm
umamahesh_nyros View latest post
No new posts Deploying Ruby on Rails Application with Passenger
2 sivakrishna.m 630 Tue Jul 27, 2010 2:16 pm
criether View latest post
No new posts Steps to implement star-rating using acts_as_rateable plugin
0 vijayalakshmi 46 Mon Jul 26, 2010 5:47 am
vijayalakshmi View latest post
No new posts Twitter Retweet Integartion
0 Anu 41 Thu Jul 22, 2010 12:27 pm
Anu View latest post
No new posts Usage of build method in rails
0 ktulasi 30 Thu Jul 22, 2010 12:19 pm
ktulasi View latest post
No new posts Facebook Like Integration in Rails
0 Anu 53 Thu Jul 22, 2010 12:16 pm
Anu View latest post
No new posts Fshare in your Rails Application.
0 Anu 39 Thu Jul 22, 2010 12:10 pm
Anu View latest post
No new posts Installation of Postgresql in windows.
1 swaminadhan 198 Thu Jul 15, 2010 10:17 am
proximity3 View latest post




Hire an expert Ruby on Rails developer / coder / programmer or development team from India now!!

Other Forums : PHP   ::   .Net   |   Free unlimited HTML CSS templates download

Nyros Technologies   |   Kakinada City Portal   |   Developers Blog   |   About Ruby on Rails Experts   |   More