<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Ruby and Metaprogramming</title>
	<atom:link href="http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/feed/" rel="self" type="application/rss+xml" />
	<link>http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/</link>
	<description>Ruby and Ruby on Rails Development</description>
	<pubDate>Fri, 09 Jan 2009 23:15:19 +0000</pubDate>
	
		<item>
		<title>By: John W</title>
		<link>http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-394</link>
		<dc:creator>John W</dc:creator>
		<pubDate>Tue, 04 Dec 2007 04:26:55 +0000</pubDate>
		<guid isPermaLink="false">http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-394</guid>
		<description>This is an excellent introduction.. I've been working with RoR for the last two years, and you've cleared a lot of things up. Big thank you.</description>
		<content:encoded><![CDATA[<p>This is an excellent introduction.. I&#8217;ve been working with RoR for the last two years, and you&#8217;ve cleared a lot of things up. Big thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Free as in Time &#187; Blog Archive &#187; RoR Tuesday 19/06/2007</title>
		<link>http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-77</link>
		<dc:creator>Free as in Time &#187; Blog Archive &#187; RoR Tuesday 19/06/2007</dc:creator>
		<pubDate>Tue, 19 Jun 2007 16:09:39 +0000</pubDate>
		<guid isPermaLink="false">http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-77</guid>
		<description>[...] is a topic new to me, and here&#8217;s a post that deals with Ruby and Metaprogramming. I&#8217;ll have to dig into that [...]</description>
		<content:encoded><![CDATA[<p>[...] is a topic new to me, and here&#8217;s a post that deals with Ruby and Metaprogramming. I&#8217;ll have to dig into that [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seng Ming</title>
		<link>http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-75</link>
		<dc:creator>Seng Ming</dc:creator>
		<pubDate>Tue, 19 Jun 2007 06:16:24 +0000</pubDate>
		<guid isPermaLink="false">http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-75</guid>
		<description>Great intro. I've been meaning to dive into metaprogramming for a while now and was glad to find this article.</description>
		<content:encoded><![CDATA[<p>Great intro. I&#8217;ve been meaning to dive into metaprogramming for a while now and was glad to find this article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kamal</title>
		<link>http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-69</link>
		<dc:creator>kamal</dc:creator>
		<pubDate>Fri, 15 Jun 2007 02:16:48 +0000</pubDate>
		<guid isPermaLink="false">http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-69</guid>
		<description>I think to make this a clearer post to people who are new to Ruby metaprogramming, I would suggest removing the cattr_reader example and just stick to the simple attr_accessor. The outline would roughly be:

1. Show the typical boilerplate code in Java where you need to write setters and getters to get at instance variables.
2. Show how to achieve the same thing in Ruby, with explicit #var, #var=(other) method.
3. Weave in the story about how you can use eval, to the point of evaling the entire def var, def var=(other)
4. Generalize it by wrapping the eval in a class method called attr_accessor and replacing the explicit "var" with the symbol that's passed in.
5. ???
6. Profit!

Also, worth noting the more cautious way to create methods on the fly is to use define_method and pass in a block.</description>
		<content:encoded><![CDATA[<p>I think to make this a clearer post to people who are new to Ruby metaprogramming, I would suggest removing the cattr_reader example and just stick to the simple attr_accessor. The outline would roughly be:</p>
<p>1. Show the typical boilerplate code in Java where you need to write setters and getters to get at instance variables.<br />
2. Show how to achieve the same thing in Ruby, with explicit #var, #var=(other) method.<br />
3. Weave in the story about how you can use eval, to the point of evaling the entire def var, def var=(other)<br />
4. Generalize it by wrapping the eval in a class method called attr_accessor and replacing the explicit &#8220;var&#8221; with the symbol that&#8217;s passed in.<br />
5. ???<br />
6. Profit!</p>
<p>Also, worth noting the more cautious way to create methods on the fly is to use define_method and pass in a block.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manuel Lemos</title>
		<link>http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-68</link>
		<dc:creator>Manuel Lemos</dc:creator>
		<pubDate>Thu, 14 Jun 2007 19:33:28 +0000</pubDate>
		<guid isPermaLink="false">http://rails.aizatto.com/2007/06/15/ruby-and-metaprogramming/#comment-68</guid>
		<description>Metaprogramming does not to be done on the fly.

Actually if you do it on the fly it means you will be making your program spend more time and memory to do something that actually may not need to change on the fly.

For instance, you persistent objects model does not change at application runtime. So you do not need any metaprogramming done on the fly at runtime because you database schema will not change on the fly either.

It would be much more efficient if you code generate ORM classes in a previous compilation step because you can optimize the code generation based on the knowlegde of the model that will not change at runtime.

Metaprogramming in PHP is not a new thing. You may want to check the MetaL metaprogramming language site:

http://www.meta-language.net/

Metastorage is PHP ORM classes code generation tool based on the MetaL compiler engine. It generates very efficient ORM classes that do not need a runtime library to perform ORM tasks because all optimizations are generated at compile time. The resulting classes are very compact and fast. The generated code is very clean and readable, as if it were a real human being that have written it.

http://www.metastorage.net/</description>
		<content:encoded><![CDATA[<p>Metaprogramming does not to be done on the fly.</p>
<p>Actually if you do it on the fly it means you will be making your program spend more time and memory to do something that actually may not need to change on the fly.</p>
<p>For instance, you persistent objects model does not change at application runtime. So you do not need any metaprogramming done on the fly at runtime because you database schema will not change on the fly either.</p>
<p>It would be much more efficient if you code generate ORM classes in a previous compilation step because you can optimize the code generation based on the knowlegde of the model that will not change at runtime.</p>
<p>Metaprogramming in PHP is not a new thing. You may want to check the MetaL metaprogramming language site:</p>
<p><a href="http://www.meta-language.net/" rel="nofollow">http://www.meta-language.net/</a></p>
<p>Metastorage is PHP ORM classes code generation tool based on the MetaL compiler engine. It generates very efficient ORM classes that do not need a runtime library to perform ORM tasks because all optimizations are generated at compile time. The resulting classes are very compact and fast. The generated code is very clean and readable, as if it were a real human being that have written it.</p>
<p><a href="http://www.metastorage.net/" rel="nofollow">http://www.metastorage.net/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
