September 13th, 2024

Porting SBCL to the Nintendo Switch

Charles Zhang's team is porting SBCL to the Nintendo Switch, facing technical challenges and incurring $17,000 in costs. They seek community support to complete the project after successfully executing Lisp code.

Read original articleLink Icon
CuriositySupportAdmiration
Porting SBCL to the Nintendo Switch

Charles Zhang and his team have been working on porting the SBCL (Steel Bank Common Lisp) runtime to the Nintendo Switch for the past two years, primarily to run their game engine, Trial. The project has faced significant challenges, particularly in adapting to the Switch's proprietary operating system and its unique constraints, such as issues with garbage collection and audio output. Despite these hurdles, they have successfully compiled and executed Lisp code on the Switch, interfaced with shared libraries, and set up the necessary graphics context using OpenGL. However, the project has incurred costs of approximately $17,000, which the developer has been funding through sales of their game, Kandria, and donations. The financial strain has raised concerns about the feasibility of continuing the project, especially given the limited income from game sales. The Switch's environment, which runs on an ARM64 Cortex-A57 chip and lacks a traditional shell or compiler suite, complicates the porting process. The team has developed a workaround to compile Lisp code on a Linux host while simulating the Switch environment. They have also utilized SBCL's immobile-code and elfinator features to adapt the code for the Switch's requirements. The developer is seeking support through platforms like Patreon to help overcome the remaining challenges and complete the port.

- The porting of SBCL to the Nintendo Switch has faced significant technical challenges.

- The project has cost approximately $17,000, funded by game sales and donations.

- The Switch's proprietary operating system complicates the development process.

- The team has successfully executed Lisp code and set up graphics using OpenGL.

- Support from the community is sought to help complete the project.

AI: What people are saying
The comments reflect a mix of curiosity, support, and technical discussion regarding the porting of SBCL to the Nintendo Switch.
  • Users express interest in the potential of using SBCL for game development on the Switch, questioning its utility compared to popular engines.
  • Several commenters share their positive experiences with Lisp and the Trial framework, emphasizing the benefits of real-time game development.
  • There are discussions about the technical challenges of using official SDKs versus homebrew options, with some questioning the rationale behind these choices.
  • Commenters highlight the significance of the project and express admiration for the developers' efforts, wishing for more support from companies like Nintendo.
  • Concerns about performance, particularly regarding garbage collection in Common Lisp for gaming, are raised, indicating a need for further exploration in this area.
Link Icon 20 comments
By @colingw - 5 months
I have being using Trial[1] for the past few weeks to test out game development in Common Lisp, and have been having a great time. Being able to alter (almost) all aspects of your game while it's running is a blessing.

I hope this port succeeds.

[1]: https://github.com/Shirakumo/trial

By @fouric - 5 months
This is super neat - SBCL is an awesome language implementation, and I've always wanted to do CL development for a "real" game console.

I'm also surprised (in a good way) that Shinmera is working on this - I've seen him a few times before on #lispgames and in the Lisp Discord, and I didn't know that he was into this kind of low-level development. I've looked at the guts of SBCL briefly and was frightened away, so kudos to him.

I wonder if SBCL (+ threading/SDL2) works on the Raspberry Pi now...

By @spsesk117 - 5 months
Thanks to the author for the fascinating and detailed write up. It feels like a lot of the time this level of detail around the specifics of 'blessed' (not homebrew) console porting are only revealed years after the end of the consoles lifetime.

As an aside, reading about this kind of deeply interesting work always makes me envious when I think about the rote software I spend all day writing :)

By @Retr0id - 5 months
> The answer to that is that while I would desperately like to share it all publicly, the NDA prevents us from doing so.

I'm curious what the rationale here was for using the official SDK, rather than the unencumbered "homebrew" ones[0].

As a complete guess, maybe Nintendo doesn't let you officially publish games built using 3rd party SDKs?

[0] https://switchbrew.org/wiki/Setting_up_Development_Environme...

By @aktau - 5 months
Related: https://opengoal.dev.

Context: Naughty Dog used a custom Lisp-alike (GOAL) to build the Jak & Daxter series on PS2. They left enough debugging information in that it was possible to reverse engineer. The OpenGOAL project has done so, and these games can now be run on all platforms that their GOAL compiler gets ported to (x86 for now AFAIK). Would be cool to port this to the Switch.

By @nanna - 5 months
I've just bought Kandria. I'm not much of a game player so I probably won't get much play out of it, but Shinmera is clearly pushing the bounds of the Lisp world, and that's something to support.
By @sleepycatgirl - 5 months
Her work is just amazing. And makes me incredibly happy, as I like to write some CL here and there.
By @ducktective - 5 months
I wish the likes of Nintendo and Sony themselves finance such efforts. I mean it's one another way to create games (IP) for your console, what possibly could be the downside of starting something similar to Github Accelerator for your platform?
By @noobermin - 5 months
This is what I come to HN for. Kudos to OP and their colleague. I know it's impossible but what a blessing it would be if Nintendo could be a little more open about their system.
By @hoten - 5 months
b/c it isn't described anywhere...

SBCL - "Steel Bank Common Lisp"

> Steel Bank Common Lisp (SBCL) is a high performance Common Lisp compiler. It is open source / free software, with a permissive license. In addition to the compiler and runtime system for ANSI Common Lisp, it provides an interactive environment including a debugger, a statistical profiler, a code coverage tool, and many other extensions.

https://www.sbcl.org/

By @dasyatidprime - 5 months
How's CL's GC performance for games nowadays? I've been slightly eyeing the upcoming Autumn Lisp Game Jam myself, but last I checked all the major libre CL impls, including SBCL, still used a full stop-the-world collector, which feels like a recipe for latency spikes. I saw flashes of stuff on sbcl-devel about someone working on a lower-latency one, but I don't know whether it got anywhere.
By @not_your_vase - 5 months
Somewhat offtopic, just flashed through my mind: you know what would be amazing and absolutely useless at the same time?

Porting Yuzu to Nintendo Switch

By @superdisk - 5 months
Great article. One question I had, not to diminish this hard work, is why not use a different implementation like ECL which is pretty portable already and can compile to static C code which can just be compiled traditionally for the target? I've been doing that for a Wasm + SDL2 game in Lisp and it's been (relatively) straightforward. I suppose performance might be a issue.
By @drmeister - 5 months
Awe-inspiring work Shinmera and Charles.
By @terrycody - 5 months
How is this thing useful? Does it mean you can use the Trial to develop games completely free hassle on NS after its done, and you don't need a popular engine like Unity, Godot, Unreal?
By @trenchgun - 5 months
Does anybody know what is the status of Trial on Mac OS? Specifically Apple Silicon
By @snthpy - 5 months
OT but is there an easy way to build a game with Godot or Unity and deploy it to the Switch? I'd love this for my son.
By @rootnod3 - 5 months
Absolutely kudos to that effort. I love hacking around with CL and some Schemes, and an effort like this is just amazing.
By @whitten - 5 months
I probably missed it, but since the switch doesn’t have a keyboard how do you handle text input ?