📜 ⬆️ ⬇️

We explain the code using ASCII art

Note from the translator: a typical Friday article on Tuesday morning ... why not?



Most people are visuals. They use images to get to the core of the problem. But mainstream programming languages, by contrast, are based on a textual representation. The gap between text and graphics is filled by ASCII images drawn with text characters and inserted into the program source code. I love them! Once I threw a cry on Twitter and sent me a lot more examples than I expected. Thanks to everyone who participated. In this topic I came across several excellent examples that I collected and put into categories. For each image, a link to the corresponding repository is given.

Data structures


One of the most common uses of ASCII art in code is to visually show the data structure.

The first example from the LLVM source code:


Source code

Location of fields in the data structure in Jikes RVM:


Source code

Rotate the tree in musl:


Source code

Two-sided queue in Rust:


Source code

Swift compiler internals:


Source code

The location of the items in the Malloc header:


Source code

State machines


Javascript profiling:


Source code

RPC to Cloud Spanner:


Source code

I / O stream states:


Source code

Domain logic


Control flow in NWScript decompiled program:


Source code

ECC internals:


Source code

Formatting numbers:


Source code

Quantum contour:


Source code

Balancing memory management tasks in the operating system kernel:


Source code

Type compatibility (this is a particularly impressive case, because here ASCII art is the code!)


Source code

DBF file format:


Source code

Lookup-table for image processing:


Source code

The shape of the color function:


Source code

URL structure:


Source code

A "brief" help on canceling operations in emacs:


Source code
Translator's note: there are many more such graphs on the link.

Geometry


Height control in the onboard computer Apollo (!!!):


Source code

Split images into segments:


Source code

Boomerang trajectories in Nethack:


Source code

Drawing element borders in CSS:


Source code

Quad tree:


Source code

Machine speed control:


Source code

Scrolling web pages:


Source code

Hope you enjoyed it!

An additional example from a translator:

Graph interpolation values:


Source code

Source: https://habr.com/ru/post/440830/