![]() |
Nothing Found :(
✂️ - 27 - Why not try...
Blog
27th August 2025
Oooh, Optimising!
-=-=- So, I was sitting writing a new version of Optimisationalism for JSE, and discovered quite the spike in function vs speed.. Interestingly, it's not a bottleneck I'd noticed before, and rather than instantly post the new Optimisationalism for testing, I figured I'd try feeding the results into a chatbot, first. ![]() Hey, Mister Google Gemini, here's all the code for JSE, and here's something I'm noticing.. Multi-command and Random String are seemingly slower than everything else, and it's obvious that they're the same slow for the same reason, namely that each one has to parse 6 commands within that test, whereas the other tests have 1 command at most. We had a fairly decent discussion about how Javascript optimises things, and how I might be inadvertently un-optimising for the same of finding quicker ways for the code to run. How I was sacrificing readability for speed, and that most of the time that's not the best option. "Why do you keep using the magic number 37171650?" "That's my ICQ number, so it's wedged in my head." "Nobody's going to know that, you should use a const" and so on and so forth. But, in the end, I got it to understand my use of globals and stop adding const's all over, and it slowly started to figure out the complexities involved in writing a BASIC interpreter. "Why don't you try multi-threading difficult multi-command lines?" "How do you multi-thread, but ensure that the values are all available before completing the line? Like Print A+B, how can we be sure that both A and B have been retrieved, and added together, before the Print is activated?" "Oh, I see what you mean, that won't work in this scenario." etc, etc So, back to the problem. Each command is searched for within a maze of Switch commands. First a "Switch (Command Type)" then a "Switch (Command within that type)". This was done because a huge "Switch (All the commands)" became stupidly slow, so I split it into sections, and those seemed much more optimalised. We continued to chat, and it suggested one possible improvement might be to use a lookup object. .. "... A Lookup Object?" I asked.. .. It showed me a quick example. ![]() An Array, (hurray!) so we can jump directly to the commands we want, and each one acts as a function. Oooh, now!!! The only issue being that I'd need to sit and edit every single command, changing them from Method A, to Method B. .... *ugh* So I set about the task, and after a few hours of "delete, tab, paste, delete, }, " over and over and over again, I was finally done. Good grief, that took far too long. Could I have automated it? Sure. But with spaghetti code galore, I wasn't sure how best to automate it.. So I just did it by hand, because in the end, that was quicker than trying to solve how to automate it. I popped a test version onto my various devices, and ... ![]() ... What a complete waste of 3 hours. Probably should've been finishing off that Shoebox game, eh? New "Optimisationalism 6" will be coming soon. I just need to be sure that I'm stress-testing the right things, first. Obligatory A.I. Usage DisclaimerThis wasn't "Vibe Coding", and I frankly wouldn't let the computer code anything important for JSE. Example .. If we take a look at this little bit of code.. // In your main execution loop: const commandId = JSE_ScriptC[JSE_Line]; // Check if a handler exists and call it directly. if (commandHandlers[commandId]) { commandHandlers[commandId](); } Why did it assign JSE_ScriptC[JSE_Line] to a const? Why did it not just use JSE_ScriptC[JSE_Line] directly? It's not as if it uses it again. It's just declaring a single-use variable for no viable purpose. "Readability" it would claim.. But, no. That's not really any more or less readable, to me, it's just shoving an extra const in there for no good reason. And if this happens EVERY SINGLE TIME there's a command.. That's a LOT of declaring, freeing later and discarding of memory.. Over and over and over. This is something I learned early on doing JSE. That these "little" consts (and lets and vars) really do add up when you're squeezing every ounce out of the engine. So, no... Though the lengthy conversation (and it WAS a lengthy conversation) with the A.I. did indeed give me a number of interesting concepts and ideas, I certainly wouldn't let it code this for me. Not in this scenario. No way in hell! A.I. CornerLyrics : By me Sound Imported : Tumbly House > Reveal 🔎 | Download | Suno LinkAlternative versions | Download | Suno Link | Download | Suno Link | Download | Suno Link | Download | Suno LinkSung by Suno ![]() "Cartoon Derek (solo) put a lot of effort in, but ultimately it just wasn't worth it. (No text)" by DrawThings / Flux .. Oh dear..!! Looks like Greenie's sleeping on the Sofa, tonight. > Reveal 🔎 Views 11, Upvotes 0
Daily Blog
,
Jse
|