Rails is a full-stack, open-source web framework in Ruby for writing real-world applications with joy and less code than most frameworks spend doing XML sit-ups
- What's Ruby?
Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and
to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable.
Features of Ruby:
•Ruby has simple syntax, partially inspired by Eiffel and Ada.
•Ruby has exception handling features, like Java or Python, to make it easy to handle errors.
•Ruby's operators are syntax sugar for the methods. You can redefine them easily.
•Ruby is a complete, full, pure object oriented language: OOL. This means all data in Ruby is an object, in the sense of Smalltalk: no
exceptions. Example: In Ruby, the number 1 is an instance of class Fixnum.
•Ruby's OO is carefully designed to be both complete and open for improvements. Example: Ruby has the ability to add methods to a class,
or even to an instance during runtime. So, if needed, an instance of one class *can* behave differently from other instances of the same
class.
•Ruby features single inheritance only, *on purpose*. But Ruby knows the concept of modules (called Categories in Objective-C). Modules are collections of methods. Every class can import a module and so gets all its methods for free. Some of us think that this is a much clearer
way than multiple inheritance, which is complex, and not used very often compared with single inheritance (don't count C++ here, as it
has often no other choice due to strong type checking.
•Ruby features true closures. Not just unnamed function, but with present variable bindings.
•Ruby features blocks in its syntax (code surrounded by '{' ... '}' or 'do' ... 'end'). These blocks can be passed to methods, or
converted into closures.
•Ruby features a true mark-and-sweep garbage collector. It works with all Ruby objects. You don't have to care about maintaining reference
counts in extension libraries.
•Writing C extensions in Ruby is easier than in Perl or Python, due partly to the garbage collector, and partly to the fine extension API.
SWIG interface is also available.
•Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances of
class Fixnum) and large integers (Bignum), but you need not worry over which one is used currently. If a value is small enough, an integer is
a Fixnum, otherwise it is a Bignum. Conversion occurs automatically.
•Ruby needs no variable declarations. It uses simple naming conventions to denote the scope of variables. Examples: simple 'var' =
local variable, '@var' = instance variable, '$var' = global variable. So it is also not necessary to use a tiresome 'self.' prepended to
every instance member.
•Ruby can load extension libraries dynamically if an OS allows.
•Ruby features OS independent threading. Thus, for all platforms on which Ruby runs, you also have multithreading, regardless of if the OS
supports it or not, even on MS-DOS! ;-)
•Ruby is highly portable: it is developed mostly on Linux, but works on many types of UNIX, DOS, Windows 95/98/Me/NT/2000/XP, MacOS, BeOS, OS/2, etc.
What Kind of Language Is Ruby?
In the old days, the distinction between languages was simple: they were either compiled, like C or Fortran, or interpreted, like BASIC. Compiled languages gave you speed and low-level access; interpreted languages were higher-level but slower.
Times change, and things aren't that simple anymore. Some language designers have taken to calling their creations ``scripting languages.'' By this, we guess they mean that their languages are interpreted and can be used to replace batch files and shell scripts, orchestrating the behavior of other programs and the underlying operating system. Perl, TCL, and Python have all been called scripting languages.
What exactly is a scripting language? Frankly we don't know if it's a distinction worth making. In Ruby, you can access all the underlying operating system features. You can do the same stuff in Ruby that you can in Perl or Python, and you can do it more cleanly. But Ruby is fundamentally different. It is a true programming language, too, with strong theoretical roots and an elegant, lightweight syntax. You could hack together a mess of ``scripts'' with Ruby, but you probably won't. Instead, you'll be more inclined to engineer a solution, to produce a program that is easy to understand, simple to maintain, and a piece of cake to extend and reuse in the future.
Although we have used Ruby for scripting jobs, most of the time we use it as a general-purpose programming language. We've used it to write GUI applications and middle-tier server processes, and we're using it to format large parts of this book. Others have used it for managing server machines and databases. Ruby is serving Web pages, interfacing to databases and generating dynamic content. People are writing artificial intelligence and machine learning programs in Ruby, and at least one person is using it to investigate natural evolution. Ruby's finding a home as a vehicle for exploratory mathematics. And people all over the world are using it as a way of gluing together all their different applications. It truly is a great language for producing solutions in a wide variety of problem domains.
Is Ruby for Me?
Ruby is not the universal panacea for programmers' problems. There will always be times when you'll need a particular language: the environment may dictate it, you may have special libraries you need, performance concerns, or simply an issue with training. We haven't given up languages such as Java and C++ entirely (although there are times when we wish we could).
However, Ruby is probably more applicable than you might think. It is easy to extend, both from within the language and by linking in third-party libraries. It is portable across a number of platforms. It's relatively lightweight and consumes only modest system resources. And it's easy to learn; we've known people who've put Ruby code into production systems within a day of picking up drafts of this book. We've used Ruby to implement parts of an X11 window manager, a task that's normally considered severe C coding. Ruby excelled, and helped us write code in hours that would otherwise have taken days.
Once you get comfortable with Ruby, we think you'll keep coming back to it as your language of choice.
-Useful Links
-Rails tutorials & tools .
-Documentation 1.
-Documentation 2.
-FAQ 1.
-FAQ 2.
-Applications.
.