Opening, Saving, Closing,Editing and Running programs in Ruby

In Ruby, you have the choice to use any text editor that is more convenient for you. Ruby provides flexibility on whatever Operating System that is used and can run as a ruby program by just simply giving the filename and mentioning of extension is not required. The file extension .rb might still be needed in other programs.

We need to pass the file for processing and execution to ruby interpreter twice. Once to go for the proper syntax errors and upon receiving the success status second time to execute it. We need to give –c and –w as command line switches to get the checking status for errors and warnings if required Here –c states the checking for syntax errors and –w demonstrates the warnings messages to be sent to programmer .If the execution is done successfully we get the actual result displayed on our computer screens.

The Ruby Language

Ruby is straightforward and easy to learn. Coding for tasks is simple and can be easily maintained. In Ruby programming things work out as you expect them to do, and no surprises will spring on you. It is a transparent language as it does not hide solutions behind syntax you have written and does not need support codes to get simple things done. Programs are expressed directly and elegantly, making coding faster and the programs readable.
It is quite astonishing that when you use Ruby, more codes can be done and it works at the first try. You will see very few syntax errors, no type violations, and far fewer bugs.

Differences of Ruby and Perl

Ruby and Perl might have a number of similarities, but there are a number of features that makes them unique from each other.

In Ruby, you won’t encounter context-dependent rules like with Perl. The array literals go in brackets instead of parentheses. A variable isn’t the same as the object to which it refers in Ruby. Instead, it’s always seen just as a reference to an object. Ruby uses “def” instead of “sub”. Semicolons are not needed after each line. You end it up with ‘end’ instead. Diamond operators are not found in Ruby and fat commas are only used in hash literals.

Features of Ruby Programming

Ruby Programming is an object-oriented program. It has four levels of variable scope which are: global, class, instance, and local. It has exemption handling. There are iterators and closures that are based on passing blocks of code. Ruby is also a native, Perl-like regular expressions at language level. The program features an automatic garbage collecting, operator overloading and is highly portable. It is has cooperative multi-threading on all platforms using green threads. It has a large standard library and DLL/shared library dynamic loading on most platforms. Ruby supports dependency injection and object runtime alteration. Ruby currently lacks full support for Unicode, though it has partial support for UTF-8.

Yukihiro Matsumoto

Yukihiro Matsumoto, also known as Matz, is a Japanese software programmer and computer scientist born on April 14, 1965 in Osaka Prefecture in Western Honshi. He is best known all over the world as the father and creator of the Ruby Programming.

According to Japan Inc. He taught himself how to program until he graduated from high school. He took up Information Science from Tsukuba University and earned a degree. During his college days, he associated himself with research that has something to do with programming languages, compilers and the like. Yukihiro Matsumoto is married with four beautiful children and serves as a missionary in the church.

Similarities of Ruby and Perl

Perl is an awesome program and it creates awesome documents, but the only problem with Perl is its complexity.

Are you aware that Perl and Ruby has a lot of similarities? Read on and learn.

The parentheses are optional and the strings work just the same. There’s a package management system that is similar to CPAN (called Ruby Gems). You can see a lot of commonly used built-ins too. Both programs have Regexes that are built right. Both have embedded doc tools. In Ruby, it is called rdocs, and lastly, there is a general delimited string and regex quoting syntax similar to Perl’s.

The Philosophy of Ruby Programming

When Yukihiro Matsumoto created the Ruby Language, he aimed to make a design mainly for the programmers to be productive and at the same time enjoy by following the principles of a good interface design. He believed that the system design must first consider the human being over what the computer needs.

The principle of the least surprise (POLS) is the principle that Ruby Language follows. “Matz” (Matsumotol’s Nick) was quoted saying that his primary design goal was to make a language that the programmer will be required minimize work and confusion. Actually, he hasn’t applied the principle olf the least surprise to the design of Ruby, but the phase is somewhat related with the Ruby On Rails Programming

Ruby as a Programming Language

The Ruby language has been used for scripting jobs, but most often it is used as a general-purpose programming language. It can be used to write GUI applications and middle-tier server processes, as well as for managing server machines and databases. Ruby is also used for working with Web pages, interfacing to databases and producing dynamic content. Some clients are using it to write artificial intelligence and machine learning programs, and have been found to be useful as a means for exploratory mathematics and formatting book publications. It is a wonderful language for creating solutions in a variety of problem domains.

All About RubyOSA

Have you heard of RubyOSA? It is a free software that retrieves the scriptable definition of of a given application and populates a new Ruby namespace with classes, methods, constants, enumerations, and all other elements described by the terminology.

For better understanding, most Mac OS X applications are scriptable, and they define their scriptable interface in an XML format. RubyOSA parses this file and creates the Ruby API on the fly. This API will do the necessary AppleEvent work transparently for you (building and sending events).

RubyOSA can be an alternative to the RubyAEOSA project. The latter is more a set of Ruby bindings for the AppleEvent C API, while RubyOSA is a more high-level framework as the AppleEvent infrastructure is completely hidden.

Ruby as ApplyScript Replacement?

With the recent developments going on between OS X and Ruby, A lot of Ruby addicts are convinced that Ruby has the potential to be the de-facto OS scripting language of choice within the next few years. A lot of programmers find AppleScript secretive or hideous enough to avoid it wherever possible. There’s an article recently that compares an AppleScript code and it’s ruby alternative:

The AppleScript Code:

tell application “TextEdit”
get paragraph 1 of document “Read Me”
end tell

The Ruby Alternative
app(’TextEdit‘).documents[’Read Me‘].paragraphs[1].get

In reality, AppleScript is much more easier to understand, but the Ruby version is easier to remember in terms of its construction and as long as you’re familiar with Ruby syntax, you won’t get lost.

Next Page »