The Mezunian

Die Positivität ist das Opium des Volkes, aber der Spott ist das Opium der Verrückten

Perhaps Writing News Articles Isn’t for Everyone Either…

From the annoyingly-titled, “I’m a Developer. I Won’t Teach My Kids to Code, and Neither Should You.” ( ¿what savage puts a period in a headline? ), which, according to the page title, is also called “Teaching kids to code: I’m a developer and I think it doesn’t actually teach important skills.”, which is either to get extra SEO juice from different keywords or a hilariously incompetent mixup from modern newspapers too cheap to give a shit anymo’:

That is, of course, ridiculous. Coding is not the new literacy. While most parents are literate and know to read to their kids, most are not programmers and have no idea what kind of skills a programmer needs.

Programmer walks into a social issue & completely misunderstands history. Yes, most parents are literate — now. But during the boom o’ literature that led to the Industrial Revolution, most people weren’t. & those people who weren’t were @ a huge disadvantage.

Coding books for kids present coding as a set of problems with “correct” solutions.

& books aimed @ teaching kids literature present them stories with just 1 “correct” story, & the vast majority o’ literary schooling is still teaching kids the “right” way to write. Your school won’t give a shit how creative a rapper Ice Cube is: you write your term papers in ebonics & you’ll get marked down. I don’t see him bemoaning the fascism o’ language arts class. Maybe that’s ’cause, looking @ some o’ the style he uses, he probably hasn’t studied writing in a while…

And if your children can just master the syntax, they’ll be able to make things quickly and easily.

Hardly any learning material tries to get beginners to “master the syntax”. In fact, most hardly talk ’bout the syntax, which is a problem for those trying to learn, in-depth, how the language they’re using works in total, but works fine for those who just want to get things done to see how it feels like. That’s why they do it — it’s training wheels.

But that is not the way programming works.

Yes, & writing books doesn’t work by taking a crayon & writing inane nonsense, but that’s how most kids learn ’cause kids are kids & aren’t smart ’nough to program like true professional programmers. But if you get them used to computers & creating things on them, then it will make it easier for them get better @ it as their brains develop mo’.

Programming is messy. Programming is a mix of creativity and determination.

So is reading & writing, so I guess kids shouldn’t bother trying to learn those, either.

While both literature & programming involve creativity, you can’t just do whatever you want. It’s an objective fact that there are programs that simply won’t run. Typing out exactly what a book tells you to type out will get you closer to avoiding that than having a kid just type random buttons on a keyboard & hope it works. Similarly, being considered “literate” requires certain rules. If your kid just writes random letters that don’t spell any true words, they fail school & aren’t considered literate ’cause, just as a random jumble o’ code doesn’t give any useful info to the computer, jumbles o’ letters don’t communicate any useful info to other people, & communication is the only reason for words & programming.

Early in my career, I wrote some code to configure and run a group of remote servers. The code worked great. At least that’s what I thought until about 18 hours later, when my phone dinged in the middle of the night telling me a group of the servers had failed. Staggering from bed to my laptop, I ran the code again to replace the broken servers. Hours later, a different group failed.

“21-year-ol’ me didn’t just copy what a workbook said. ¿Why can’t these dumb 5-year-ol’s?”.

¿What does this prove other than that this writer isn’t good @ programming, but the demand vs. supply for programmers is good ’nough that his employers can’t rely entirely on great programmers? This sometimes happens to me, ’specially when it’s an unfamiliar system somebody else made; but I would ne’er pretend to myself that this process is better than actually knowing what’s wrong & figuring out how to fix things through logic & expertise, nor feel proud o’ my ability to fix my own fuck-ups.

There wasn’t a syntax problem.

But there would be if you hadn’t figured out the syntax yet. It’s also true that college literature students don’t usually fail their final ’cause they couldn’t figure out what the word “the” means in Shakespeare, but we still need to teach children that.

This guy says “early in my career”, not “when I was learning”, so this example is completely irrelevant. I can bet you that when he did 1st learn how to program, he had to learn syntax, ’cause last time I checked, programmers weren’t born knowing any programming language.

Coding is like that. Try something. See if it works. Try again.

