Earlier quoted context omitted.
Do you have an example context in which you'd use these? I've never thought to do this and am curious about the possibilities and use cases.
Basically I use the same kind of philosophy as RFCs, and document things using ascii art where some kind of diagram makes sense. For example, see the TCP RFC https://datatracker.ietf.org/doc/html/rfc793 where they use it for packet layout, flow diagrams, block diagrams, etc. It makes the whole thing self contained, you can copy paste diagrams to almost anywhere, easy to modify. Disadvantage is in some more complex di…
ASCII art for semantic code commenting
71–80 of 82 posts
Re: ASCII art for semantic code commenting
#72For what it's worth, I keep a file in my home folder containing some box drawing characters. It's not super fast to draw by copy-paste but the result usually looks quite nice. ─ │ ┌ ┬ ┐ ┄ ┆ ├ ┼ ┤ ╲ ╱ ┈ ┊ └ ┴ ┘ ━ ┃ ┏ ┳ ┓ ┏ ┯ ┓ ┏ ┳ ┓ ┏ ┯ ┓ ┅ ┇ ┣ ╋ ┫ ┣ ┿ ┫ ┠ ╂ ┨ ┠ ┼ ┨ ┉ ┋ ┗ ┻ ┛ ┗ ┷ ┛ ┗ ┻ ┛ ┗ ┷ ┛
For those on macOS/iOS, using custom text expansions [0] also helps to do this without having to leave the doc you’re editing. I’ve built up tons of these over the years for things like ⌘ (“commandkey”) → (“rightarrow”) (╯°□°)╯︵ ┻━┻ (“tableflip”) and of course, a party parrot wave for Slack (“parrotwave” → :parrotwave1::parrotwave2::parrotwave3::parrotwave4::parrotwave5::parrotwave6::parrotwave7:). They can sync over…
Re: ASCII art for semantic code commenting
#73It's amazing that it is 2022, and not only can we not put any kind of media in source code comments, nobody even entertains the idea that it could be possible. Programming tooling really is living in the dark ages sometimes.
IMO text still provides the best combination of flexibility, power, simplicity and accessibility. A screen reader can’t describe a JPEG or animated GIF. You can’t diff images/animations as easily as text. You can’t automatically translate text in images. Images and their toolchains like imagemagick introduce attack vectors. They take up more disk space. You can’t change the font of text in images. Text in images is n…
Sure it can. There's a whole field of computer science for doing just that, computer vision.
>You can’t automatically translate text in images
You can use OCR to read text from images.
>Images and their toolchains like imagemagick introduce attack vectors.
This isn't fair. Text based toolchains can be vulnerable too. There have been millions of vulnerabilities with string handling
>They take up more disk space.
Buy a bigger hard drive / cloud storage.
>You can’t change the font of text in images.
Pick a readable font in the first place.
>Text in images is not greppable.
Again your could use OCR to make thi spossible.
>Do you need to change some text in that documentation image? Hope you have the vector-based original!
Check in the project file to source control or just draw over the current one.
Re: ASCII art for semantic code commenting
#74For what it's worth, I keep a file in my home folder containing some box drawing characters. It's not super fast to draw by copy-paste but the result usually looks quite nice. ─ │ ┌ ┬ ┐ ┄ ┆ ├ ┼ ┤ ╲ ╱ ┈ ┊ └ ┴ ┘ ━ ┃ ┏ ┳ ┓ ┏ ┯ ┓ ┏ ┳ ┓ ┏ ┯ ┓ ┅ ┇ ┣ ╋ ┫ ┣ ┿ ┫ ┠ ╂ ┨ ┠ ┼ ┨ ┉ ┋ ┗ ┻ ┛ ┗ ┷ ┛ ┗ ┻ ┛ ┗ ┷ ┛
(I use a Compose key for almost all character composition, with plenty of custom mappings in my ~/.XCompose, but box drawing specifically I have skipped and use Vim digraphs, and so drop into Vim any time I want to write any.)
Re: ASCII art for semantic code commenting
#75I wish I had known about this tool when I was building this little browser game https://replit.com/@aMoniker/Gush because all the levels & game objects are generated from multiline strings of ascii symbols, and it just took too long to do manually.
Re: ASCII art for semantic code commenting
#76Earlier quoted context omitted.
It's fabulous in cases where there's a "big important business logic" or a "big important test" with tough to eliminate complexity, where you feel a diagram is so important that it's worth putting in comments beside said code. I do recommend that you be careful with this though; in places where it's not common to put ASCII art diagrams in code you'll probably receive pushback (it is afterall very large and distractin…
It's also extremely useful for bit-mapped registers in embedded code. EG the TI bq25155[1] battery charge controller PCHRGCTRL register (page 52) is divided into 3 fields. It can be quite helpful to show the layout before code to set the range. /* * ┌───────────────┬──────────┬─────────┐ * │ ICHARGE_RANGE │ RESERVED │ IPRECHG │ * │ 7 │ 6-5 | 4-0 | * └───────────────┴──────────┴─────────┘ * This function sets the prec…
Re: ASCII art for semantic code commenting
#77Earlier quoted context omitted.
For those on macOS/iOS, using custom text expansions [0] also helps to do this without having to leave the doc you’re editing. I’ve built up tons of these over the years for things like ⌘ (“commandkey”) → (“rightarrow”) (╯°□°)╯︵ ┻━┻ (“tableflip”) and of course, a party parrot wave for Slack (“parrotwave” → :parrotwave1::parrotwave2::parrotwave3::parrotwave4::parrotwave5::parrotwave6::parrotwave7:). They can sync over…
Did you override the hotkey to go to the end of a line for an emoticon? Or are those 3 different examples?
Re: ASCII art for semantic code commenting
#78https://controlc.com/69f12f5a/fullscreen.php?hash=60268775f1...
Re: ASCII art for semantic code commenting
#79It's amazing that it is 2022, and not only can we not put any kind of media in source code comments, nobody even entertains the idea that it could be possible. Programming tooling really is living in the dark ages sometimes.
Re: ASCII art for semantic code commenting
#80It's amazing that it is 2022, and not only can we not put any kind of media in source code comments, nobody even entertains the idea that it could be possible. Programming tooling really is living in the dark ages sometimes.
IMO text still provides the best combination of flexibility, power, simplicity and accessibility. A screen reader can’t describe a JPEG or animated GIF. You can’t diff images/animations as easily as text. You can’t automatically translate text in images. Images and their toolchains like imagemagick introduce attack vectors. They take up more disk space. You can’t change the font of text in images. Text in images is n…