Is programmeren echt zo moeilijk dan?

Scratch editor met bewegende katSinds begin dit jaar probeer ik als newbie coach te helpen bij CoderDojo Genk. Ik moet eerlijk zijn, ik ken nog niet écht veel van Scratch en nog veel minder van micro:bit, maar ik ga ervan uit dat dat wel zal komen. Soit, afgelopen weekend vertelde de moeder van 2 deelnemers me dat programmeren haar zo moeilijk lijkt. In de chaos van het moment heb ik daar amper op geantwoord, maar die opmerking heeft de schoolmeester in mij toch een beetje wakker gehouden. Want is programmeren echt zo moeilijk? Als een “leek” het werk van een échte developer op het scherm ziet, lijkt dat ongetwijfeld ondoorgrondelijke tekst met hier en daar enkele herkenbare Engelse woorden waar verder kop noch staart aan te krijgen is. Het succes van Scratch is dat het die letterspaghetti verbergt achter mooi gekleurde blokjes die logisch in elkaar kunnen worden geklikt om zo de basisconcepten van het programmeren spelenderwijze aan te leren. Maar zitten er achter die Scratch-blokjes eigenlijk geen eenvoudige ideeën die iedereen zou kunnen begrijpen?

Ik probeer even met een denkbeeldig spelletje waar je een vliegtuigje moet besturen;

  • in elk computerprogramma (software) zitten er acties; toon een vliegtuigje en een achtergrond, … (dus dikwijls “uitvoer” naar de gebruiker van de software)
  • er is logica om de gebruiker toe te laten om die actie te beïnvloeden (de invoer of input), bijvoorbeeld het pijltje naar boven of beneden om het vliegtuigje te besturen
  • die invoer wordt getoetst aan “als … dan” voorwaarden (testen): dalen of stijgen is afhankelijk van welk pijltje wordt ingedrukt, maar een voorwaarde kan even goed controleren of de positie van het vliegtuigje te laag vliegt waarop het crasht of landt (een nieuw actie dus)
  • software zal dikwijls informatie bijhouden (en soms tonen) in “variabelen“, bv. de huidige positie van het vliegtuigje of een score of het aantal levens dat je nog resten in een spel
  • als scores worden bijgehouden kan om de high scores te tonen een lus gebruikt worden. zo een “loop” kan een vast aantal keer doorlopen worden (zoals een top 5 om de eerste vijf resultaten uit een al geordende lijst), maar een lus kan ook doorlopen worden tot er aan een voorwaarde voldaan is (bijvoorbeeld als je een oneindig aantal pogingen krijgt om woord te raden, in dat geval blijf je in die lus tot je het woord geraden hebt).

Is dat echt alles? Nee, er komt natuurlijk meer bij software development kijken; het opvangen van fouten, de code veilig maken voor hackers, de code leesbaar en onderhoudbaar houden voor collega’s zorgen voor technische documentatie, zorgen voor automatische testen en het communiceren met databases of andere software om maar een paar zaken te noemen. Vanzelfsprekend bevat zowat elk stukje software honderden of duizenden acties, voorwaarden, loops, variabelen en databank velden, maar bovenstaande concepten geven wel een beeld met welke betrekkelijk eenvoudige basisblokken software wordt geschreven.

Programmeren is in de eerste plaats dan ook volgens een bepaalde logica nadenken. De juiste vragen stellen en proberen, falen, je afvragen waarom het niet werkt en met dat nieuwe inzicht opnieuw proberen tot het werkt. Dat heb ik dikwijls ook geantwoord op de Coderdojo aan de Scratchende kinderen/ tieners; “Wat denk je zelf dat er moet gebeuren?” en “OK, probeer het eens en kijk of het werkt”. En zo leer ik ook beetje bij beetje Scratchen 🙂

How to go block-less with the WordPress ActivityPub plugin

Being the web performance zealot I am, I strive to having as little JavaScript on my sites as possible. JavaScript after all has to be downloaded and has to be executed, so extra JS will always have a performance impact even when in the best of circumstances it exceptionally does not impact Core Web Vitals (which are a snapshot of the bigger performance and sustainability picture). Hence when adding blocks in WordPress, I check if the block is entirely rendered server-side and if not I look for alternatives to avoid multiple files from wp-includes/js/dist (and in the case of some 3rd party blocks the entire React JS and more) being loaded.

For that reason I tested the WordPress ActivityPub plugin with the reactions block loaded as per these guidelines and indeed it triggers the loading of hooks.min.jsi18n.min.jsurl.min.js, api-fetch.min.js (all in wp-includes/js/dist) and 2 files from the plugin itself (/wp-content/plugins/activitypub/build/reactions/view.js and /wp-content/plugins/activitypub/build/remote-reply/view.js).

To be able to reduce the dependency on those JavaScript files, 2 questions needed to be answered; how to have reactions (which I like a lot) without the JavaScript-driven rendering and what is that remote-reply thing.

