那些代码里有趣的字母拼图注释
那些代码里有趣的字母拼图注释
图示是最容易让人理解的表达方式,我们使用图片来认识问题。各种主流编程语言,从某方面来说,都使用了完全不同的编程理念或数据操作方法,给人们的认知留下了巨大的鸿沟。本文展示了一些嵌入在源代码中,使用字母排列拼出来是图案注释。我们很佩服这些注释!
数据结构注释
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:
Double-ended queue from the Rust library:
状态机注释
逻辑结构注释
Control flow in an NWScript program being decompiled:
Balancing memory management objectives in an OS kernel:
Subtyping relations (this is a very cool special case where the ASCII art is also code):
A lookup table for image processing:
A very quick tutorial on undo systems from emacs:
几何学注释
Attitude control in the Apollo Guidance Computer (!!!):
Boomerang trajectories in Nethack:
Speed control in a milling machine:
希望你也会喜欢这些有趣的代码注释!
参考评论
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.
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
字母拼图制作工具
你也许感兴趣的:
- 趣图:注释主要是用来干嘛的?
- 那些年我们写过的代码注释,没被打死真是奇迹!
- 代码神注释,让我们认真对待一次!
- 神注释大全(欢迎补充)
- 雷人的代码注释-最后一张雷死人
- 程序员代码里神一般的图案注释,太逗了
- 10个令人喷饭的代码注释,你有没有遇到更绝的?
- Python里的一些注释规范
- 这样的代码才是好代码
- Python 开发者节省时间的 10 个方法
你对本文的反应是: