<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>Rails on the Run - All Comments</title>
  <id>tag:www.railsontherun.com,2008:mephisto/comments</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  
  <link href="http://www.railsontherun.com/" rel="alternate" type="text/html" />
  <updated>2008-05-13T21:06:27Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/railsontherun-comments" type="application/atom+xml" /><entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Roberto</name>
    </author>
    <id>tag:www.railsontherun.com,2007-09-27:107:1201</id>
    <published>2008-05-13T21:06:27Z</published>
    <updated>2008-05-13T21:06:27Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/AJWy27uvOaQ/ajax-pagination-in-less-than-5-minutes" rel="alternate" type="text/html" />
    <title>Comment on 'Ajax Pagination in less than 5 minutes' by Roberto</title>
<content type="html">&lt;p&gt;Hi Matt, i really appreciate your hack to will_paginate, it was excactly what o was looking for. 
I have Prototype 1.6.0.2 and Low Pro 0.5. Everything seems to work fine and it did, but with firebug i get this annoying javascript error and googling didn't help:&lt;/p&gt;

&lt;p&gt;Event.addBehavior has no properties
    application.js?1210710865()application.js?12... (line 5)
Event.addBehavior.reassignAfterAjax = true;&lt;/p&gt;

&lt;p&gt;where my application.js is exactly like your and in my view i included the javascripts like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;%= javascript_include_tag 'prototype' %&amp;gt;
&amp;lt;%= javascript_include_tag 'lowpro' %&amp;gt;
&amp;lt;%= javascript_include_tag 'remote' %&amp;gt;
&amp;lt;%= javascript_include_tag 'application' %&amp;gt;
&amp;lt;%= javascript_include_tag 'effects' %&amp;gt;
&amp;lt;%= javascript_include_tag 'controls' %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I even tried to substitute "Event.addBehavior.reassignAfterAjax = true;" with this "Event.addBehavior.reload();" but with the same result.&lt;/p&gt;

&lt;p&gt;Any ideas?&lt;/p&gt;

&lt;p&gt;Thanks in advance.&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2007/9/27/ajax-pagination-in-less-than-5-minutes</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>R. Elliott Mason</name>
    </author>
    <id>tag:www.railsontherun.com,2008-04-10:872:1192</id>
    <published>2008-05-10T19:16:33Z</published>
    <updated>2008-05-10T19:16:33Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/WzeNB-4ryTU/rails-or-merb-what-s-best-for-you" rel="alternate" type="text/html" />
    <title>Comment on 'Rails or Merb, what's best for you?' by R. Elliott Mason</title>
<content type="html">&lt;p&gt;I know that Rails is killing my 256 Slice and I am currently in the process of porting my Rails app to Merb.  Since Merb can use AR it has been a pretty decent experience.  Most people warned me that switching frameworks is suicide but since my models are fat and my controllers are skinny it has been fairly straightforward.  I &lt;em&gt;did&lt;/em&gt; have to adjust my Upload model since Merb handles uploads differently than Rails, but other than that it's been a breeze.&lt;/p&gt;

&lt;p&gt;The only thing I feel like I'm missing out on is Rails' abundance of view helpers.  It is not incredibly fun to have to code my own link_to_if, but it's not time consuming either.&lt;/p&gt;

&lt;p&gt;And I love raising NotFound (as strange as that sounds), because a 404 isn't always because there isn't a route to match the request, it could also be because a record doesn't exist.  Why Rails don't got that?&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/4/10/rails-or-merb-what-s-best-for-you</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Alain</name>
    </author>
    <id>tag:www.railsontherun.com,2007-10-04:112:1164</id>
    <published>2008-05-07T08:35:38Z</published>
    <updated>2008-05-07T08:35:38Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/3amAryNkbvs/sexy-charts-in-less-than-5-minutes" rel="alternate" type="text/html" />
    <title>Comment on 'Sexy charts in less than 5 minutes' by Alain</title>
<content type="html">&lt;p&gt;The problem was coming from the compile error in the xml.builder as reported by jamiew. Can you update your code as I do not guess whit what to replace label.
By the way I am a duplo addict ;-)&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2007/10/4/sexy-charts-in-less-than-5-minutes</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Rob Kaufman</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1161</id>
    <published>2008-05-06T20:24:48Z</published>
    <updated>2008-05-06T20:24:48Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Rob Kaufman</title>
