From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] How to write an efficient interpreter
Date: Mon, 24 Oct 2011 13:28:16 +0200 [thread overview]
Message-ID: <4EA54BD0.8090009@inria.fr> (raw)
In-Reply-To: <CAHqiZ-J15s9PiVnvT+rw8KF--OooFLyP8YRk6x+e31dTEGX_SQ@mail.gmail.com>
On 10/24/2011 11:10 AM, Diego Olivier Fernandez Pons wrote:
> I have to write an interpreter for a datatype rich purely applicative
> language. I have already written a naive interpreter (like in programming
> languages class) and was wondering what where the options for writing
> something that would perform better while keeping it maintainable by a single
> person < 5% dedicated and preferably only in core-ML (no C code or fancy ML
> extensions).
Gabriel and Gerd gave very good advice already, but here are my two
cents:
- Beware of premature optimizations. It could very well be that your
naive interpreter is already fast enough for your applications.
Test and profile to find hot spots.
- Pay special attention to your data structures, e.g. environments should
be maps, not A-lists. A good trick is to hash-cons identifiers
into unique integers: not only comparisons are much faster,
but you can use Patricia trees for your environments.
- Compiling to bytecode is probably overkill.
Hope this helps.
- Xavier Leroy
next prev parent reply other threads:[~2011-10-24 11:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-24 9:10 Diego Olivier Fernandez Pons
2011-10-24 9:58 ` Gabriel Scherer
2011-10-24 10:57 ` Gerd Stolpmann
2011-10-24 11:28 ` Xavier Leroy [this message]
2011-10-24 11:50 ` Diego Olivier Fernandez Pons
2011-10-24 12:33 ` Jérémie Dimino
2011-10-24 12:40 ` Gerd Stolpmann
2011-10-24 12:46 ` oliver
2011-10-24 12:58 ` Gerd Stolpmann
2011-10-24 21:01 ` oliver
2011-10-26 9:27 ` Diego Olivier Fernandez Pons
2011-11-07 6:45 ` Jon Harrop
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EA54BD0.8090009@inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox