那些代码里有趣的字母拼图注释

那些代码里有趣的字母拼图注释

图示是最容易让人理解的表达方式,我们使用图片来认识问题。各种主流编程语言,从某方面来说,都使用了完全不同的编程理念或数据操作方法,给人们的认知留下了巨大的鸿沟。本文展示了一些嵌入在源代码中,使用字母排列拼出来是图案注释。我们很佩服这些注释!

数据结构注释

One of the most common kinds of ASCII art in code is illustrating the shape of a data structure.

The example I started with comes from LLVM:

The layout of a data structure in the Jikes RVM:

A tree rotate in Musl:

Double-ended queue from the Rust library:

Swift compiler internals:

Malloc header layout:

状态机注释

JavaScript profiling:

RPCs in Cloud Spanner:

I/O stream states:

逻辑结构注释

Control flow in an NWScript program being decompiled:

ECC internals:

Formatting numbers:

A quantum circuit:

Balancing memory management objectives in an OS kernel:

Subtyping relations (this is a very cool special case where the ASCII art is also code):

The format of a DBF file:

A lookup table for image processing:

Shape of a color function:

Structure of a URI:

A very quick tutorial on undo systems from emacs:

几何学注释

Attitude control in the Apollo Guidance Computer (!!!):

Image tiling:

Boomerang trajectories in Nethack:

Rendering CSS borders:

Quadtrees:

Speed control in a milling machine:

Scrolling web pages:

希望你也会喜欢这些有趣的代码注释!

参考评论

https://asciiflow.com/

You might be interested in stream-tree, a library I created for expressing functions as ASCII flow charts in JavaScript.

https://github.com/Widdershin/stream-tree

Here’s an example of a slides app that uses stream-tree.

https://github.com/Widdershin/how-to-write-javascript-without-going-insane/blob/ce84669d40c7109c8c10b93175f5b56bd2079a24/index.js#L55-L108

I did some animated ascii art explanations of basic algorithms a while ago
https://stackoverflow.com/questions/198199/how-do-you-reverse-a-string-in-place-in-c-or-c/21617273#21617273
https://stackoverflow.com/questions/21863609/building-a-binary-heap/43077941#43077941
https://stackoverflow.com/questions/4833423/shell-sort-java-example/22408617#22408617

One more category that seems like it would fit
is describing the hardware that will be controlled by the software.
Warren Creemers drew/gathered a collection of Arduino layouts to add as comments in Arduino scripts:
https://busyducks.com/wp_4_1/2015/11/16/ascii-art-arduino-pinouts/
(github: https://github.com/busyDuckman/ascii-art-arduinos)

There is also a tool called AACircuit by Andreas Weber that is used to lay out circuits in ASCII art:
https://josoansi.de/aacircuit.php
(github: https://github.com/Andy1978/AACircuit)

Gary Richardson made a Python version, but I haven’t been able to
track down the actual files. Here’s his post about it back in 2005:
https://sci.tech-archive.net/Archive/sci.electronics.design/2005-12/msg05445.html

Another example of schematics used in Arduino code (by carlynorama):
https://github.com/carlynorama/ASCII-schematics

字母拼图制作工具

https://buttersquid.ink

你也许感兴趣的:

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注