gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS homebrew announcements > DualScheme - Scheme Interpreter

#151702 - qw3rky - Mon Mar 03, 2008 6:38 pm

For the past few weeks I've been working on a Scheme implementation for the DS. It's called DualScheme.

Here's the description from the readme:

DualScheme is a halfway compliant implementation of Scheme for the DS. It includes most of the basic features of the Scheme language. It provides a REPL (read-evaluate-print-loop) that shows evaluation results on the top screen, and uses the bottom screen as a virtual keyboard. It does not implement continuations, macros, tail-call optimization, garbage collection, or error handling, and it leaves out a few syntax shortcuts, but other than that, DualScheme allows you to program on the go in the Scheme language!

You can download it from my projects page:
http://brian.grogan.jr.googlepages.com/dual_scheme.zip
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS

#151704 - simonjhall - Mon Mar 03, 2008 7:48 pm

Programming in Scheme gives me The Fear!
But yeah, kudos on the app! Can it draw to the screen, or just print text?
_________________
Big thanks to everyone who donated for Quake2

#151721 - qw3rky - Mon Mar 03, 2008 10:32 pm

"Learn the Way of the Lambda, and you will know no fear." - Alan Perlis (not really)

Lol, if you take the time to learn about Scheme, it really does make you a better coder overall. And that's a big part of my motivation for DualScheme. I want to make Scheme a bit more accessible for people.

Right now, DualScheme only deals in text, but drawing commands are a big item on my todo list for version 1.5. I wanted to push something out to people just to get it out there, but now that it's out in the wild, I am very open to suggestions. I had to hold off on graphics because I haven't figured out the best way to deal with displaying them (both screens, one screen only, which screen to draw to, etc). I'll figure it out and get the next version out sometime next week or so.
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS

#151723 - simonjhall - Mon Mar 03, 2008 11:11 pm

qw3rky wrote:
"Learn the Way of the Lambda, and you will know no fear." - Alan Perlis (not really)
Ha ha, I'll have to try that on a Scheme programmer at work :-)

I really hated *learning* to program this language whilst I was at uni - the assignments were really hardcore and marked in a really unfair way so basically everyone hated the course! Then came the second year and me and my gf accidently signed up for advanced scheme! We were like nooooooo...
I'm gonna def have a go with this - I've been looking at getting back into the lang recently or maybe having a go at lisp for a bit of variety.

In relation to the graphics, reason I asked was because there's a game team that I know of that wrote their entire renderer in Scheme. And yeah, this was on a console :-) (PS2, I think)
So I was wondering if graphics are a natural fit for the language.

edit: a bit of quick testing: if I type in something like (a 123) it'll hang! Also, reckon you could stick (, ), cons and car on their own buttons?
_________________
Big thanks to everyone who donated for Quake2

#151726 - tepples - Mon Mar 03, 2008 11:54 pm

This isn't based on SIOD or Guile, is it?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#151735 - qw3rky - Tue Mar 04, 2008 1:08 am

@simon
You have Scheme programmers at your workplace? Where do you work? And more importantly, is the company hiring? :)

I absolutely agree with you that many of the universities offering a course in Scheme often take the lesson plan to the extreme, and it's enough to turn a lot of people off to the language itself. It doesn't have to be this way and I'm hoping that DualScheme can be one way to make Scheme programming more friendly and accessible. Maybe once I get my graphics implementation going... PLT Scheme is a group of academics with some of the same concerns and their Scheme implementation is arguably the best out there.

You are also absolutely right that a game developer used Scheme to write a commercial game (sort of). The game developer was Naughty Dog. The head developer of the group, Andy Gavin (one of my heroes along with Paul Graham), wrote their own pseudo-Scheme compiler called GOAL (Game Oriented Assembly Lisp) and they used it to develop Crash Bandicoot and Jak and Dexter for the PS2. Unfortunately, they had to give it up once they were bought as a second-party developer for Sony. You can read all about it on the Wikipedia article: http://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp

When you typed in (a 123), did you define "a" as a function? (a 123) would mean a function call to "a" with 123 as the parameter. And as I mentioned in the readme, I haven't implemented error handling yet, so if you mess up with the syntax or try to use something that doesn't exist yet, it freezes and dies. That'll probably be fixed in 1.5 as well. And thanks for the suggestions about parentheses and cons, car, cdr having their own buttons. Those things are used very frequently, and I've just noticed as well that it's a pain to have to type them in all the time.

@tepples:
Nope, DualScheme does not use any of the code from SIOD or Guile (so don't worry about any license violations). I designed this from the ground-up in the best object-oriented C++ that I could muster. Why would I reinvent the wheel like that? Because this is also a big learning exercise for me. I've been trying to improve my understanding of C++ and design patterns. I was also really interested in the problem of implementing a dynamically typed, interpreted language in a statically typed, compiled language. The Interpreter Pattern proved really useful and now I understand it much better than I ever had before.
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS

#151744 - simonjhall - Tue Mar 04, 2008 10:14 am

Nah, we don't program in scheme here! It's all about the C++! Shame I have poor C++ skills, eh? Anyway, a mate of mine uses the language in his spare time. All the script-y stuff we do here is in lua (which I can't do, either!).

And yeah I was thinking of Naughty Dog - I wasn't sure if it was common knowledge that it was them who did all their stuff in scheme (and then changed it because of Sony!). Huh, I guess I should have checked wikipedia! Cool on that link btw. I'm impressed by link #1 on the page though, which has an example of what code run by their system looks like - it looks quite easy! Also the inline assembly (and the comments!) in the middle made me larf :-)

Back to your thing: no, I hadn't defined 'a'. I had actually defined a function but I made a typo and the thing locked up! So I thought I'd just see how I could replicate it.
_________________
Big thanks to everyone who donated for Quake2

#151772 - bear - Tue Mar 04, 2008 9:19 pm

I have to take a look at this later. Would be really cool if you can use this for the exercises when going through structure and interpretations of computer programs!

#151801 - qw3rky - Wed Mar 05, 2008 1:44 am

I have in fact been using SICP as a source of unit tests for DualScheme! The Wizard Book is a classic, one of my favorite books (of any genre) of all time. It really expands the way you think about programming.

Not all of the exercises will work quite yet, because DualScheme is not yet fully R4RS-compliant, but if this helps you take your studies of Scheme and computer science to a new, more portable level, than I will have accomplished one of my major goals. Now whenever I travel, I can take along my SICP book and follow along with my DS.
_________________
I've coded about 17 different implementations of Pong. It's the game dev's "hello, world".
DualScheme - Scheme Interpreter for DS

#151814 - nczempin - Wed Mar 05, 2008 10:18 am

qw3rky wrote:
I have in fact been using SICP as a source of unit tests for DualScheme! The Wizard Book is a classic, one of my favorite books (of any genre) of all time. It really expands the way you think about programming.

Not all of the exercises will work quite yet, because DualScheme is not yet fully R4RS-compliant, but if this helps you take your studies of Scheme and computer science to a new, more portable level, than I will have accomplished one of my major goals. Now whenever I travel, I can take along my SICP book and follow along with my DS.


A big ACK on SICP!