Only a shitty programmer codes like that. Most programmers think a’least a li’l ’bout what the code will do before typing it ’cause they’re not monkeys bashing their fingers randomly on their keyboard. I’m sure Mozilla makes their programs by just typing random strings, compiling, & seeing what shit sticks. <Hmm… “error: ‘asfsdfsa’ does not name a type”. I guess I’d better type in some other sequence o’ letters & see if that will name a type. I’ll find 1 o’ those crafty fellows ’ventually>. As for syntax, having code with coherent ’nough syntax so that your code compiles is the minimum requirement, which is why those dumb books probably focus on that when teaching kids, just like how dumb reading books waste time teaching young kids something as easy & frivolous as the alphabet before teaching things they’ll truly need, like how to judge a sentence’s trustworthiness by the information not written ’bout.

If a problem was straightforward, it would be automated or at least solved with some open-source code.

¡Stupid Kindergartens! ¡Wasting our tax $ having kids write down all the letters in the alphabet when they should just have 5-year-ol’s run “npm i alphabet –save-dev” in the terminal!

If this guy had looked outside his window @ the real world he’d be surprised by how many straightforward things are not automated. Customer service isn’t quantum mechanics, but still hasn’t been automated. & open source code comes with caveats: it may only be available for other projects that are open source, may have slight incompatibilities with your project’s goals, or may just be badly made — which leads to the catch-22 problem that, in order to know whether the open source code does what it does well, you have to be knowledgeable ’nough to know what a good version o’ the code would be, & thus need to know how to make the good code, essentially. This is why people still “reinvent the wheel” so oft: it’s a great way to learn how wheels work so you know which wheels are good & which aren’t.

Finally, ’less you take the time to carefully check the open source code, it may contain security flaws or outright spyware — & may develop them after you 1st decide to use them if you upgrade the open source code without carefully checking the code ’gain, as had legit happened to WordPress plugins after they had secretly been bought by someone unscrupulous. This is why the npm leftpad controversy has caused npm to become a laughingstock by so many programmers: it’s oft simpler to code something yourself & be sure that the code is exactly as you want it than have to trust complete strangers.

All that’s left is the difficult task of creating something unique.

Which you can’t do till you figure out how to do the things everyone’s already done. That’s why John Cormack literally started by copying code out o’ magazines & running them on his own computer. That’s why Shakespeare started by translating already-written Latin texts. Indeed, read ’bout the history o’ Shakespeare’s learning & witness how much monotonous reciting & robotic copying & memorization he had to go through in that relatively conservative school he went to. Somehow he still figured out how to create well-beloved works ( technically not “unique”, since e’en the most renowned English writer copied other people ).

Also, his claim is disproven by his own example. Configuring & running remote servers isn’t e’en close to creating something unique. The vast majority o’ programmers are doing things already done ’cause the reality o’ the costs o’ using foreign code is different from the abstract ideal this programmer made up in his head.

Besides, as that emo story o’ the Bible, “Ecclesiastes”, & many emos hereafter have said: there’s nothing new under the sun, son.

There are no books that teach you how to solve a problem no one has seen before.

Which is why it’s a good thing none o’ these books offering to get kids started programming don’t promise to do that. ¿Have these books promised that your kid will be the next Linus Torvald? I haven’t seen those books myself.

Writing unique literature is also something you can’t learn from books, & yet many societies have somehow caused the literacy rate to jump from a tiny few elites to the majority by wasting their time teaching kids to robotically memorize the basic elements o’ writing so they could use that knowledge in creative ways when they are older.

The entire basis o’ his argument is, “These books don’t teach kids everything ’bout programming so they’re baby Donald Knuths, so clearly they are completely useless”. This programmer should learn what “Perfect solution fallacy” is.

One day, my son was concerned that a chair of his was wobbly. We looked at it and he helped me isolate the problem: One of the screws was loose. I found one of our many leftover hex wrenches and showed him how to screw it back in. After that, he was curious what would happen if he screwed the other way, which he did until the screw came out. We ended up taking the chair all the way apart and putting it back together a couple of times, often mismatching pieces, before he was satisfied the job was finished. Try something. See how it works. Try again.

“& now he’s already working for Google, so clearly this is better than all those dumb books”.

People did this kind o’ thing for centuries before programming e’en existed, which proves that this isn’t sufficient for learning programming @ all. You would think a’least 1 o’ the many mechanics working in the 1800s would’ve invented the kind o’ computers & software we have now centuries earlier, since apparently knowing how to unscrew screws is sufficient knowledge to become a programmer. That’s why I always put “I spent my whole day bonking pieces together till it closely resembled a chair” @ the top o’ my resume when applying to Microsoft & Nintendo. I have no idea why they’ve ne’er called me for an interview yet. Those books he complains ’bout, meanwhile, will a’least get someone a working program, e’en if it’s not impressive in the slightest, whereas this li’l adventure doesn’t lead to a working program @ all.

Of course, getting something working is just the first step of building software.

& the 1st step is necessary for any further steps, so you better make sure, ’bove all, that you can do it. & no ’mount o’ wobbly-chair sleuthing will help you if you can’t e’en write a program with correct ’nough syntax that the compiler or interpreter can understand it @ all.

The next step is to make code clear, reusable, and neat.

Many great programs, — far greater than this guy has probably come close to doing — from ’bout every game on the NES & SNES to Linux kernel code ( which is somehow the most secure kernel code, relied on by the vast majority o’ web servers, while using those dreaded gotos ), fail these 3 criteria. There has ne’er been any true scientific, empirical evidence that “clear, reusable, and neat” code is anything beyond subjective taste.

Once, early in my career, I wrote a feature and gave it to a senior developer for review. He took one look at my sloppy spacing, mismatched lines, and erratic naming conventions and just said, “Do it again.”

¿Anyone remember how this article was almost entirely him ranting ’bout how unimportant syntax is? But now “sloppy spacing, mismatches lines, and erratic naming conventions” are o’ huge importance. Clearly teaching kids a grounding in these basic things is a waste, then. I would love to know how learning ’bout why chairs wobble would solve this problem.

The syntax was valid. It was still wrong. Good coders don’t just get something to work. They want it to be good.

Which books can’t teach you, ’cause spacing & keeping lines matching is too complicated to teach, e’en though these are subjects that can have specific, consistent answers ( e’en if people may disagree on which answers are best ). Indeed, if this writer is a professional programmer, he should know that companies have documents that specifically delineate the rules they demand you follow, like Google’s Style Guides.

He goes on to reiterate that real programming is hard — which is no different from real writing, & so goes gainst his claim that being literate in programming is completely different from being literate in human languages. This is ’cause it’s not: both are just writing. The only difference is that traditional literature is aimed @ only humans, while computer programming is aimed @ computers, which think in much mo’ radically different ways from humans. & that’s the point those who make the comparison: that just as it’s vitally important that humans be able to communicate with other humans through writing to thrive in modern society, as computers become mo’ & mo’ prevalent, it becomes mo’ & mo’ important to develop the ability to communicate with them, & those who do ’head o’ the rest may have advantages o’er those who don’t.

He continues with ’nother irrelevant example o’ showing his son how to bake cookies, & claiming that it, too, teaches his son how to program better than books that aim @ teaching programming, e’en though it teaches general skills he would probably already learn in a million o’ other places & is not sufficient for learning programming — which is why all chefs can’t also make iPhone apps.

He then ends the article with the kind o’ flowery poetic bullshit ’bout how having a “blatantly employable skill” isn’t important that only a ditsy upper-middle-class parent who’s rich ’nough that they’ll ne’er have to worry ’bout their kid being able to get a job when they grow up would write. Parents who can’t afford to keep paying for their children into their 20s or who can’t afford to game on the small chance that their child will whimsy themselves into their dream job may want to stick with the solutions that actually has empirical evidence ’hind it & make sure their children are well educated in matters that will make them employable, & thus able to keep themselves ’live when their parents are no longer ’live, as well as maybe their own kids, which will require mo’ money — money the vast majority o’ people get by being employable. When they’re doing that, they can also work on becoming creative, & use those boring ordinary skills they learned as the backbone to their creativity, since it’s actually quite hard to think ’bout things in new ways when you don’t e’en know what things are ol’. If the ditz who spewed this nonsense had read a biography o’ just ’bout any great creator they’d know that almost all o’ them, while they may have done wacky, fun experiments with wobbling chairs, also spent a significant ’mount o’ their time when young sitting the fuck down & learning fundamentals.

If this article has shown anything, it shows that most people aren’t quite as literate as popularly thought. You could say this article’s syntax was “valid” ’nough that I can identify it as English that says something, but it’s not good: its central point isn’t backed by most o’ the arguments he makes, — &, in fact, some o’ his arguments contradict his main point — & some o’ his examples are so irrelevant they verge on nonsequitor; his grammar is full o’ choppy small sentences that he doesn’t e’en try to tie together, which adds to the rambling feeling o’ this article; & for someone who emphasizes uniqueness & creativity, he’s just spewing the kind o’ empty bourgie philosophy millions o’ others have already done before just to cast the appearance o’ depth onto others without putting in the mental effort to actually say anything profound ( or e’en coherent ). Like this writer’s programming interviewer, if he had turned this in to any writing professor, they would simply say, “Do it again”.

& yet this is apparently good ’nough for Slate, & Mozilla thought this was good ’nough to show me in their amazing Pocket ads recommendations. Well, I say if all these fucking idiots on these braindead glorified blogs can rape something as important as literature every day, let your fucking kid make whatever sloppy code they want. Web developers make, on average, 50K a year; & I can say with personal experience that they have virtually no standards, as evidenced by the aforementioned npm leftpad scandal & the existence o’ JavaScript & PHP.

This writer’s central problem, in addition to being bad @ writing, is that he can’t comprehend the very basic idea that the people comparing learning coding to learning how to read are making. They’re not saying every kid should become a professional programmer any mo’ than schools teach kids how to read so they’ll all become professional writers or teach kids math so they’ll all become mathematicians. E’en when almost every kid in developed countries learn these 2 subjects, they usually are far too bad @ them to excel — as proven by this guy who obviously learned how to read & write when he was young, e’en though he ne’er became an accomplished writer ( though for some reason he thought that he could be one ).

’Course, there was a time when everyone who learned how to read & write were a minority o’ upper-class scribes & everyone considered learning to become literate useless for petty workers. Then society changes, as it tends to do. ¿How does this writer know that only professional programmers will be programing in the future? So many other professions are already invaded by technology that is becoming e’er mo’ complicated so that their users have to give e’er mo’ complex instructions that creep close to being like programming in the need for infinite options for creatives. Already professional artists learn how to program macros when working in Photoshop, many writers & accountants use regular expressions for complex search & replace, & many people on social media run into short snippets o’ HTML & CSS all the time. Someone I work with knows nothing ’bout programming, but knows ’bout “hex” color codes used for describing colors on the internet, though they don’t know what “hex” means.

Meanwhile, the ideal o’ only a few programmers making tools for everyone else to use is showing its weaknesses. The internet is slow & annoying ’cause too many people who need websites have the delusion that they can make 1 without programming & ’stead just get junk like Wix & its ilk spew out. There are too many examples o’ computer software that’s s’posed to make things easier for people breaking & spewing out error messages that only a programmer could understand, which just feeds the need for customer service. It’d be like a world where customers had to call for instructions in every place where we usually use written words — from instructions to setting up everything to knowing the ingredients o’ a food product — ’cause they ne’er bothered to learn how to read.

This writer himself demonstrates a complete hypocrisy himself in his regard: he claims that programming is too hard for the majority o’ plebs to do, & that they would be better off not trying, but has no trouble trying writing, e’en though people mo’ literate than him could tell him that he’s not good @ it. While we rightfully understand that writing & reading skills aren’t binary: we expect everyone to have a baseline level to be able to function in modern society, but only expect the highest skills in brilliant writers, this writer & many others treat programming as if you either can do it or not — e’en though the fact that this programmer apparently spent most o’ his time with remote servers ’stead o’, say, programming for NASA shows that there are clearly programmers superior than he is.

This doesn’t fit utility, as the demand for programmers is still quite high, & mostly for endeavors that don’t need the best programmers — which is, ’course, why so many people are jumping on the bandwagon, & why so many publishers are pumping out books to feed that demand. Businesses pay mo’ for programmers ’cause they can’t get ’nough for their needs. People realize that & aim for that career path so that they can make mo’ money. Thus, mo’ people want works or services that help them accomplish that goal. It’s possible this may change in the future; but it doesn’t seem like computers o’ anything is just a temporary fad. People who see that computer skills will be mo’ useful to society in the future, & thus the sentiment that mo’ people should aim for getting those skills is just being rational & useful for society. Just throwing caution to the wind & hoping someone will pay you simply for having curiosity is utterly irrational & irresponsible, & only works if you’re privileged ’nough to have people they can sponge off or scam.

Notably, the only biographies I’ve read where someone succeeded without working hard to learn tedious fundamentals when young were people who were essentially con men, like Steve Jobs1. Those are usually the people who like the spin the bullshit that these small whimsical stories are what got them successful ’cause they can’t talk ’bout what truly made them successful, since it would out them as a con man, & can’t use examples o’ actual technical knowledge, since it’s too easy to prove that these people don’t have technical skills. Thus someone like Steve Jobs would try to tell you that knowing some arcane, pseudoscientific inner knowledge is mo’ useful for something like programming ( which, Jobs, who forgot multiple times that computers need fans to keep them from o’erheating & dying, obviously couldn’t do ).

Interestingly, 1 o’ the aspects o’ being literate that schools teach you is what they call “critical reading comprehension” so you can read works & analyze what they call “authorial intent” & underlying meaning. Part o’ that includes, what they don’t call, seeing the bullshit ’hind writing. The fairy tale o’ the person who became a brilliant creator by learning not to put the cookie cutter in the middle o’ the dough is 1 o’ those. The fact that it isn’t based on any proof @ all, but just the author asserting that it is so based on logical fallacies so obvious e’en a dimwitted blogger could point them out is solved thanks to Americans’ habit o’ slobbering subservience to privileged figures, whether it’s some Silicon Valley mogul or some famous online newspaper like Slate.

Thus, why Mozilla, an organization s’posedly dedicated ’nough to fighting fake news that they show pop ups ’bout it whenever I open Firefox, decided to throw in my face an article without any science or evidence @ all, but not, say, the many scientific studies that exist. Maybe that’s good: maybe science should only be kept for the professional scientists & we plebs should just get by with quirky stories o’ being curious ’bout wobbly chairs.

But Mozilla will get their effigy in my next editorial…

Posted in Programming, Yuppy Tripe

Boskeopolis Land: Let’s Code a Crappy 2D Platformer Like Millions o’ Other People on the Internet & Lose Interest & Give Up Only a Few Months In, Part XXXXIII: Catahoneycombs

I delayed this video ’cause I felt this level may have too much content — &, in particular, too many gimmicks — for just 1 level & considered splitting it into 2 levels, which would conflict with my theme system, since I already had 3 mine levels & no other theme where this level would fit, e’en in a game that already stretched level themes beyond their logical boundaries ( quite a hefty problem for a game revolving round revolving level themes, which needs meaningful level themes for the cycling o’ said level themes to have meaning ).

I mentioned in an earlier post that I prefer to have multiple li’l gimmicks in a level than 1 all-encompassing level gimmick so that the level doesn’t feel too 1-dimensional; however, too many gimmicks either bloat the level too long ( & I feel most games have levels that are too long ) or leave some gimmicks underused, which I fear may happen here, particularly with the sticky floor gimmick. Other than a few places near the beginning that simply show without telling how sticky floors work without risk, the sticky ground is only used in 1 small section in the middle o’ the level challenging you to dodge Pufferbees while traversing sticky floor. This can be ’splained by the fact that I didn’t consider adding this gimmick till late in this level’s development: originally, this level went straight from that 1st platform with a white ant on it to the next.

’Twas mainly this gimmick I planned on cutting out into its own level, while leaving this level as ’twas originally. But in addition to not having ’nother level slot for ’nother beehive level, I came to the conclusion that there probably wasn’t much else to do with the sticky floor gimmick. Plus, I don’t think ’twas a particularly enjoyable gimmick to stretch much longer, either.

