Amplifying C with Lisp

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Jan 29, 2010 at 16:38

I just thought I should share this link.

http://voodoo-slide.blogspot.com/2010/01/amplifying-c.html

While I don’t have that much experience with neither C nor Lisp, being able to generate plain low-level C while having the advantage of the high-level functional Lisp seems awesome.

4 Replies

Please log in or register to post a reply.

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Jan 29, 2010 at 20:19

edit:

Sorry, I misinterpreted the article.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Jan 29, 2010 at 21:03

Very interesting. I’ve contemplated the idea of having a high-level language compile to C as a target language before, but never seen a complete system that does it. It’s certainly a useful idea if you want to create your own language generally (not just Lisp-based things). As the article points out, C compilers/libraries exist for just about every platform out there, so by compiling to C your language is immediately cross-platform (assuming you only need cross-platform libraries) and gets the benefit of very mature optimizers, code generators and suchlike.

As for Lua, uh, what? :) Of course, you could write a Lua-to-C compiler too if you liked. :)

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Jan 29, 2010 at 23:39

Well, it’s not really compiling Lisp to C.

You would actually write C code in Lisp syntax, giving you access to the extremely powerfull Lisp macro system. That way you can do stuff like resource management and exception handling by transforming the C code.

You would then compile your Lisp-ish C into plain C.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Jan 29, 2010 at 23:43

Writing “C code in Lisp syntax” sounds pretty much like writing Lisp to me. :) Yeah, maybe you’d have calls to the C standard library instead of the Lisp one, but that’s a minor detail.