kbrecordzz
An art & entertainment company
Home - About - Contact - Overview
* Company diary *


Toby Fox isn't a bad programmer - and that 1000+ values switch-case statement doesn't exist

by kbrecordzz September 29, 2025 Toby Fox, video games, Undertale

When people on the internet talk about how bad Toby Fox' programming for Undertale was, they often use the example of him - supposedly - using one single large switch-case statement for all dialogue in the game. These people think that's bad programming, either because it's inefficient or because it's just bad coding style. It's just that they are objectively wrong about so many things. Of course I'm not surprised about people on the internet collectively being wrong about something with confidence, but when Youtubers like JuniperDev spread this "Toby Fox being a bad programmer" rumour further to her 1.5 million (as of currently) viewers, it isn't just some random people being angry on a forum anymore, it's getting materialized as a truth.


JuniperDev - Undertale is a horribly made game - YouTube

I'm not going to argue for or against coding style, because people playing the game aren't affected by that because the code gets converted to an executable file. And Toby Fox was the sole programmer for Undertale so no one except himself needed to see that code. Code style taste is all up to him. It's all personal taste, and it's so easy to have strong opinions about because there is no true answer.

Okay, but are super-large switch-case statements inefficient or not? I guess the idea of them being inefficient comes from people thinking that checking if a variable has a certain value, then checking if it has another one, and doing that one after another 1000+ times, isn't the most efficient way to go. That could be true, maybe? But the people arguing for this never come with an objectively better alternative. They usually propose using some kind of object-oriented method, which is rarely more efficient than not using objects, and then it often turns out they're indeed arguing about code style more than code performance, and say that one large file with 1000 lines is "difficult to maintain". Which could be true, but it could also be not true, depending on who you are and what you like. And it still doesn't matter, because Toby Fox managed to maintain his code and release a full game. If it would have been unmaintainable... he wouldn't have been able to finish the game.

I've found some ideas on the web on how to handle lots of dialogue in possibly more efficient ways. I haven't tried them out, so they may have some drawbacks. You could have an array of strings, one string per line of dialogue, and then have a function that outputs a string from that array, taking an index value as argument. Then you wouldn't need to check all values before you go to a dialogue. However, this function would need to get called from various places, and the structure of all these other places could still be inefficient. You could also, at least in theory, have a system where you first check which room you are in, then which character to talk to, then what dialogue of that character to choose, and this could lead to less if statements per dialogue, since you only test 10 rooms, 10 characters and then 10 dialogues, instead of testing 1000 dialogue values every time. But this may have drawbacks too, because I haven't tested it in real life. However, having one large switch-case statement like Toby Fox isn't bad. It could probably be better, but that could be said about everything. I also want to say that people arguing against Toby Fox' code have no idea how computers work. Checking if a variable has a certain numeric value, even if it's done thousands of times, is extremely easy for a computer, and doesn't compare at all to other things like graphics rendering and all the overhead object-orientation adds (which is funny since this is what people reach for when trying to explain better alternatives). Undertale was also made in Game Maker, and although I don't know how good it optimizes its executables, I don't think a 1000 lines switch-case statement is the worst thing happening in that Undertale binary. Game Maker was never meant for creating super efficient games, it's made for having fun while making the games, so Toby Fox probably couldn't reach peak performance in his code no matter how hard he tried. Game Maker uses a programming language, but it also allows a "drag-and-drop" system for handling events in the game, and who knows how efficient or inefficient that is, for example? Neither me or those critizising Toby Fox' programming do. Lastly, critizising code by just looking at one part of a whole system is really dumb. Believing there is one way of coding that suits all types of projects is also equally dumb.

But wait! You can delete the whole last paragraph, because the premise of "all of Undertale's dialogue is in one large file with 1000+ switch-case statements" isn't even true. If we're all reading the same decompiled Undertale project at https://github.com/fachinformatiker/undertale, only around a third of the dialogue seems to be in that one large switch-case statement file. And it's only around 500 values in the switch-case. That isn't even very much anymore! The rest of the dialogue seem to be inside of separate objects (like NPCs, etc). So to conclude, the arguments people use are pretty much wrong, and the thing they're arguing against isn't even there. I shouldn't be surprised by this, but I was really surprised by how little people care about reading just the tiniest bit of the code they're having so strong and confident opinions about. My expectations were low and they were still (anti-)surpassed.

People can say what they want, and I don't often see the point of joining the online discourse like this, because I won't reach the people who really need to be reached, but the fact that Toby Fox has received the attribute "bad programmer" by the whole online world is really unfair. Mostly because it isn't true at all, but also because of who Toby Fox is and what he does - apart from creating good games, being a force for the independent game movement and for pushing games as an art medium, he also sells his games for pretty cheap and sometimes gives away games and soundtracks for free. If someone in the game industry deserves this kind of treatment the least it's Toby Fox. Then, imagine programming a full game by yourself that runs well and isn't full of bugs and still getting called "a bad programmer" in front of 1.5 million (the viewcount of the video by JuniperDev right now) people on the internet by a Youtuber who just wants views, and who has no facts to back it up with.


Subscribe to Golden emails