Ruby's Metaprogramming Toolbox

What is Metaprogramming?

Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data, or that do part of the work at compile time that would otherwise be done at runtime. In many cases, this allows programmers to get more done in the same amount of time as they would take to write all the code manually, or it gives programs greater flexibility to efficiently handle new situations without recompilation. (via Wikipedia)

The following tutorial lists all the methods from the Ruby core that are useful for metaprogramming as well as demonstrates common usage scenarios you will find helpful to get started. In conclution, an example is presented showing how to develop a dynamic database class like ActiveRecord which automatically generates classes for database tables and populates each model class with getters and setters for its fields.

Posted by Corban Brook Tue, 25 Aug 2009 17:23:00 GMT | 6 comments | , | Full article

Javascript: The Underappreciated Dynamic Language

I’ve always felt that Javascript is an under-appreciated language.

This is probably due to the fact that it’s been cursed in several tremendously unfortunate ways: First, Javascript has always been associated with Java, with which it shares pretty much no characteristics, leading to some undeserved lumping-with and confusion when it comes to the things that Java does badly within web browsers; Second, Javascript is a deceptively “easy” language that doesn’t initially appear to have much to it – many programmers (even ones with academic backgrounds) use it as if it was a vastly-weaker cousin of Java and for whatever reason never chance upon Javascript’s fascinating high level features; Third, Javascript appears to be “missing” a lot of features that were hip and happening through much of the crazy dot-com days and the last few years IT in general—object-orientation in the pop sense being one of them; Fourth, and most frustratingly, for many years the web and print resources available to anyone interested in the true nature of Javascript have been disgustingly atrocious and juvenile. (One might argue that this is changing nowadays with the focus on AJAX, increasing prominence of dynamic languages like Ruby, and the surging interest in LISP-like features, as evidenced by nearly every language gradually incorporating bits and pieces of LISP features into successive versions). For much of the last decade, however, any search engine query for Javascript-related terms has resulted in a barrage of junky websites with little information and a lot of cut-and-paste code for producing animated HTML effects.

To really move forward, we need to stop looking at Javascript as “C for the Web” or worse, “Crappy Java”, and instead try to interpret the language through the lens of what we’ve learned from Ruby, LISP, Scheme, Eiffel, etc. In other words, we’re asking the question: what can we squeeze out of our Javascript experience if we enter the scene expecting features we’re used to in super high level languages? To that end, what follows is a short demo of how we can extend, manipulate, and otherwise tinker with Javascript functions.

Posted by Maciek Sun, 13 Aug 2006 04:19:00 GMT | no comments | | Full article

About

    Buildingsky.net is comprised of Corban Brook and Maciek Adwent. We build experimental web applications.

    We are interested in computer science, ruby-lang, javascript, web technologies, audio synthesis, finance/economics.

Contact

Projects

Categories