News for hackers. Stuff that matters.
Re:Loren Segal: Too Lazy to "Type" by johnnygood on Monday December 13, 2010 @11:56PM (#2003170)
This is something that has bothered me about my Ruby usage. A lot of the time, I feel like I'm writing "dynamic" code that really just needs to be pre-processed.

  class Cool
    [:ice, :soda, :snow].each do |item|
      define_method item do
        #some code
      end
    end
  end
There isn't a real reason why that couldn't be pre-processed. I don't know a ton of Java, but the idea of compile-time code generation is appealing. Does anyone know more about this?
Re:Loren Segal: Too Lazy to "Type" by ambition on Tuesday December 14, 2010 @02:07AM (#2003419)
Solving this problem in general is a major area of research. Look up "Partial Evaluation."
Re:Loren Segal: Too Lazy to "Type" by grav1tas on Tuesday December 14, 2010 @02:14AM (#2003428)
Yes! I second this. Partial evaluation is especially compelling stuff for improving efficiency. I'm glad other people on HN are into it.
Re:Loren Segal: Too Lazy to "Type" by aaronblohowiak on Tuesday December 14, 2010 @03:02AM (#2003490)
That code is only run once per application lifetime. Without risking DRY, I don't know what you mean by 'pre-processed'. Do you care if it is run at the parse time instead of the Class Object definition time?
Re:Loren Segal: Too Lazy to "Type" by sha90 on Tuesday December 14, 2010 @10:29AM (#2004442)
Pre-processed here likely means what you think it means. DRY is not really a concept meant to be applied to method definitions (IMO), but rather method bodies-- of course there are many ways to abuse the interpretation of DRY as well. As far as whether you should care about compile vs load time-- in Ruby you don't need to, but if the language had static typing, it would make a difference.
Re:Loren Segal: Too Lazy to "Type" by stephen on Tuesday December 14, 2010 @01:39PM (#2005194)
I think the reason is merely that compile-time metaprogramming hasn't been adopted in any mainstream programming language (yet).

Boo can do cool things like that though:

http://bamboo.github.com/2010/07/11/boo-meta-programming-fac...