<content type="html">&lt;p&gt;It is worth noting that Tim Harpers method only gets called when the class instantiates (which is why it is equally as fast) as Matt's cleaned up version.  The most important thing about meta-programming is knowing when to use it and when not to and to only do as little as possible.  The reasons are speed, readability and maintainability.  And remember there is nothing wrong with writing code that writes code (generators)&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Tim Harper</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1155</id>
    <published>2008-05-05T18:16:34Z</published>
    <updated>2008-05-05T18:16:34Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Tim Harper</title>
<content type="html">&lt;p&gt;The following code is just as fast, and I would write it this way over the long way :)  It's pretty clear to me.&lt;/p&gt;

&lt;pre&gt;
module MetaTimeDSL
  SECOND  = 1
  MINUTE  = SECOND * 60
  HOUR    = MINUTE * 60
  DAY     = HOUR * 24
  WEEK    = DAY * 7
  MONTH   = DAY * 30
  YEAR    = DAY * 364.25

  %w[SECOND MINUTE HOUR DAY WEEK MONTH YEAR].each do |const_name|
    meth = const_name.downcase
    class_eval &amp;lt;&amp;lt;-eof&gt;&lt;/pre&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Tim Harper</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1154</id>
    <published>2008-05-05T18:16:01Z</published>
    <updated>2008-05-05T18:16:01Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Tim Harper</title>
<content type="html">&lt;p&gt;The following code is just as fast, and I would write it this way over the long way :)  It's pretty clear to me.&lt;/p&gt;

&lt;p&gt;module MetaTimeDSL
  SECOND  = 1
  MINUTE  = SECOND * 60
  HOUR    = MINUTE * 60
  DAY     = HOUR * 24
  WEEK    = DAY * 7
  MONTH   = DAY * 30
  YEAR    = DAY * 364.25&lt;/p&gt;

&lt;p&gt;%w[SECOND MINUTE HOUR DAY WEEK MONTH YEAR].each do |const_name|
    meth = const_name.downcase
    class_eval &amp;lt;&amp;lt;-EOF
      def m_#{meth}
        self * #{const&lt;em&gt;get(const&lt;/em&gt;name)}
      end
      alias m&lt;em&gt;#{meth}s m&lt;/em&gt;#{meth}
    EOF
  end
end&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Ken Miller</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1152</id>
    <published>2008-05-05T15:27:39Z</published>
    <updated>2008-05-05T15:27:39Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Ken Miller</title>
<content type="html">&lt;p&gt;Amendment to above: in this case, it's also that you're doing the array work every time.  That could easily be moved into the generator code and out of the instance method, leaving the instance methods defined identically to the hand-coded methods.&lt;/p&gt;

&lt;p&gt;But this really supports the overall point -- metaprogramming is harder to write and understand, and contains more opportunities for bugs and sneaky performance pitfalls.  But if you really need it, it IS possible to make it perform just as well as hand-coded ruby.&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Ken Miller</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1151</id>
    <published>2008-05-05T15:21:43Z</published>
    <updated>2008-05-05T15:21:43Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Ken Miller</title>
<content type="html">&lt;p&gt;It's not metaprogramming per se that makes this slow, it's the use of define&lt;em&gt;method.  methods so defined are always slower to call than methods defined the usual way.  If you just use class&lt;/em&gt;eval and a string containing a standard method definition, you'll get results more in line with the written out version.&lt;/p&gt;

&lt;p&gt;Of course, then it's even harder to read.  Metaprogramming should really only be used if it's the only way to solve a problem, as you say, but performance is not really a reason not to.&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>DaveS</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1150</id>
    <published>2008-05-05T15:06:49Z</published>
    <updated>2008-05-05T15:06:49Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by DaveS</title>
<content type="html">&lt;p&gt;You might as well go back to assembly programming...&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>allen</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1149</id>
    <published>2008-05-05T14:43:48Z</published>
    <updated>2008-05-05T14:43:48Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by allen</title>
