From: Sean O'Halpin Date: 2006-07-27T08:35:47+09:00 Subject: Re: For performance, write it in C On 7/26/06, Chad Perrin wrote: > On Thu, Jul 27, 2006 at 12:23:23AM +0900, Charles O Nutter wrote: > > > > You're mixing language semantics and implementation details here. [snip] > In some ways, you're right: implementation details are being mixed up > with language definition in the preceding list of features. [snip] Nope - there's no mix up. My point is that any feature of a language that requires extra work whether it be at compile time or run time incurs a cost. Those features are generally there to make life easier for us programmers, not the machine. The only way to make sure you're not paying that price is to hand-code optimised machine code for a specific processor and hardware context. No language translator can guarantee that it will produce better code (regardless of the nonsense of the 'perfect compiler'). Let me take two examples from my list. First, method lookup in OO languages. There is no way you can optimise this across the board to static jumps in a language like Ruby or Smalltalk. There will always be the requirement (imposed by the ~semantics~ of the language) to be able to find the right method at runtime. This is part of the language design which imposes constraints on the implementation that assembly languages (for example) do not have to pay. There is a cost for abstraction (a cost which I am willing to pay by the way). Of course, you can implement virtual methods in assembly, but you don't ~have~ to. In Ruby there is no choice. Everything is an object. (You can optimise most of it away, but not all). Second, closures: Chad Perrin said: > A little extra memory usage does not translate directly to performance loss. Coming from a background where I had to make everything happen in 48K, I have to disagree. And it's not always just 'a little extra memory usage'. Careless use of closures can cripple an application. See the problems the Rails team encountered. Charles - you say that closures are explicit - I beg to differ. By definition, they are surely implicit. Doesn't your argument that they can be simulated by other means contradict your statement? As for the notion that a hardware YARV processor would make a difference - how would that ameliorate the issues Ruby has with memory usage? Performance isn't just about time - space also matters. I am surprised that you think I am confusing language features with implementation details. From my point of view, it is you who are ignoring the fact that abstractions incur a cost. Best regards (I'm enjoying this discussion BTW :) Sean