Re: What's so great about lisp?
- From: Jon Harrop <usenet@xxxxxxxxxxxxxx>
- Date: Sun, 09 Oct 2005 13:42:57 +0100
Pascal Costanza wrote:
> Jon Harrop wrote:
>> If that were available then I'd want the final statically-checked code to
>> be compiled efficiently, i.e. without unnecessary run-time checks and
>> with optimised pattern matches and so on.
>
> That doesn't make sense.
I think it makes sense. Moreover, I think it is widely accepted and there is
a lot of evidence that it is true. For example, SBCL tries to remove
run-time checks where possible in order to improve performance.
> The majority of a program is executed very
> rarely, typically only few parts are executed most of the time. It's one
> of those 80:20 things: 80% of the time only 20% of the code is executed.
> (These are, of course, not the exact numbers, but that's the idea.)
Yes. Removing run-time checks speeds up all of the code, including the ~20%
where most of the time is spent. The advantage is significantly faster
programs.
> This means that the "efficiency" of the resulting code doesn't really
> pay off in the majority of the code - you wouldn't actually notice any
> difference. On the other hand, the removed run-time checks are areas
> where potential problems can occur.
> Think about security leaks or lack of information in case the program
> fails in unexpected ways.
No. In ML, the run-time checks are only removed when it is statically proven
to be safe to do so. SBCL can remove run-times checks without requiring
such proof, leading to unsafe programs, but only when instructed to do so.
> The only reasonable way to get efficient programs is to try to identify
> the "hot spots" and optimize them and only them. The best way to
> optimize them is to completely get rid of them. This boils down to
> finding better algorithms / execution stratetegies rather than
> fine-tuning what are essentially bad algorithms, etc.
While that is certainly true, it has nothing to do with the compiler
removing run-time checks for you.
When I want to optimise a C++ program, for example, I start by requesting
compiler optimisations on the command line (e.g. -O2) because it is easy to
do. Automated removal of run-time checks falls into the same category.
> Common Lisp implementations are allowed to ignore these declarations,
> but many do a pretty good job at interpreting them in useful ways. CMUCL
> and SBCL are especially interesting because they have a type inferencer
> that interacts with these settings (IIUC). (This doesn't mean that I
> generally recommend to focus just on those two implementations - their
> compiler is relatively slow because it apparently spends quite some time
> on optimizing code, and sometimes it is more important to a have fast
> compiler rather than have fast code.)
Does that mean that "eval" is slow to invoke with CMUCL and SBCL?
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
.
- Follow-Ups:
- Re: What's so great about lisp?
- From: Pascal Costanza
- Re: What's so great about lisp?
- References:
- Re: What's so great about lisp?
- From: Joe Marshall
- Re: What's so great about lisp?
- From: Jon Harrop
- Re: What's so great about lisp?
- From: Joe Marshall
- Re: What's so great about lisp?
- From: Jon Harrop
- Re: What's so great about lisp?
- From: Lars Brinkhoff
- Re: What's so great about lisp?
- From: Jon Harrop
- Re: What's so great about lisp?
- From: Thomas F. Bur***
- Re: What's so great about lisp?
- From: Jon Harrop
- Re: What's so great about lisp?
- From: Juliusz Chroboczek
- Re: What's so great about lisp?
- From: William Bland
- Re: What's so great about lisp?
- From: Joe Marshall
- Re: What's so great about lisp?
- From: Jon Harrop
- Re: What's so great about lisp?
- From: Pascal Costanza
- Re: What's so great about lisp?
- Prev by Date: Re: What's so great about lisp?
- Next by Date: Re: Style questions
- Previous by thread: Re: What's so great about lisp?
- Next by thread: Re: What's so great about lisp?
- Index(es):