415 points · by todsacerdoti · 2y ago · 81 comments
I hope this port succeeds.
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.
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
That said I have a question: is it a common pattern when using Lisp languages for games to use a flyweight object reuse pattern? This would minimize the need for GC.
If typing out "(list ...)" is annoying, it's a few lines of code to let you type {:a 3 :b 4} instead, like Clojure. And the result of that can be a plist, or a hash table, or again like Clojure one of the handful of immutable map structures available. You can also easily make the native hash tables print themselves out with the curly bracket syntax.
(On the speed front, you might be amused by https://renato.athaydes.com/posts/how-to-write-slow-rust-cod... But separately, when you want to speed up Lisp (with SBCL) even more than default, it's rather fun to be able to run disassemble on your function and see what it's doing at the assembly level, and turn up optimization hints and have the compiler start telling you (even on the individual function level) about where it has to use e.g. generic addition instead of a faster assembly instruction because it can't prove type info and you'll have to tell it/fix your code. It can tell you about dead code it removed. You can define stack-allocation if needed. Simple benchmarking that also includes processor cycles and memory allocated is available immediately with the built-in time macro...)
SBCL and other implementations compile code to machine code then execute it. That is to say, when a form is submitted to the REPL, the form is not interpreted, but first compiled then executed. The reason execution finishes quickly is because compilation finishes quickly.
There are some implementations, like CCL, with a special interpreter mode exclusively for REPL-usage.[1] However, at least SBCL and ECL will compile code, not interpret.
[1] https://github.com/Clozure/ccl/blob/v1.13/level-1/l1-readloo...
I probably am more guilty of that than I should be.
That's TempleOS technology right there.
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...
And, as mentioned, *her :)
My current unannounced project is a lot more ambitious still, being a 3D hack & slash action game. I post updates about that on the Patreon if you're interested.
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 :)
Having been in both worlds, i'm not entirely sure there's that much to be envious of.
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
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...
This isn't really my scene so I don't know the details, but I remember reading that the first 10+ million Switches produced have an unpatchable bootloader exploit. I'm sure you're correct that almost nobody actually has a hacked console, but my understanding is that they're readily available for people who want one.
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.
Block Nintendo servers, disable auto updates, use separate sysMMC and emuMMC with no unauthorized games or DLC run on the sysMMC. If you follow the main guide everyone uses now, it's pretty safe. But updating becomes a more difficult and manual process. Have to grab a zip of the new firmware from the 'net on your PC and copy it to the SD card to be installed via a homebrew method. Installing games, game updates, and DLC is similarly manual. It's not like the PS3, Vita, and 3DS(?) where you can pull it all off of official servers easily.
Oh yeah, and we're stuck with a "tethered jailbreak", that's perhaps the worst part. Any time you turn off the hacked Switch it needs to be sent a payload from your PC or phone to boot up again then.
Whether it's all worth it depends on your needs I suppose. You could get a bunch of tournament setups going with Smash (or another fighting game) + all DLC for your LAN party and save a bit of money. You can try out new singleplayer games before buying them physically. You can mod games and run emulators. Honestly the Switch scene seems largely less cool than what we had with the 3DS or Wii (Wii U was a little disappointing as well). I barely touch my Switch(es) since getting a Steam Deck.
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.
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.
I wish vendors would be just more supportive of different llvm tool chains. Rust isn't even well supported.
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.
That is why we cannot have nice things.
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://benchmarksgame-team.pages.debian.net/benchmarksgame/...
> Overall we have needed to do surprisingly little actual performance analysis and optimisation work to make Kandria run well.
Porting Yuzu to Nintendo Switch
*: Compared to my usual ideas