xkcd.WTF!?

Image loading failed. try again

Spreadsheets

My brother once asked me if there was a function to produce a calendar grid from a list of dates in Google Sheets. I replied with a single-cell formula that took in a list of dates and outputted a calendar. It used SEQUENCE(), REGEXMATCH(), and a double-nested ARRAYFORMULA(), and it locked up the browser for 15 seconds every time it ran. I think he learned a lot about asking me things.

Explanation

Cueball is doing some task on his computer, with an angel and devil on either side of him, trying to influence his work. The angel is telling him to do things the "right" way, while the devil is telling him to do his work using a spreadsheet, which is considered by professional software engineers to be a shortcut or a hack.

Spreadsheets provide an array of cells, which can contain information or instructions. Spreadsheets are a common end-user development tool, allowing non-developers to easily create code. However they can be hard to maintain, thus they are often mocked by developers as a wrong approach to programming. Although it is not clear from the cartoon that this is meant, the "right" alternative to using a spreadsheet for some tasks may involve a database or a more general programming language.

The punch line comes when the angel becomes so intrigued by the spreadsheet functions, Google Sheets in particular, that it gives up trying to dissuade Cueball, and asks for more information from the devil.

In the title text, Randall mentions a time when he created a calendar grid in Google Sheets using a list of dates. This is described as being done in a "single-cell formula", and taking a long time to run. This shows the power and complexity of spreadsheets. The procedure taking a long time to run, and freezing up the internet browser (possibly even the rest of the computer) for 15 seconds every time it ran, was probably not what Randall's brother had in mind when he requested help. His brother learned he might need to be wary about what he gets back when asking Randall for assistance.

All functions mentioned in this comic can be found in Google Sheets, but functions similar to some of them can be found in most modern spreadsheet applications.

REGEXREPLACE(text, regular_expression, replacement) ⇒ Replaces part of a text string with a different text string using regular expressions.

ARRAYFORMULA(array_formula) ⇒ Enables the display of values returned from an array formula into multiple rows and/or columns and the use of non-array functions with arrays.

QUERY(data, query, [headers]) ⇒ Runs a Google Visualization API Query Language query across data.

IMPORTHTML(url, query, index) ⇒ Imports data from a table or list within an HTML page.

SEQUENCE(rows, columns, start, step) ⇒ Returns an array of sequential numbers, such as 1, 2, 3, 4.

REGEXMATCH(text, regular_expression) ⇒ Whether a piece of text matches a regular expression.