2 ms·
You can have state, several styles of OO, or even the worst sort of imperative spaghetti code in Lisp. It's not a pure functional language like Haskell -- it do
by silentbicycle 18y ago
You can have state, several styles of OO, or even the worst sort of imperative spaghetti code in Lisp. It's not a pure functional language like Haskell -- it doesn't force you to write functionally, it just has excellent support for using FP when it suits it the problem. The design of Scheme (a Lisp dialect) encourages functional programming, but it's mostly via things like naming conventions -- functions which mutate state end in exclamation marks (set!), for example. You may consider this nagging, but it's easy to ignore. It's not a bad idea to know which parts of your program depend on mutating state, though.
Good libraries, particularly multimedia ones, will be very important. Chicken Scheme has a great library collection (http://www.call-with-current-continuation.org/eggs/ http://www.call-with-current-continuation.org/eggs/) and works well with C. (Chicken compiles Scheme to C.) Other people here strongly recommend PLT Scheme, though I haven't personally used it much.
For learning functional programming in Lisp, I'd recommend starting with The Little Schemer. After that, The Seasoned Schemer and/or SICP.
I would also consider Lua under those circumstances. Game programming is one of its strongest areas, and IMHO it is a very practical and well-designed language. (Lua and Scheme are, by far, my favorites.) You can also do FP in Lua, though it's not really emphasized, so Scheme is better suited to learning it.
- mjgoins 18y agoI agree with all this, but still haven't seen any large games in scheme. Some folks made a first person shooter in haskell, however, apparently for a school project: http://www.haskell.org/haskellwiki/Frag http://www.haskell.org/haskellwiki/Frag
- silentbicycle 18y agoInteresting link! I think part of the issue is that writing a game in Haskell is a novel challenge (it's running head-on into the weak points of the language), so the people who succeed make a big deal out of it. I'm not saying they don't deserve credit, but if they had used more appropriate language(s), the game would be judged on its own merits, you know? Similarly, I find kkrieger (http://www.theprodukkt.com/kkrieger http://www.theprodukkt.com/kkrieger) quite impressive. Not because of great gameplay (I don't even like first-person shooters), but because they fit so much into 96kb. Half the original post's question is about learning functional programming. That's one of the niches where Scheme trumps almost everything else, and I also think Scheme is worth learning in general.