Explain the code using ASCII art
- Transfer
Note from the translator: typically a Friday article on Tuesday morning ... why not?
Most people are visuals. They use images to get to the bottom of the problem. But mainstream programming languages, on the contrary, are based on textual representation. The resulting gap between text and graphics is filled with ASCII images drawn using text characters and inserted into the program source code. I love them! Once I threw a cry on Twitter and they sent me much more examples than I expected. Thanks to everyone involved. This topic came up with some excellent examples that I collected and put into categories. For each image, a link to the corresponding repository is given.
One of the most common uses of ASCII art in code is to illustrate the data structure.
The first example from LLVM source code:
Source
Location of fields in the data structure in Jikes RVM:
Source
Tree rotation in Musl:
Source
Two-way queue in Rust:
Source
Swift compiler internals:
Source
Location of elements in the Malloc header:
Source
Javascript Profiling: RPC
Source
in Cloud Spanner:
Source
I / O Stream State:
Source
Control flow in the decompiled NWScript program:
Source
ECC internals:
Source
Number formatting:
Source
Quantum loop:
Source
Balancing memory management tasks in the kernel of the operating system:
Source
Type compatibility (this is a particularly impressive case, because ASCII art is code here!)
Source
Format DBF file:
Source
Lookup-table for image processing:
Source
Color function form:
Source
URL structure:
Source
"Short" help on canceling operations in emacs:
Source
Translator's note: there are still a lot of similar charts on the link
Height control in the on-board computer Apollo (!!!):
Source
Splitting the image into segments:
Source
Boomerang paths in Nethack:
Source
Drawing the borders of the element in CSS:
Source
Quadrant tree:
Source
Control the speed of the machine:
Source
Scrolling web pages:
Source
I hope did you like it!
Additional example from translator:
Graph of interpolation of value:
Source
Most people are visuals. They use images to get to the bottom of the problem. But mainstream programming languages, on the contrary, are based on textual representation. The resulting gap between text and graphics is filled with ASCII images drawn using text characters and inserted into the program source code. I love them! Once I threw a cry on Twitter and they sent me much more examples than I expected. Thanks to everyone involved. This topic came up with some 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 illustrate the data structure.
The first example from LLVM source code:
Source
Location of fields in the data structure in Jikes RVM:
Source
Tree rotation in Musl:
Source
Two-way queue in Rust:
Source
Swift compiler internals:
Source
Location of elements in the Malloc header:
Source
State machines
Javascript Profiling: RPC
Source
in Cloud Spanner:
Source
I / O Stream State:
Source
Domain Logic
Control flow in the decompiled NWScript program:
Source
ECC internals:
Source
Number formatting:
Source
Quantum loop:
Source
Balancing memory management tasks in the kernel of the operating system:
Source
Type compatibility (this is a particularly impressive case, because ASCII art is code here!)
Source
Format DBF file:
Source
Lookup-table for image processing:
Source
Color function form:
Source
URL structure:
Source
"Short" help on canceling operations in emacs:
Source
Translator's note: there are still a lot of similar charts on the link
Geometry
Height control in the on-board computer Apollo (!!!):
Source
Splitting the image into segments:
Source
Boomerang paths in Nethack:
Source
Drawing the borders of the element in CSS:
Source
Quadrant tree:
Source
Control the speed of the machine:
Source
Scrolling web pages:
Source
I hope did you like it!
Additional example from translator:
Graph of interpolation of value:
Source
Only registered users can participate in the survey. Please come in.
Do you document your code using ASCII art?
- 21% Yes 73
- 52.7% No, but now I will be 183
- 26.2% No way! 91