’Sides, the other gimmicks in this level aren’t strong ’nough to hold a whole level. The honey bubbles that form this level’s predominant gimmick1 are just floating water, & the honey falls are just vertical lines o’ water with greater downward force. I didn’t e’en bother to eliminate the oxygen mechanic o’ these water blocks, which I considered, but then declined, since I didn’t feel it worth the effort & felt the oxygen element added an extra complexity to these simple gimmicks, ’specially to the honey falls, adding a bit o’ extra challenge to getting all those gems down there. Meanwhile, the white ants are just a new enemy type that could hardly be called a “gimmick”. Also, I considered taking them out, since, as the video was nice ’nough to show, they glitch out sometimes for reasons I still haven’t figured out. It can’t be due to some blocks not spawning messing up their block detection, as the “blocks_work_offscreen” flag is turned on so that the square-formation bees near the beginning are already moving when you get there ( a necessity if you don’t want the 1st jump to be free & you want to ensure the bees are always in sync with each other ).

Recording this level’s video went surprisingly great: I was able to get it all in 1 take. That’s rare & surprising for a level so tricky — with so many tight jumps where it’s easy to just nick a bee or spike — that I’m considering moving this up from the 2nd cycle to the 3rd & putting “Curse o’ th’Ladder-Splayed Caves” in the 2nd cycle ’stead. The only true hitch was the obligatory level error remaining during recording: the white ant that spins off its platform into space.

I was ’specially surprised I got the time score 1st try, since I flubbed up so much, including the part where I miss the initial bee space due to brain flatulence & waited there a whole second like a buffoon. A’least I was able to show that with quick but tiny jumps you can go through the middle section with honey floor & bees without pausing, as I detest when game’s make you stop. Also, I think I miscalculated the gem score: as the video shows, e’en if you don’t collect every gem, it’s still easy to get mo’ than 10,000₧, while the score requirement is only 9,000. I should bump it up to 10,000.

This level’s music, by the way, is not by the elusive public domain composer Kevin MacLeod, who made most o’ these songs I used, but by Lobo Loco & came from my other main repository for free music ( well, Creative Commons, which works fine for me, since my game is on Creative Commons, too ), None o’ MacLeod’s songs fit a beehive theme particularly well — which you can’t blame him for, since it’s a rare level theme. I thought searching “bees” in Free Music Archive would be a far fetch, ’specially since, unlike MacLeod, that website doesn’t focus on video game themes. So you can imagine my surprise when I heard Lobo Loco’s “Save the Bees” & heard exactly what I wanted. It reminds me a lot o’ the “Flight of the Zinger” song from Diddy’s Kong Quest, used in that game’s beehive levels, which is exactly what I was thinking o’ when imagining what I wanted this level’s song to sound like.

This source code is so bad it gives me hives

Posted in Boskeopolis Land, Programming

Boskeopolis Land: Let’s Code a Crappy 2D Platformer Like Millions o’ Other People on the Internet & Lose Interest & Give Up Only a Few Months In, Part XXXXII: Good Ship Lifestyle

For once the layout & programming took mo’ time than the graphics — probably ’cause much o’ the graphics are reused from other “pirate” themed level. & for once this is actually pirate themed & not a beach or bathtub.

It’s hard for me to get difficulty right ( or I fail to get it right ), since I’m bad @ games, so I can’t tell if I made a level too ridiculous or if I just suck. ¿Does dodging some o’ these anchor bullets require luck or just sharp eyes & reflexes? I considered lengthening the minimum shoot delay, since it seems like the most seemingly unfair hits were when it shot just after shooting, but decided not to, since I figured I was just reacting too slowly.

Anyway, the gem & time scores are lenient & I’m quite sure all o’ the trouble I had gathering the footage for this day’s video was due to sloppy playing. The time video here particularly shows that off, as after near flawless playing through the 1st half I flop round as if my fingers were covered in butter & hesitate as if I developed Alzheimer’s & still make the time score — though right on the last second.