<content type="html">&lt;p&gt;Metaprogramming is used to add methods and features to classes at load time, not on each instantiation. Of course, doing this will require more work to dynamically create and install these methods on your Ruby classes.&lt;/p&gt;

&lt;p&gt;While the metaprogramming can be slower on load time, it it not significant considering it is only loaded once (in the production environment, though after every change to those classes in development). &lt;/p&gt;

&lt;p&gt;This should be the same in merb as rails. In a script/runner invocation or an application off the rails (CGI, command line, etc.) will have a slower load time as the class will be loaded each time your app starts up.&lt;/p&gt;

&lt;p&gt;In the end, it does provide more readable/maintainable and DRY code, if written well. Are you optimizing prematurely?&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Matt Aimonetti</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1145</id>
    <published>2008-05-05T08:35:10Z</published>
    <updated>2008-05-05T08:35:10Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Matt Aimonetti</title>
<content type="html">&lt;p&gt;Good point! At least if you care about performances.&lt;/p&gt;

&lt;p&gt;Now, if the benchmarks were close and that the slightly slower version was easier to read/understand, I would probably go for readability over performance.&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Ben</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1144</id>
    <published>2008-05-05T08:00:57Z</published>
    <updated>2008-05-05T08:00:57Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Ben</title>
<content type="html">&lt;p&gt;I seem to remember a cartoon from the 80s - GI Joe, maybe? - that always had a moral at the end; like the one in this post, however, the moral presented then often seemed to be the wrong one given the experiences the Joe team had in the preceding half-hour.&lt;/p&gt;

&lt;p&gt;Isn't the correct moral here that you should benchmark your code, metaprogrammed or otherwise?&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Matt Aimonetti</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1141</id>
    <published>2008-05-05T03:38:08Z</published>
    <updated>2008-05-05T03:38:08Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Matt Aimonetti</title>
<content type="html">&lt;p&gt;Matt Jones had a really good post, but my blog indicated that textile was enabled while only Markdown is enabled.&lt;/p&gt;

&lt;p&gt;Here is Matt's post:&lt;/p&gt;

&lt;p&gt;dohzya's comment is on target - the overhead here is in restoring the context (stack frame) that was captured by definemethod, and handling the amount.isa?(Array) case.&lt;/p&gt;

&lt;p&gt;Just lifting the Array case above define&lt;em&gt;method fails pretty badly, as the methods don't get defined on Numeric until the end. (Also note: the meta-programming code relies on the TimeDsl code in this example - m&lt;/em&gt;days calls TimeDsl's version of hours)&lt;/p&gt;

&lt;p&gt;What's really needed (if you want to go meta) is something closer to ActiveRecord's method:&lt;/p&gt;

&lt;p&gt;see &lt;a href="http://pastie.caboo.se/191414"&gt;pastie&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please look at the above pastie to see how Matt got really good perf using metaprogramming. Really interesting stuff!&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>dohzya</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1131</id>
    <published>2008-05-04T10:19:34Z</published>
    <updated>2008-05-04T10:19:34Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by dohzya</title>
<content type="html">&lt;p&gt;try to put @amount = amount.is&lt;em&gt;a?(Array) ? amount[0].send(amount[1]) : amount@ out of the define&lt;/em&gt;method. It must be compute one time only, not at each call of method...
Your can try to replace your @define_method@ by an @eval( "", binding )@ too (more slow one time only)&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
  <entry xml:base="http://www.railsontherun.com/">
    <author>
      <name>Henrik N</name>
    </author>
    <id>tag:www.railsontherun.com,2008-05-04:1128:1130</id>
    <published>2008-05-04T09:43:47Z</published>
    <updated>2008-05-04T09:43:47Z</updated>
    <link href="http://feedproxy.google.com/~r/railsontherun-comments/~3/PYjwt7BKd8c/avoid-using-metaprogramming" rel="alternate" type="text/html" />
    <title>Comment on 'Avoid using metaprogramming (seriously!)' by Henrik N</title>
<content type="html">&lt;p&gt;Oh, and the 364.25 (as opposed to 365.25) in the very first code snippet is a bug and/or typo.&lt;/p&gt;</content>  <feedburner:origLink>http://www.railsontherun.com/2008/5/4/avoid-using-metaprogramming</feedburner:origLink></entry>
</feed>
