18 ms·
Show HN: My current App Store Featured Game was written entirely in Scheme
- rrradical 13y agoI'm the author. I wrote the game and engine using the wonderful, and fast, Gambit Scheme (http://gambitscheme.org/ http://gambitscheme.org/). I needed a lisp to manipulate the puzzles, because they aren't based in a strict grid. It ended up being way more natural to program the block structures as lists rather than traditional matrices. Gambit compiles the Scheme code down to C, which I can then link to Objective-C for iOS, or port to Android or any other platform that Gambit supports.
- orthecreedence 13y agoWould really like an end-to-end guide on compiling C with objective C (and possibly some example code in gambit that shows the interfacing you did). I'd love to be able to do this with ECL (http://ecls.sourceforge.net/ http://ecls.sourceforge.net/) to build apps in common lisp for iOS (possibly android). I know about MOCL, but I'm a pretty cheap guy, so would rather stick to open technologies and do the work myself. I'm not a scheme guy, but until you get a writeup done, would you mind posting any info you have on interfacing gambit with iOS? Good work, and thanks for sharing!!
- funcall 13y agoI did an ECL port to iOS a while back, which you can read about in the ecl links here: http://kriyative.github.io/tags/ http://kriyative.github.io/tags/ I vaguely remember someone adapting it with an ECL to android cross compilation effort. Can't find that link now. The LGPL license of ECL is something to keep in mind as you consider your options. Good luck.
- rrradical 13y agoThe standard Gambit distribution actually comes with an example iOS project. It also has a script for building the Gambit runtime for ARM (the phone) and x86. It's definitely not a 10 minute process, but shouldn't be too hard. I think I also remember some projects popping up the Gambit mailing list to make all of this easier. It might be worth searching the archives.
- anuragramdasan 13y agoMy lisp experience has been largely restricted to writing elisp. I would really love to write something in Scheme though. How well maintained and diverse are the GambitScheme libraries? I see three different sets on their packages page, do you have any experience with those or would you have some better suggestions?
- rrradical 13y agoI didn't use many libraries. It's pretty straightforward to interface with C code, so instead of writing a whole OpenGL wrapper, I just call into some C code to handle the rendering. It was somewhat tricky to get it all setup, but I followed in the footsteps of James Long (http://jlongster.com/s/jlongster-old/pages/blog/write-apps-iphone-scheme.html http://jlongster.com/s/jlongster-old/pages/blog/write-apps-i...) and a few others. I hope to contribute back what I learned and make it easier for others to use it for games in the future. It's seriously a great language for game writing.
- anuragramdasan 13y agoI agree. I would love to someday be able to build on mobile using games. It would be amazing if you could share a writeup or maybe a hello world starter template on running Gambit on iOS or android. This seems like a lovely project. Congratulations and good luck.
- Turing_Machine 13y agoWould love to see it! I ran across Long's page some time ago, but unfortunately it's way out of date.
- Touche 13y ago> How well maintained and diverse are the GambitScheme libraries? The library situation in Gambit is.... very bad. Last time I tried it (~6 months ago) you had to compile from a different branch to get Blackhole to work. Chicken Scheme has a much better ecosystem. It also compiles to C and is fast. Gambit is known for its speed so I won't say Chicken is as fast but it is "fast enough" and the ecosystem is worth the difference IMO.
- npsimons 13y agoThanks for posting this, but the link is rather anemic for this audience; any possibility of a writeup (even a quick and short one) of how you did it? I've been looking at cross-platform solutions for apps, and the best I've come up with so far is Kivy (http://kivy.org http://kivy.org) and haXe (http://haxe.org http://haxe.org), which both still require a machine running OSX to package for iOS.
- rrradical 13y agoThanks, that's a good point. I am definitely planning on writing up everything I learned in the process. It just launched a few days ago so I'm still focused on handling that at the moment. If you like I can e-mail you in the future when the article is out. There's contact info on my website: http://asivitz.com/cloudbreaker/ http://asivitz.com/cloudbreaker/
- npsimons 13y agoEh, no pressure; I'll keep an eye on your website and HN, but I'd be curious if anyone here has found ways to do cross-platform (Android, iOS, Linux, OSX, Win, etc) apps from the environment of their choosing. I'm not looking to monetize, so arguments of "investing" into platforms I don't already have are moot; this is mostly a hobby/side "what could I do if . . . " sort of thing right now, and just having scheme as another option is awesome :)
- lisper 13y agohttps://wukix.com/mocl https://wukix.com/mocl
- terhechte 13y agoI've recently spend quite some time trying to figure out what's the best way to use a Lisp in order to write multi platform games. I'm still in the researching phase, but if you need to support more than iOS & Android, then ClojureScript on top of a Javascript Game Engine (possibly with native extensions) is the best bet.
- 13y ago
- TuringTest 13y agoOh? How do you traverse vertical and horizontal structures that are wider than one block? If you have vertical lists, following a horizontal row wild involve lots of find-nth-position calls, which I wouldn't call "natural"
- rrradical 13y agoThe basic data structure is this ((0 (73 84 92)) (1 (17 95 31))) Where the 2 digit numbers are id numbers for the blocks. The single digit number to left of each row is the horizontal offset. So, shifting a row, the most elementary operation in the game, just requires incrementing the offset. Vertical shifts are done with a 90 degree rotation operation, then a horizontal shift, then a -90 degree rotation. Sometimes traversing the lists is necessary, but the most common operations are fast, and then rest are fast enough. The limiting factor in performance is definitely rendering, not the game logic.
- mcescalante 13y agoSince you mentioned it, I'd love (to download & play) a port to Android at some point :)
- rrradical 13y agoThanks! I'm planning on releasing for Android soon. Hopefully in the next month or two.
- moron4hire 13y agoAny chance you'd write a technical article on your algorithms? I'm in love with puzzle manipulation code. Seeing the sort of things you're doing would be a lot of fun.
- rrradical 13y agoYea, I'd love to write about some of that stuff. There's unfortunately a big problem with indie games getting cloned out of existence by some big publishers, so I'm a little hesitant to put all of the logic out there. I do think it would be pretty hard to implement in a traditional OO language though. There's a basic explanation of the method in another comment I've written here though.
- jorgeleo 13y agoAwesome work in so many ways. Congratulations!
- chm 13y agoAs soon as I saw the game, I thought about Gambit-C. I'm currently following a compiler class with its author.
- j_m_b 13y ago> I'm currently following a compiler class with its author. Is this an online source? I would love to see a compiler course by someone like Marc Feeley!
- rrradical 13y agoMe too! That would be amazing!
- chm 13y agoNo, it's at the Université de Montréal.
- Flow 13y agoDoes the course have a public page for us to see?
- j_m_b 13y agoI did some digging before I ask chm originally, here is what I found: There are some lecture notes for the compiler class in French: http://www.iro.umontreal.ca/~feeley/cours/ift3065-ift6232/ http://www.iro.umontreal.ca/~feeley/cours/ift3065-ift6232/ Chrome automatically translated that resource for me. Here is Feely giving a talk about a Scheme to javascript compiler: http://www.iro.umontreal.ca/~boucherd/mslug/meetings/20041020/minutes-en.html http://www.iro.umontreal.ca/~boucherd/mslug/meetings/2004102... chm: Lucky... it would be awesome to do a compiler class in Scheme! Could you please tell Feely that some people on Hacker News would be thrilled if he made his lectures available online?
- chm 13y ago
- seivan 13y agoI am so jealous and incredibly happy that you shipped - nice work. I wish I could do that as well.
- rrradical 13y agoThank you! No time like the present to start. Just do your best and then keep redefining what your best is.
- jlongster 13y agoAwesome work! I'm continually blown away that people still reference my old work on porting Gambit Scheme for iOS. Almost makes me want to play around with it again. :)
- rrradical 13y agoYes! So glad you saw this! I had trouble getting the server based repl working, so here's the in-game repl I ended up implementing as a Quake-type dev console: http://imgur.com/J6ozzT6 http://imgur.com/J6ozzT6 (Obviously disabled in the App Store version.) I may be getting ahead of myself, but I think it's a GREAT language for writing games, and is going to take off at some point.
- jlongster 13y agoVery cool! Hooking up the internal gambit REPL was finicky because it never got much love. I think Marc polished it up somewhere though. Still, a quick in-game REPL like that goes a long way. The cool thing about having a real Gambit REPL was that you could use the Gambit debugger in real-time. So if an error ever occurred, the debugger REPL would pop up and you could step around. You also get all the builtin stuff for inspecting cooperative threads and such. Anyway, it would be a great minimalistic environment if it was fleshed out more. Part of my mission in the JavaScript world is to bring these concepts to more people, and hopefully lead them to Clojure/Scheme/etc. Did you use a module system? Last I remember Black Hole was getting really advanced. Did that ever take off within Gambit?
- malandrew 13y agoI would love to hear more about what you're working on to bring these concepts to the Javascript world, since we at famo.us are interested in the same.
- jlongster 13y agoYou can see a few things on my blog: http://jlongster.com/ http://jlongster.com/. Recently I've been helping out with the sweet.js project (http://sweetjs.org/ http://sweetjs.org/) to implement macros in JS. People really need to understand how macros transform a language. It's going really well so far. I'm also working on the idea of live evaluation. Most devs are used to writing code and refreshing the page. There are tools that help with live evaluation, but they all suck. I am working on something that will give you a better connection with your code, and fully support the idea of incrementally coding up an app. I'm not focusing on specific Lisp/Scheme features, but more about the philosophy behind them. Any project I do I try to expose the good stuff that I learned from Scheme.
- matheusbn 13y agoWell done! Gameplay video link: https://www.youtube.com/watch?v=1T11wl70wjc https://www.youtube.com/watch?v=1T11wl70wjc
- mjt0229 13y agoNice work! I think I played ultimate with you this past summer, and we talked about this on the way to a game.
- rrradical 13y agoWoah, small world! Not sure who this is though. Shoot me an e-mail? Contact info on website, asivitz.com
- Kiro 13y agoOT but what is ultimate?
- mark212 13y agoa frisbee based game: http://en.wikipedia.org/wiki/Ultimate_(sport) http://en.wikipedia.org/wiki/Ultimate_(sport) my college football team played it as a spring sport during "optional" workouts and it was brutal. Like rugby, only with a forward pass.
- lumens 13y agoFWIW, OP has also made an Ultimate Frisbee game for iOS, sponsored by Major League Ultimate, the biggest professional Ultimate Frisbee league going: http://asivitz.com/champ_ultimate/index http://asivitz.com/champ_ultimate/index
- rrradical 13y agoA great sport: http://www.youtube.com/watch?v=uq3pg0JcJSI http://www.youtube.com/watch?v=uq3pg0JcJSI
- keithflower 13y agoThe Gambit interpreter (REPL) itself also runs on the iPhone https://itunes.apple.com/us/app/gambit-repl/id434534076?mt=8 https://itunes.apple.com/us/app/gambit-repl/id434534076?mt=8 and on the Android platform (updating it with the latest version of Gambit is on my todo list): http://apps.keithflower.org/?page_id=152 http://apps.keithflower.org/?page_id=152 http://apps.keithflower.org/?p=223 http://apps.keithflower.org/?p=223 https://play.google.com/store/apps/details?id=org.keithflower.gambit https://play.google.com/store/apps/details?id=org.keithflowe... Note that this is just the interpreter itself - not a very good way of writing games for Android.
- weavie 13y agoIf you could update it so you could make the scripts edit fields full screen that would be awesome! it is really hard editing then in the tiny boxes they are at the minute.
- keithflower 13y agoThanks for the feedback. The intent in that version was to mimic Marc's (Gambit author Marc Feeley) past iOS version as closely as possible (via webview) - I'll see what he's doing with his latest iOS version and also try to include a full screen option.
- xkarga00 13y agoJust downloaded and tried the app. Simple and elegant, very good work!
- tokipin 13y agoI thought "non-Objective C" languages weren't allowed in the App store, or something like that.
- sandyarmstrong 13y agoThat was never consistently enforced, and was eventually removed as a rule.
- deadfall 13y ago"Gambit compiles the Scheme code down to C, which I can then link to Objective-C for iOS, or port to Android or any other platform that Gambit supports."
- loumf 13y agoThat was in the rules and quickly abandoned. What they care about is that you don't load new code from the Internet. Ostensibly, the reason is security, but the real reason is they don't want you to make an app store. JavaScript in webviews is excepted because you couldn't show a website without that. If you don't get new code from the Internet (for example, someone types it in) that's ok. It's even ok to copy and paste it from the Internet.
- jcromartie 13y agoThis was assumed to be the case until approximately early 2010.
- alvatar 13y agoGreat work! :) Congratulations! For those who want to try developing in Scheme, I'm working on a project that could help you get started. Currently only Android is available, but as soon as possible iOS will be as well. http://schemespheres.org http://schemespheres.org
- codegeek 13y agoGood stuff. Interestingly, the very first programming language offered in introductory CS class at my college was Scheme at the time (2000). The power of 'car' and 'cdr' still resonates in my head. At times, the parenthesis used to give me dyslexia but good old days of doing stuff like: (car(cdr(car(cdr(cdr a)))))
- wonnage 13y ago(cadaddr a) :P
- codegeek 13y agobut that takes the fun out saying "car of the cudar of the cudar of...". Seriously though, such a simple concept of list manipulation can be used to solve so many problems. I never realized the power of this until a long time after.
- brudgers 13y agoThe power of Lisp is that it has a word for this concept.
- latj 13y agoGet a copy of this for the kids! http://www.amazon.com/The-Little-Schemer-4th-Edition/dp/0262560992/ http://www.amazon.com/The-Little-Schemer-4th-Edition/dp/0262...
- mentos 13y agoOne of the best CS classes I took in college was an introduction to scheme that used 'The Little Schemer' as its text book. Having only worked in imperative languages it really opened my head up!
- dmix 13y agoThe MIT course on youtube from the 80s using SCIP and Scheme was the single best time investment I've made since learning programming. It still blows my mind how much it changed my perspective on programming.
- deleted 13y ago[deleted]
- Shivetya 13y agoAfter reading the story I just have to recall stories from the guys who flew and serviced F4s, they joked they could fly without either wing simply because it was just a rocket sled. We had one guy knicknamed Major Cablecutter as he "clipped" the guidelines of a radio tower one time. He also had come back more than once with branches stuck to his F4. Being that they were only "Recon" they tended to be aggressive during war games and this game guy over stressed his airframe turning into some F18s trying to tag him. So many military planes have such high thrust to weight ratios I do not doubt that wings merely become the means to stable flight
- deleted 13y ago[deleted]
- smoyer 13y agoYour comment is great ... but it belongs with a different post.
- Oculus 13y agoI think you meant to comment on this post: https://news.ycombinator.com/item?id=7360011 https://news.ycombinator.com/item?id=7360011
- dsjoerg 13y agoWriting a whole iOS game in Scheme is about as crazy as flying an F4 with only one wing.
- curiousphil 13y agoThis comment made me think this game must have some incredible unseen angle not shown in the screenshots on the App Store. Brilliant!
- blahbl4hblahtoo 13y agoFantastic. You rock.
- oliverlord 13y agogreat work :) congrats
- rrradical 13y agothank you!
- elwell 13y agoIt shows how spoiled I am that I expected a github link.
- dogprez 13y agoI play around with this a bit, a few things I learned is that XCode 5.0's llvm crashes when compiling Gambit-C 4.7.0's generated C code. The beta for 5.1 has a fix. Here are a few demos that might help a few people: scheme REPL over TCP using chibi scheme: https://github.com/clarkeaa/Scheme_iOS_REPL https://github.com/clarkeaa/Scheme_iOS_REPL calling in and out of Gambit-C: https://github.com/clarkeaa/HelloGambit https://github.com/clarkeaa/HelloGambit You can grab a precompiled Gambit-C library from the later project if you want.
- hoprocker 13y agoIt's truly inspiring to see a project like this completed. I've been wanting to combine mobile (specifically Android) and some sort of Lisp dialect for a while. Am I interpreting correctly from some of the other components that doing the programming in a language-once-removed (ie Scheme instead of Obj-C) opens an easier path to compiling for both iOS and Android?
- rrradical 13y agoThat was part of my motivation for using Scheme, yes. Many indie developers are using the Unity engine which can compile to many different targets. (But that uses C# as far as I know.)
- arms 13y agoVery cool! I always like seeing when something is built using a typically non-traditional language for the environment. I downloaded the game to see how well it performed, and I gotta say, it's a lot of fun. Great job!
- Flow 13y agoDear rrradical, Tried your game, was not disappointed. :-) It's almost spooky that your post came at this time, for I have read a lot about Scheme->C systems this week. This PDF made a great impression on me of the gambit scheme system. http://www.iro.umontreal.ca/~gambit/Gambit-inside-out.pdf http://www.iro.umontreal.ca/~gambit/Gambit-inside-out.pdf I have a few questions for you: 1. I installed Gambit-Scheme via Brew and compiling any scheme file results in a clang segfault. How did you get around this? For now I use gcc instead. :-/ 2. Why Gambit-Scheme and not Chicken-Scheme? I can't really decide which is the better choice for writing a game. 3. Do you use continuations to make coroutines in your game?
- rrradical 13y ago1. I think the segfault is explored in this thread: http://article.gmane.org/gmane.lisp.scheme.gambit/7068/match=xcode+5 http://article.gmane.org/gmane.lisp.scheme.gambit/7068/match... Basically, the problem is with the version of llvm/clang that Apple uses in Xcode 5. Some of the newer Xcode betas might fix it. I personally use the Xcode 4 compiler. You could probably also build your own clang from their SVN. For more info you could probably ask the mailing list. 2. I definitely looked at chicken, and I can't remember my exact reason for going with gambit, but it was a practical one. I don't think I could get chicken up and running on the iphone for some reason. Chicken did seem to be better documented with better libraries. Gambit may be faster though. (I started working on this about a year ago. The situation may be completely different now.) My game isn't too complex, compared to, say, a first person shooter. I'm not sure if the GC implementation would start to matter in that circumstance. I recommend trying one and then if you're happy with it, great. If not, most of the code will be portable. 3. No. I don't have much experience with them (besides learning the basics in school). I did use a lot of closures, anonymous lambdas, and lambda builder functions. Glad you're enjoying the game!
- lumens 13y agoI love the originality on display with this game mechanic. Too many "samesies" games out there for my tastes. This developer has another puzzler in the App Store as well: Button Brigade, also quite original, but more of an adventure style puzzle game. https://itunes.apple.com/us/app/button-brigade/id542991688?mt=8 https://itunes.apple.com/us/app/button-brigade/id542991688?m... http://asivitz.com/button_brigade/index http://asivitz.com/button_brigade/index
- minikomi 13y agoWow, I've been thinking about this a lot lately. I would pay for a good series of tutorials or an ebook on this topic maybe implementing something well known like Tetris etc.
- eddieroger 13y agoSomewhere, deep in Lindley Hall at Indiana University, is an old professor exclaiming, "I told them people used it!" I wonder if I'd have taken more to Scheme if I were learning it now. At the time, I was double majoring CS and Telecom, but the world of open source hadn't been as friendly to Mac as it is now, and Macs were a prereq for TCom. Getting Scheme running on my old iBook was a pain in the ass, let alone the assignments (which still didn't match the untouchable stability of our automated grading system). I conceptually understood why I needed to learn it, and even grasped many of the concepts of what I was learning, but it wasn't the language for me.
- feeley 13y agoI just downloaded the game. Very cool! I wish I has written it... oh wait... given that I wrote Gambit, in a sense I wrote most of the game! It gives me a warm fuzzy feeling! Your in game REPL is neat. For developing games, where there's a need to explore variations quickly, it is a powerful tool. I'm currently working on a remote REPL for Gambit-JS, so that you can remotely debug Scheme code (possibly games) running in the browser.