Starting with the latter; “remote-reply” handles the federation of local comments on reactions (comments) from the Fediverse, showing a modal window where the commenter is asked what ActivityPub account they want to post the reaction from. I decided this was not that important for me and –with some help from Matthias @pfefferle who always gives great support- came up with a couple of lines of code to not “do” remote-reply on this blog.

Now that Fediverse reactions block is very nice and I did want reactions showing on my blog, so I started looking at the database and the ActivityPub plugin code and saw that all Fediverse reactions were stored in the wp-comment en wp-comment-meta db-tables and were in fact accessible with the WP_Comment_Query class. With quite a bit of trial and error I ultimately ended up with a totally server-side generated solution that looks pretty nice (and similar to the JavaScript-rendered one).

If you’re interested, you can find the code in this gist, but don’t expect it to be good. Some negatives include no language handling, unminified CSS inline and the placement of the reactions might not work on every theme as I hook into the comments_template action to try to show them just before the comments. But who knows it might just work for you as well?

Zijn er Meshcore-users in de Limburgse Maasvallei?

Ik steek het op de Fediverse, waar ik sinds een paar weken (maanden?) regelmatig posts langs zag komen over Meshcore als technologie/ software voor gedecentraliseerde ad-hoc netwerken voor tekst-gebaseerde berichten op basis van LoRa radio. Ik heb me zo een Sensecap T1000-e gekocht, meshcore geflasht (vanuit Chrome, poef) en verbonden met m’n Fairphone met de Meshcore app en … niks. Adverts gestuurd, eerst braaf 1 hop, daarna floods. Maar nee, niemand te zien. Alleen op de wereld!

Anderzijds mag me dat niet verwonderen; zelfs met de GSM is de ontvangst hier in de bossen aan de rand van het Kempisch plateau abominabel. En die Sensecap met interne antenne, dat is ook niet van dien aard om kilometers ver te zien/ zichtbaar te zijn. Ik veronderstel dat ik eerstdaags eens naar het panoramapunt op de Mechelse Heide moet wandelen, daar heb ik misschien iets meer kans?

Maar bij deze; als U in de Limburgse Maasvallei woont en af en toe een Meshcore-toestel aan hebt staan, geef dan gerust een seintje! En vertel er direct bij welke frequentie U frequenteert misschien? 😉

w.social invite code

Screenshot of the w.social landing page where an invitation code has to be entered.So regarding that new EU social network (which is said to be decentralized but unclear if that implies ActivityPub which would make it more relevant in my book); entering a string in the “invitation code” and clicking “continue” does not result in an XHR request to the server and there’s a lot of JS on the page to handle the invitation code.

This implies the code is checked in the browser so the correct code(s) is somewhere in the JavaScript. So it should be possible to reverse-engineer it, no? 😉

Any takers for this challenge?

blog.futtta.be on the fediverse

Pretty sure no-one is waiting for this, but after having spent a couple of years on the Fediverse (Mastodon in my case) I decided to add ActivityPub support to my WordPress installation via the ActivityPub plugin.

I have the WP Rest Cache plugin active, so I’m expecting things to gently hum along, without (most likely) or with these posts gaining traction.

Kudo’s to Stian and Servebolt for assisting me to get the webfinger endpoint to work, which is … not self-explanatory on hosts that have unoverrideable configuration on the .well-known folder 🙂

AOPro soon to have a wizard tab

Currently the last lines of code are being added/ reviewed to integrate a “wizard” tab in Autoptimize Pro, which should help new users to switch between different presets all while keeping backups of original settings so one can easily try out different optimization levels. Have a look at below screenshot to see where we’re taking this 🙂

screenshot of the soon to be available "wizard" tab in AOPro

And while we’re at it; have a great 2026, whether you’re using Autoptimize, AOPro or if you’re just reading this out of curiosity!

Improving LCP the wrong way

Performance hack seen on a customer site; fix the bad LCP (due to an animation in revslider) by loading an inline (base64’ed) png image which according to FF is broken and later in the rendering process hiding & removing it.

Even though that image is not *really* used, tools such as Google Pagespeed Insights pick it up as the LCP image and the score is “in the green”.

Not sure this is really helping performance (spoiler: it’s not), but Pagespeed is happy and so is the customer. Crazy!

Heads-up: Autoptimize Pro price increase for 2025

It’s been 2 years since AOPro was launched and a lot has happened in that time; bugs were squashed, improvements were made and some great features were added. Taking that into account on one hand and increasing costs from suppliers on the other: prices will see a smallish increase as from 2025 (exact amounts still to be determined)

But rest assured; if you already signed up, you will continue to pay the lower price, also when renewing. Same if you sign up before the end of the year too by the way, so if you’re considering switching on Autoptimize’s Pro features, now might be the moment! 🙂

Whatever you do, if you’re an Autoptimize users or not, if you’re an AOPro customer or not, have a great end of year! Peace and love to you and your loved ones, whomever you may be!