11 ms·
Porting SBCL to the Nintendo Switch
- sleepycatgirl 2y agoHer work is just amazing. And makes me incredibly happy, as I like to write some CL here and there.
- Shinmera 2y agoAw, thank you. Happy hacking!
- aktau 2y agoRelated: https://opengoal.dev 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.
- terrycody 2y agoHow 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?
- rootnod3 2y agoAbsolutely kudos to that effort. I love hacking around with CL and some Schemes, and an effort like this is just amazing.
- colingw 2y agoI 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 https://github.com/Shirakumo/trial
- sinker 2y agoLisp languages seem well-suited for building games. The ability to evaluate code interactively without recompilation is a huge deal for feature building, incremental development, and bug-fixing. Retaining application state between code changes seems like it would be incredibly useful. Common Lisp also appears to be a much faster language than I would have blindly assumed. The main downside for me (in general, not just for game programming) is the clunkiness in using data structures - maps especially. But the tradeoff seems worth it.
- spintin 2y ago[dead]
- pjmlp 2y agoThere are 1980's papers about Lisp compilers competing with Fortran compilers, unfortunately with the AI Winter, and the high costs of such systems, people lost sight of it.
- coliveira 2y agoWell, I imagine at the time they had some LISP implementations that were very well tuned for specific high end machines, which essentially duplicated Fortran functionality. This is difficult to do for general purpose Lisps like SBCL. It was also probably very expensive.
- lispm 2y agoOne of the downsides is that implementations like SBCL have a deep integration and need things like a well performing GC implementation - to get this running on specialized game hardware is challenging. The article describes that. Getting over the hurdle of the low-level integration is difficult. The reward comes, when one gets to the point, where the rapid incremental development cycles of Common Lisp, even with connected devices, kicks in. For the old historic Naughty Dog use case, it was a development system written in Common Lisp on an SGI and a C++ runtime with low-level Scheme code on the Playstation. > Common Lisp also appears to be a much faster language than I would have blindly assumed. There are two modes: 1) fast optimized code which allows for some low-level stuff to stay with Common Lisp 2) unoptimized, but natively compiled code, which enables safe (-> the runtime does not crash) interactive and incremental development -> this mode is where much of the software can run nowadays and which is still "fast enough" for many use cases
- spsesk117 2y agoThanks 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 :)
- cschep 2y agowell said! as I was just sitting down to another day of ruby on rails (that I am grateful for!) I was thinking.. I wonder what hobby/open source projects could use some of my attention later.. .. what projects my attention could use later .. :D
- whizzter 2y agoAt least back when I was working these "blessed" tools were usually a tad hacked together, modern homebrew toolchains for many older platforms are better except for debugging support (since the devkits for the machines usually had better hooks available but also avoiding the entire GDB focus). Having been in both worlds, i'm not entirely sure there's that much to be envious of.
- fouric 2y agoThis 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...
- f1shy 2y ago- Is it not her?
- anisoco 2y agoIt is https://reader.tymoon.eu/article/436 https://reader.tymoon.eu/article/436
- f1shy 2y agoOh I did not know that she transitioned. I just remebered it was the author of portacle, that was a woman. What a world of pain must be to have to go through it. Kudos to her. Also what she does for lisp is amazing.
- Shinmera 2y agoI'm not doing the SBCL parts, that's all Charles' work that I hired him for. My work is the portability bits that Trial relies on to do whatever and the general build architecture for this, along with the initial runtime stubbing. And, as mentioned, *her :)
- cellularmitosis 2y agoHoly cow, Kandria looks amazing. Is it also developed using Trial? https://www.youtube.com/watch?v=usc0Znm-gbA https://www.youtube.com/watch?v=usc0Znm-gbA
- ducktective 2y agoI 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?
- jsheard 2y agoBecause it's well established that game developers can and will jump through whatever hoops the platform holder demands at their own expense, they don't have the leverage to be picky about the technical details when deciding which platforms to ship on. Nintendo doesn't need to create new incentives to release on the Switch when they already have the biggest incentive of all: 140+ million units sold, and a high attach rate. At least there isn't as much hoop jumping as there used to be, since the systems have all converged on using commodity CPU and GPU architectures with at most minor embellishments.
- Arelius 2y agoYeah, also whatever they would build, the other platform vendors won't choose the same thing, and it wont be the exact variant of lisp or w/e that even the few nice developers would want. I wish vendors would be just more supportive of different llvm tool chains. Rust isn't even well supported.
- pjmlp 2y agoRust isn't even available on Android NDK, even though is now used on Android. Same applies to Rust on Windows, and whatever Microsoft is doing, windows-rs isn't that great, and after what the team did with C++/WinRT I don't have high expectations. So consoles have even less reasons to support Rust.
- pjmlp 2y agoThey did in the past and the only thing people did was to port MAME and other emulators, or copies from old 8 and 16 bit days. That is why we cannot have nice things.
- noobermin 2y agoThis 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.
- Retr0id 2y ago> 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_Environment https://switchbrew.org/wiki/Setting_up_Development_Environme...
- Shinmera 2y agoYou cannot publish games with homebrew, it has to use the official SDK. Besides that, almost nobody has a jailbroken Switch, so it would make it extremely hard to play any games on anything but an emulator.
- Retr0id 2y ago> You cannot publish games with homebrew, it has to use the official SDK This doesn't surprise me much, but does Nintendo state this explicitly anywhere public? If Nintendo chose to sign an application developed using a 3rd party toolchain, there's no technical reason why it couldn't run on retail consoles.
- Arelius 2y agoYeah, maybe. But also the official SDKs are pretty good and you get support from Nintendo. It seems like a pretty big risk to use an unsupported SDK... for what benefit?
- Retr0id 2y agoI don't have access to Nintendo's SDK so I can't compare directly, but the article cites an inability to map executable pages. libnx supports this (but of course, this is moot if Nintendo wouldn't let you ship it). But the main benefit is being able to talk about and share your work without worrying about violating an NDA. https://switchbrew.github.io/libnx/jit_8h.html https://switchbrew.github.io/libnx/jit_8h.html https://switchbrew.org/wiki/JIT_services https://switchbrew.org/wiki/JIT_services
- deleted 2y ago[deleted]
- whitten 2y agoI probably missed it, but since the switch doesn’t have a keyboard how do you handle text input ?
- jsheard 2y agoThe Switch can support a USB keyboard, which would be the nice way to do it. There's already a fair number of officially published games with keyboard and/or mouse support, including a couple of programming ones. It has an on-screen keyboard too of course but you wouldn't want to rely on that more than absolutely necessary.
- Arelius 2y agoOver the network most likely?
- Shinmera 2y agoIt does have a HID keyboard API, but typically you're expected to present an on-screen keyboard.
- not_your_vase 2y agoSomewhat offtopic, just flashed through my mind: you know what would be amazing and absolutely useless at the same time? Porting Yuzu to Nintendo Switch
- laidoffamazon 2y agoThis has been done, and it’s been possible to run Switch on Switch for several months [0] (about 39 minutes into the video). [0] https://youtu.be/H1gveQUBIKk https://youtu.be/H1gveQUBIKk
- not_your_vase 2y agoShoot, it was a suspiciously genius idea* for a Friday 13th. *: Compared to my usual ideas
- jfim 2y agoSince I had to look it up, Yuzu is a Nintendo switch emulator.
- trenchgun 2y agoDoes anybody know what is the status of Trial on Mac OS? Specifically Apple Silicon
- Shinmera 2y agoI don't have a mac, let alone a silicon one, so I can't test on it (I also have no patience for Apple's BS). However, it should work. At least SBCL itself runs, and Trial is mostly portable code, so it should, too, modulo some regressions.
- nanna 2y agoI'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.
- hoten 2y agob/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/ https://www.sbcl.org/
- varjag 2y ago"Steel Bank" in turn is a homage to "Carnegie Mellon" of CMUCL.
- ArneBab 2y agoAccording to the Benchmarks Game, SBCL is roughly as fast as Node. https://benchmarksgame-team.pages.debian.net/benchmarksgame/box-plot-summary-charts.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- tmtvl 2y agoSee also https://github.com/attractivechaos/plb2 https://github.com/attractivechaos/plb2 ...where I provided the SBCL solutions, so there's probably still a significant chunk of performance to be squeezed out.
- drmeister 2y agoAwe-inspiring work Shinmera and Charles.
- dasyatidprime 2y agoHow'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.
- vindarel 2y agosee this detailed report: https://raw.githubusercontent.com/Shinmera/talks/master/els2023-kandria/paper.pdf https://raw.githubusercontent.com/Shinmera/talks/master/els2... > Overall we have needed to do surprisingly little actual performance analysis and optimisation work to make Kandria run well.
- superdisk 2y agoGreat 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.
- Shinmera 2y agoBecause, as you guessed, no implementation other than SBCL comes close to the performance needed.
- snthpy 2y agoOT 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.