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.

The Ruby on Rails Web Framework

Ruby on Rails is a framework for developing database-backed web applications using the Model-View-Control (MVC) pattern. Rails gives you a Ruby development environment, starting from the Ajax in the view, to the request and response in the controller, and to the domain model wrapping the database. Almost everyone from business startups to non-profits to enterprise organizations are using Rails. It is all about infrastructure, so it fits practically into any type of web application, be it software for collaboration, community, e-commerce, content management, statistics,or management. It works with a wide range of web servers and databases, just about any operating system.

Benefit of a Real Closure – What to Do with a Block Made into an Object

A closure can be reconverted into a block, so a closure can be used anywhere a block can be used. Closures are used to store the status of a block into an instance variable, once you convert a block into a closure, it is becomes an object that can by referenced by a variable. Just as they are used in other languages, closures can be passed around the object to customize behavior of methods. To pass some code to customize a method, just pass a block. But if you want to pass the same code to more than two methods — convert the block into a closure, and pass that closure object to multiple methods.

Learning Ruby

As with any other computer language, writing codes, mostly using IRB, is the best way to learn Ruby. If you have written a number of lines, place it in a file and run it. After you’ve figured out how it works, learn about the unit testing framework, try to discover the machinery that makes it work. Another way is to get involve in discussions and if you come across unanswered questions, do research, deliberate and come up with an answer. It would also be helpful if you let the program reveal itself to you, accept it as a simple program and could give you a straightforward solution to a problem.

Rails Ecosystem

The Rails program includes a host of tools and extension methods:

Generators – special Rails method that make routine the making of models, controllers, etc.
Scaffolds – type of generator that automatically creates a simple set of incorporated functionality. They are used to maintain the CRUD views and controller actions for a specific model.
Gems – pack of Ruby codes
Rails plugins – similar to Gems but are directly established to a specific Rails application.
JavaScript frameworks are openly backed by Rails – the prototype and the scriptaculous.
RDoc and RI – devices for establishing and viewing program documentation.
Rails Console – makes available a command line setting for working directly with your application.

Ruby – Hidden Open Source WEB CMS Player

railfrogOpen source content management systems are all over the internet with a majority of these pages in PHP with Perl and Java on some and a tiny bit in Rails. There is a continuing debate over the power of Rails and PHP, with php being the one adapted early by most of the web developers, rails was indeed left on the sidelines, picking up areas that PHP deemed too have a small market and thus less profitable. Mephisto for example is described as one of the less known blog engines that integrates some CMS concepts has a surprisingly powerful templating system with an aggressive caching scheme that other platforms lack or suck at. Continue Reading »

Ruby – Too Much Diversity

ulitzerThe many companies who use Rails as their platform are muddling up the overall image of the platform which may be the main reason why it fails to go into mainstream web development. There are tons of variants and combination of the less than popular yet powerful tool which seems to be on a less than unified voice, compared to that of PHP which has a solid grip on the world and the web as a whole. Most of the pages we see on the internet are based on PHP with some dedicated yet promising ones on Rails, like the new and improved Ulitzer, which is set to become the premiere viral web advertising site of the whole web. That remains to be seen yet rails is simply too powerful enough and diverse which keeps it relevant in today’s unsecured web. Continue Reading »

Next Page »