At 09:36 24/04/2004 +0900, you wrote:
>Jean-Hugues ROBERT wrote:
>>At 06:07 24/04/2004 +0900, you wrote:
>>>Interesting stuff for Python, is any work like this being done in Ruby?
>>>   http://psyco.sourceforge.net/introduction.html
>>>Jim Moy
>>
>>Impressive !
>>
>>They could produce better code (less memory overhead) if Python's
>>syntax was expanded so that user could provide "hints" about what
>>deserves to be optimized. Today they suggest profiling as an
>>heuristic.
>>
>>There was a time when C compilers had #pragma register, whereby
>>users worried about speed could help the compiler produce faster
>>code (when you need speed, you need it hard).
>>
>>Better have some user directed optimizations than nothing.
>Maybe, but first you should do static type inference as much as you can, see

static type inference is great, no doubt about that, this is the way to go.
However, it may take a while until something like that is available.
Ruby is not the easiest language from the point of view of a type
inference scheme implementor. I believe there is currently more energy
spent on implementing a VM for Ruby then on any type inference solution.

So, in the mean time, I believe the end user may be willing to
spend some energy to get more speed (well... maybe not to the point
where you start considering C).

Analogy:
For sure, nowadays C optimizing compilers do a great job and
it is rare that you have to resort to "register" (which is not a #pragma,
sorry for my distorted memory) anymore. Yet, at its time, register
helped.

MinMax strategy: Minimize work for Ruby implementors, Maximize
user profit. In a perfect world, only implementors would work,
in today's world, users' skills could legitimately be leveraged.

>http://www.python.org/pycon/dc2004/papers/1/paper.pdf
>
>and if you then want to give hints there is no need to extend the syntax; 
>simply add a private method on Module for attaching type hints to methods 
>etc. I think the StarKiller has some kind of type annotation language like 
>that.

Nice !

I guess my notion of "hints" is aimed at the same goal as type
annotation language of StarKiller. However, for locality of
concerns purposes, I prefer the annotation to be in-lined versus
separated. It makes the result easier to read/modify I believe.

I believe that a syntax oriented solution is often
better looking and is worth the effort for frequent constructions.

As an example, think about the attr() method family. It is great,
for sure. Yet attr :myAttr is kind of surprising for a newbie, attr myAttr
would seem more direct (of course, once you understand that attr: is just
another method and that you may have your own variations of it... you
love that !).

The ultimate would probably be a compiler with a customizable syntax.
I mean, if I could change Smalltalk's syntax, I would use Smalltalk.
I would make it look like Ruby of course ;-)

>But speed may not be very important anyway... ;)

I suppose that I would be using C++ if it were :-)

The Psyco motto is that "higher level languages should actually
outperform lower level ones in terms of speed". I totally agree with
that statement, but I am slightly impatient.

BTW: Any one knows about some Ruby API to walk the Ruby compiler's
AST ? (I had a look at node.h and for sure such an API could exist).

Jean-Hugues