The ladder shafts & the final stair climb are so saturated with anchor bullet sprites that it caused slowdown, so I had to fiddle together some optimization tricks. The 1st 1 I did had nothing to do with sprites, but eased the level’s run load so much that it made up for it: many o’ the tiles are background tiles, & I noticed that none o’ those tiles animated or changed. I’ve realized for a while that drawing all these li’l blocks is probably 1 o’ the most inefficient things this game does, since it calls the SDL_RenderCopyEx function for each block, which valgrind has consistently told me is slow. ( This is what led me to realize many updates ago that loading a small image & tiling it for a background is slower than manually tiling it into a large image & just loading & drawing that large image once per frame ). So I created a branch o’ the background tile code & created ’nother version that @ the beginning creates a texture o’ all the level’s background tiles & just draws the portion o’ that that’s on the screen every frame, turning what could be o’er 200 SDL_RenderCopyEx calls per frame into just 1 per frame.

That seemed to get rid o’ the slowdown. But I still wasn’t sure or satisfied, so I made 1 other quick & easy optimization that was actually relevant to sprites & I should’ve fixed a while ago. When a sprite is killed off, it’s simply erased from the vector o’ sprites. I’ve read on the internet that vector’s erase method shifts all entries after the deleted entry backward to fill the space & still maintain the order o’ entries. Unfortunately, I don’t care ’bout sprite order — it’s arbitrary, anyway, based on whatever order the map reader finds them, which isn’t tied to the order the player is likely to find them. Moreo’er, this is slow — I believe worst-case O(n). So I changed it so that it now just replaces the data o’ the sprite to be deleted with the final sprite’s data & then just pop off the final sprite.

I must confess I didn’t come up with this idea myself, but learned it from this chapter on “Object Pools” o’ the book Game Programming Patterns. In fact, I’ve known ’bout it for years & used it in earlier programs I’ve made, which is why I said I should’ve used it earlier.

As an extra maybe-optimization that didn’t hurt is I set the sprites vector to reserve 50 spots @ the beginning to hopefully avoid going past the size o’ the vector & having to slowly reallocate memory, move the data, & delete the ol’ data. When considering this optimization, I considered changing the vector to a classic C array, since I wasn’t sure if vector e’en allowed you to delete any entry without automatically shifting other entries; but realized it didn’t matter, since the sprites are held as unique pointers, so I could just release the last entry’s data & reset the unique pointer o’ the sprite to be deleted to that data. I decided to stay with vector for the greater size flexibility it gives. I prefer the balance o’ safety & speed I can get by having a vector with a moderate # o’ space reserved so that having to enlarge the vector is unlikely, but still gives me the chance to enlarge the vector if absolutely needed, for some rare outcome that I can’t predict.

’Course, the fact that sprites are held as pointers & not data itself means that this vector can’t take advantage o’ data locality, — which I also, coincidentally, 1st learned ’bout from a chapter o’ Game Programming Patterns — which is also a rather big inefficiency. However, fixing that would take a lot mo’ work — I would basically have to refactor all sprite code so that it uses discriminating unions — which are both racist & socialist, so neither side o’ the political spectrum likes them — ’stead o’ polymorphic sprites. In hindsight, I would’ve preferred using discriminating unions for this & a few other reasons, but it’s too late; so we’re stuck with slow & stupid polymorphic classes. I could think o’ many other optimizations I could make, some big & some so small it’d be a waste o’ time — & some big, but would require me to reprogram large parts o’ the game’s integral code. This isn’t so much “fix all inefficiencies I can think o’”, which would make this project take decades to finish, but “fix inefficiencies that are obvious & ridiculously easy to do”. I’ll save these bigger ideas for the sequel, where I can start from scratch. Now I want to just get this sloppy mess finished & out o’ my sight.

Anyway, these optimizations not only seemed to clear all slowdown in “Good Ship Lifestyle”, they also seemed to fix the slowdown that has been in “Value Valhalla” for probably o’er a year. ( Didn’t fix most o’ the sprites disappearing after a loop, though ). Why this happens, I can’t understand, since this level has neither any background tile layers nor sprites that are deleted.

& I must say, this level’s music is a true banger. This time it isn’t by Kevin McLeod, but by a band called Blue Wave Theory, found on Free Music Archive, released under Creative Commons ( & thus OK for me to use ). It’s surprising how much high quality music you can find for free — which is great for people like me with absolutely no musical talent.

Final Fun Game: Try & find the minor graphical ( technically, level-design ) flaw I made & didn’t notice till after I already recorded the video this time.

Here Is Where the Bad Polymorphic Classes Can Be Found

Posted in Boskeopolis Land, Programming