POV-Ray : Newsgroups : povray.off-topic : Sometimes, Haskell wins : Re: Sometimes, Haskell wins Server Time
10 Oct 2024 00:03:08 EDT (-0400)
  Re: Sometimes, Haskell wins  
From: nemesis
Date: 22 Sep 2008 23:00:00
Message: <web.48d85b4f56396d9e9da6bd580@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> nemesis wrote:
> > those are still highly dynamic languages where code optimizations
> > through type analysis is very much impossible.
>
> It's not impossible.

Nothing is impossible, just pretty much unlikely. :)

> It just hasn't been applied very much to those
> languages yet.

The best I've ever seen for any dynamically typed language is the Stalin
compiler for the Lisp dialect Scheme.  It creates, from normal, unoptimized
Scheme code, very fast native code roughly approaching that of compiled C.
It's a true little wonder.  OTOH, it compiles a pretty static subset of Scheme:
 no eval, no load, no redefinitions of functions, no metaprogramming with
syntatic extensions and, though not dynamicism related, no arbitrary precision
arithmetic allowed.  Still, mighty impressive.

It does whole program compilation and lots of type inferencing to achieve that.
The code produced is very fast and quite small (though no match to the tiny C
executables), but the compiler itself, having to do all kinds of analysis in
the absence of type declarations, is probably the slowest you've ever seen.
Good thing any error messages are spot-on.

Languages like python and ruby abuse of their dynamic nature by going beyond
just dynamic typing and allowing all kinds of funky and slow runtime
metaprogramming.  A native compiler has no chance here.

> You won't get the optimization that Haskell can get, but
> you can get much better than people currently get. The trick is to use
> run-time information to improve your run-time.

Yes, it's what Hotspot does on the Java runtime and also what goes on on .NET's
CLR.  Not available to the official C runtimes of python, ruby and perl, except
when running on such VMs... still, I think their extreme dynamic nature makes
things difficult and allows for lots of sloppy style programming just for the
sake of it...


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.