News for hackers. Stuff that matters.
Re:Which implementation of Lisp is best when speed matters? by palish on Friday April 13, 2007 @04:21PM (#12690)
Cool, thanks for all the great replies. Here's a little about what I'm doing.

I've worked in the video game industry for the last two years, and I've been messing around with Direct3D/OpenGL for about 5. I believe wrapping these API's in an extremely high level language like Lisp might speed up creation of a video game by about an order of magnitude, especially if I expose only very high level graphical concepts to Lisp, instead of just exposing every API function.

Speed is crucial. I've layered Ruby onto my engine, but the problem was that if I wanted 60 frames per second, I could only do 16,000 Ruby if-statements per frame. That wouldn't work at all.

Even if the high level language I choose is only 4-10 times slower than C++, that would be fine. Ruby was about 100-200 times slower.

Investigating Lisp, I only require two things:

1) Somehow, I expose C functions to Lisp. These functions take standard types as arguments (float, int, double, char ...).

For example, I might expose, from C:

(Edit: argh, I can't write a star on News.YC. The following should read: "const char (star)str")

void print_to_game_console(const char str);

Then in lisp, I'd then be able to do (print_to_game_console "Odelay!")

Something along those lines.

2) Lisp only has access to what I expose. I won't get into the boring details, but I'm distributing the Lisp script files for anyone to edit and run on other's machines, so sandboxing Lisp somehow is also pretty crucial. As long as under no circumstances can Lisp access the file system, then everything else is fine.

Thanks everyone! Shawn

Re:Which implementation of Lisp is best when speed matters? by gyro_robo on Friday April 13, 2007 @08:29PM (#12780)
Also see SWIG: http://www.swig.org/Doc1.3/Lisp.html

Here's an example of compiling and loading inline C code that works with SBCL and CMUCL: http://homepages.nyu.edu/~ys453/

SBCL: sb-alien package allows interfacing with C-code, loading shared object files, etc. See Foreign Function Interface. http://www.sbcl.org/manual/Foreign-Function-Interface.html

Re:Which implementation of Lisp is best when speed matters? by Todd on Friday April 13, 2007 @11:32PM (#12820)
I read about Google's use of Python here

http://panela.blog-city.com/python_at_google_greg_stein__sdforum.htm

a few weeks ago and saw the part where they mentioned SWIG. This was quite an insight for me since I've been trying to figure out for a years the best way to write binary extensions for Perl, Lisp, etc. To see that Google uses it as a matter of course completely sealed it for me.

I have integrated it into my project over the last couple of weeks and I've got to say it is the bee's knees. It took some thrashing to get started and there are still some dark corners (e.g., typemap voodo) but I will never go back. My first project is a high performance sockets IPC module patterned after memcached/libevent and it works like a charm.

I highly recommend SWIG.

Re:Which implementation of Lisp is best when speed matters? by aristus on Friday April 13, 2007 @04:38PM (#12693)
The folks who made Crash Bandicoot did something like that in AllegroCL about 10 years ago:

http://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp

Re:Which implementation of Lisp is best when speed matters? by palish on Friday April 13, 2007 @04:42PM (#12695)
Great! It worked for someone else, so I'm not insane! Now I just have to figure out how to do it.
Re:Which implementation of Lisp is best when speed matters? by shiro on Saturday April 14, 2007 @01:20AM (#12830)
Note that they didn't write their engine IN Allegro CL---they developed a Lisp-like language which compiled into native code, and the compiler was written in CL. If you're developing for console you won't want to drag all the runtimes comes from the implementation.

I was at a session in GDC where a guy from NaughtyDog talked about how they tuned memory access on PS2 for Jak and Dexter and that was cool; since they had full control over the compiler, they could place memory access instructions to the optimal places that would interfere least to other bus activities.

Re:Which implementation of Lisp is best when speed matters? by aristus on Friday April 13, 2007 @04:59PM (#12704)
They had some killer stuff in it, from what I can tell from interviews posted here & there. But when Sony bought them they drowned GOAL in the bathtub and ported to their own inhouse platform. Kind of sad.