Wikifunctions:Status updates/2024-02-14

From Wikifunctions
Wikifunctions Status updates Translate

<translate> Abstract Wikipedia via mailing list</translate> <translate> Abstract Wikipedia on IRC</translate> <translate> Wikifunctions on Telegram</translate> <translate> Wikifunctions on Mastodon</translate> <translate> Wikifunctions on Twitter</translate> <translate> Wikifunctions on Facebook</translate> <translate> Wikifunctions on YouTube</translate> <translate> Wikifunctions website</translate> Translate

Recent changes in the software: Fix-it week

As mentioned in last week's update, we had our regular "Fix-It Week", where we work on technical debt, design oddities, and other issues that can pile up when our main daily focus is on delivering larger-scale change for users.

One of main areas of change was in cleaning-up the Vue front-end code, which has undergone a lot of change in the past few months. We improved our front-end Vuex "store" code to remove now-unused methods and change the remaining ones to be safer in edge cases (T329107); we re-organised and split up the 'mix-ins' in the Vuex store for consistency and better testability (T328430).

On the back-end services, we made a few improvements to code quality. One of these was shifting the logging system from a global into our "Invariants" class, so that it can be dependency-injected and so tested better (T337785). Our internal ZWrapper class will now correctly error rather than silently continuing when asked for a non-existent key (T309809). We migrated the JavaScript code coverage tool to use the built artefact pipeline rather than running directly on the repo's code (T355815). We also added pyflakes to our CI, to improve our Python evaluator code quality, in the course of which we found some bugs and added tests (T306365).

We switched the Beta Cluster test version of the back-end services to use the 'split' evaluator model that we rolled out to production last year (T349008), and so we were able to decommission the old 'omnibus' image that would process both Python and JavaScript code (T349557). After some checking to ensure we were content with the now-fixed results, we added a test to demonstrate and enforce the current model of error-handling in the WASM-wrapped JavaScript evaluator (T347898).

We added a little further coverage of the PHP code that mirrors how Objects work (T302599), finding and fixing a bug in how incoming results were interpreted in some circumstances. We also found and fixed a forgotten remnant of a now-removed piece of our test infrastructure that would cause errors when Wikimedia production rolled forward to PHP 8.2.

Outside of proper "Fix-It" tasks, we also landed two improvements that will roll out this week:

Following-on from last week's change to how string values are shown as outputs, wrapping them in double quote characters, we now also do the same for the abbreviated form, commonly seen on Test pages. This does not show all whitespace, but it is a further minor improvement in this vein (T343608).

Winston Sung, a Wikimedia community member very active in Chinese language support, made their first contribution, fixing our use of whitespace on each Object page's title headings in Chinese and some other languages (T356731). Thank you, and welcome!

Function of the Week: duplicate string

Duplicate string is a function that takes a single string as the input, and returns a single string as the output: the output is repeating the input twice.

Duplication of words or parts of words, for various different effects, is a feature of many different languages from all around the world. In some languages it may express emphasis, in others a plural, but it can have many other semantic effects too. The Wikipedia article provides an overview of how duplication is used, with numerous examples. Here are just two examples stolen from that page:

  • In Finnish, “ruoka” means "food", but “ruokaruoka” means "proper food", as opposed to snacks.
  • In Swahili, “piga” means to “to strike”; whereas “pigapiga” means “to strike repeatedly”

In Wikifunctions, duplicate string has five tests, WikiWiki, 1.11.1, ¨¨, the space character, and the empty string (a test that display correctly as of today, thanks to the fix-it tasks of this week). Those are great tests, trying out different kinds of characters and inputs. I particularly enjoyed the empty string as an edge case. What I am missing are non-English alphabet characters such as Hangul characters, left-to-right scripts, or emojis. But this is a great set already.

There are four implementations, of which three are unsurprising: JavaScript, Python, and a composition using join strings, all of which are calling the argument twice. The fourth implementation, another composition, is using the function duplicate string n-times, which is a great function to be used here. It requires a number as one of its arguments, but currently uses a string (set to the string “2”, for the given composition). Once we actually have a number type, this would need to be cleaned up.

All in all, this is a neat functionality, which is usually not available through a standard library, and can exemplify tests and different implementations.