Sitemap
Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Vibe coding my scientific experiment

7 min readAug 29, 2025

--

Press enter or click to view image in full size

I have a mantra when it comes to generating QR codes: Make the payload small. Then, make it smaller.

The common sense about QR codes tells us the more information we encode into a QR code, the more black and white square modules are needed, the smaller the modules, and the more difficult it becomes to focus and scan using a mobile device. We prefer scanning to be fast and easy.

For example, one of these 2 QR codes is easier to scan. I’m letting you guess which one.

“Hello, World”
“It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife. However little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered as the rightful property of some one or other of their daughters.”

Thus, encoding less information tends to improve the user experience. The scanning action has more chances to succeed, and succeeds faster. For example, using a URL shortener before generating a QR code leads to a friendlier, less complex, more performant QR code.

This is all intuitively true, but I wanted to go further and quantify this phenomenon. For this, I needed a realistic setup, a full-stack software platform, and a scientific protocol.

Experimental setup

This is my desired setup to collect measurements:

Press enter or click to view image in full size

A QR code is generated by a backend and displayed on a computer screen. A mobile device is scanning it. The mobile notifies the backend, which saves the measurements in a database and tells the computer to generate a new QR code. Rinse and repeat.

The code necessary to generate and scan QR codes using popular libraries is not very complex per se. However, writing it by hand would have taken me several days. The cost of writing boilerplaty code for 3 components (mobile app, web backend, web frontend) was high enough to deter me from building the experiment altogether.

Vibe coding!

But now is 2025 and AI assisted coding is a real thing. My experiment will come to life, mostly written by Gemini.

Integrating AI-generated code in a production system comes with real challenges. But for prototyping or building a throwaway experimental platform, vibe coding is just amazing.

I asked:

Press enter or click to view image in full size

The first results were very good. Within a few hours of guided work, I was ready to run the experiment and collect metrics in the database.

Each QR code is generated with a text payload having a random length, a random Error Correction Level (ECL) L, M, Q, or H, and has a random display size and a random position on screen.

The mobile device I’m using is not moving, but the QR code is moving towards the center of the screen, then stays fixed until scanned, or abandoned after a timeout of 7 seconds.

I gathered 5,000 data points in Firestore and exported them to BigQuery for analytics. The results surprised me!

Hey, do you already know about these very nice BigQuery features?
- Pipe syntax
- Chart panel

Results

Display size matters

Press enter or click to view image in full size

First, the size of the QR code matters a lot. At 50 x 50 pixels (too small), the scan almost always fails. At 600 x 600 pixels, the scan almost always succeeds.

QR code too small (always fails)
QR code too large (always succeeds)

This chart teaches us the most “interesting” range of sizes is between 100 x 100 and 300 x 300. The subsequent queries will control for the size variable, removing the noise from QR codes too small or too large:

|> WHERE qrSize BETWEEN 100 AND 300

Payload size matters, but…

The contents encoded in the QR code is a random alphanumerical string of random length, up to 50 characters.

Press enter or click to view image in full size

It is expected, and observed, that a larger payload leads to more failures of detection. A string of length 50 has a 40% chance of failing to be scanned, with my specific experimental setup.

Get Val Deleplace’s stories in your inbox

Join Medium for free to get updates from this writer.

However, while the tendency is clear, I still need to take into account other factors that influence the detection:

  • The Error Correction Level (ECL)
  • The QR code version, i.e. the number of modules in the grid

Error Correction Level matters

A higher level of error correction helps scanning a QR code that is partially damaged, or partially hidden. This is achieved by encoding more bits of redundancy.

But should we expect a high level to facilitate scanning in the general case, or to impede it? On the one hand, more redundancy could mean higher chances for the scanner to detect “enough info”. On the other hand, more bits encoded may come with more modules, a higher QR code version, hence smaller modules, more difficult to detect.

Press enter or click to view image in full size

In my setup, higher levels (Q, H) tend to be less successful than lower levels (L, M) for any given payload size.

ECL is a parameter that we choose when generating the QR code. A high level makes sense for printing, because the paper QR code may become damaged over time. But for a QR code displayed on a computer screen, fully visible and undamaged, the lowest level L is preferable, as it encodes fewer bits of information.

QR code Version matters, but…

The version of a QR code represents the resolution of the grid:

  • Version 1 for 21 x 21 modules (e.g. the first simple QR code at the top)
  • Version 13 for 69 x 69 modules (e.g. the complex QR code at the top)
  • Up to Version 40 for 177 x 177 modules

For a fixed display size, a higher version has more modules, and each square module appears smaller.

Are higher versions more difficult to scan?

Press enter or click to view image in full size

Obviously, yes, but this chart is a bit misleading.

The version is usually not a user-defined setting at generation. Instead, the QR encoding library computes the lowest version possible that can fit the payload, with the chosen ECL. The real question is: for a chosen payload and a chosen ECL, which version is best for scanning?

When controlling for the payload size and the ECL, my data shows a slight advantage for the lowest version possible. In fact, the libraries are already taking the best decision by default.

What about speed?

The surprising result in the data I collected is that I could not demonstrate any effect of the randomized parameters on the speed of detection, when detection does happen.

In my setup, either the QR code was detected very fast, or it was not detected at all within 10 seconds. I conjecture this is because the distance between mobile and computer screen was fixed, and the display size of any given QR code was also fixed.

The real scan action by a human is a bit different: the user is aiming and closing in on the QR code until properly framed, at a suitable distance. Thus, it is still sensible to say that a less complex QR code, encoding less data, will be easier and faster to scan by a real user, at a suboptimal distance.

To properly demonstrate this, I would need to run the full experiment again with a twist: each QR code would start small and grow every second until detected or abandoned.

QR code takeaways

  • Yes, encoding smaller information facilitates scanning and fosters better UX
  • You do not need to set an explicit QR code version. Let the library decide.
  • If you display on a screen, choose the lowest error correction L.
  • More QR code technical details on the Push to Computer blog

Useful Google Cloud links

--

--

Val Deleplace
Val Deleplace

Written by Val Deleplace

Engineer on cloudy things @Google. Opinions my own. Twitter @val_deleplace

Google Cloud - Community
Google Cloud - Community

Published in Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.