Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Laya the open source version of Jev(convaiinnovations.com ↗)
    44comments
  2. AI-generated posters don’t have to be horrible(john.hartnup.uk ↗)
    326comments
  3. Human brain is two separate organs, Stanford Medicine-led research finds(stanford.edu ↗)
    153comments
  4. “The Secret Life of Circuits” is here(coredump.cx ↗)
    32comments
  5. Android 17 is the first since 3.x to add new APIs without releasing to the AOSP(grapheneos.social ↗)
    508comments
  6. What Zig felt like, coming from Rust(besok.github.io ↗)
    1comments
  7. GPT-6 Astra Solves a WWI German Radio Cipher(prinzai.com ↗)
    113comments
  8. Tin: full-text search for Postgres(planetscale.com ↗)
    1comments
  9. San Francisco Onion Futures Company(onionfutures.com ↗)
    91comments
  10. A graphical desktop for the ZX Spectrum(github.com/mindbox77 ↗)
    discuss
  11. Black Holes or Black Hole Stars? Astronomers Spar over 'Little Red Dots'(quantamagazine.org ↗)
    1comments
  12. If math is more than proof, we need to better celebrate the rest of it(terrytao.wordpress.com ↗)
    152comments
  13. Communication by means of modulated Johnson noise(pnas.org ↗)
    17comments
  14. From Stonemasons to Carpenters(thelastsoftwareengineer.substack.com ↗)
    4comments
  15. Cloudflare Quick Tunnels(cloudflare.com ↗)
    296comments
  16. How to Write with an LLM(sockpuppet.org ↗)
    355comments
  17. You can run Git on object storage if you re-make packfiles(tigrisdata.com ↗)
    22comments
  18. SDCC – Small Device C Compiler(sourceforge.net ↗)
    21comments
  19. Saving another 100TB of RAM(cloudflare.com ↗)
    86comments
  20. Science Is Open Software(jepedersen.dk ↗)
    46comments
  21. How OpenAI Used Its Own LLMs to Design Its Jalapeño Chip(ieee.org ↗)
    108comments
  22. Why building a Rust LSP is hard(rust-glancer.github.io ↗)
    42comments
  23. NASA-IBM Lunar Foundation open-Source Geospatial AI Model(usra.edu ↗)
    5comments
  24. Ray Ozzie and the Optimism of Being Early(reproof.app ↗)
    4comments
  25. Ctenophores: Wonders of Biology(quantamagazine.org ↗)
    6comments
  26. The first new cat species discovered in 100 years(nationalgeographic.com ↗)
    116comments
  27. OpenJev(openjev.com ↗)
    274comments
  28. Goroutine Leak Profiles(go.dev ↗)
    6comments
  29. Show HN: Cactus Needle 3: 8-29MB automation models can match DeepSeek V4 Flash(cactuscompute.com ↗)
    89comments
  30. Photon-Emission-Guided Laser Fault Injection Enables RP2350 Secure Debug(ledger.com ↗)
    77comments

ASCII art for semantic code commenting

290 pointsby 4y agoasciiflow.com
78 comments
4y agoHN ↗

Wow. This is one of those "I bet someone has already done that" tools that developers wish they had but not as much to go and search for it. Bookmarked and shared. Thanks ;)

4y agoHN ↗

EDIT: Deleted before I get even more downvotes.

4y agoHN ↗

It seems to work exporting to both ASCII standard and extended for me.

4y agoHN ↗

Ah, yes, I can see it now, but that option is almost invisible for me. I have to operate some scroll buttons at the edge to see the words "ASCII Extended".

4y agoHN ↗

On a general note, I think it's time to call things "text" instead of "ascii".

Every time someone utters the word "ascii", they just mean text. Saying “I'm using ASCII” doesn't mean anything anymore, because nobody uses EBCDIC anymore – you are, no matter what, effectively using a superset of ASCII, by default UTF-8. The real question is which one.

4y agoHN ↗

Saying “I'm using ASCII” doesn't mean anything anymore, because nobody uses EBCDIC anymore

I get what you're saying, but I have seen bugs at work caused by distributed systems sending text in ASCII or UTF8 to an IBM z/OS mainframe with EBCDIC.

4y agoHN ↗

PlantUML can export to text too. And it aligns all the boxes and arrows for you.

Still, great idea and great implementation :)

4y agoHN ↗

I'm going to second this one, and add that diagrams are a real weak point for accessibility in general, one which using textual drawings exacerbates.

PlantUML is readable by screen readers and contains the same information as the diagram it generates, which is the optimal balance between using visual diagrams as part of software development while not excluding the vision-impaired completely in so doing.

To be clear, I'm not scolding anyone for using ASCII diagrams, especially given that code remains stubbornly text-only. Just boosting awareness of PlantUML in terms of its accessibility advantages. I can mention meaningful diffs in version control as another advantage!

4y agoHN ↗

I've seen this a few times. The key limit is that once drawn the characters are set, you can't move the drawn objects around.

What I'd like is something like drawio for ASCII/Unicode. I've been thinking of writing my own for years, but that'll probably never happen so I'll just keep mentioning the idea when similar apps come up in the hope I inspire someone else!

4y agoHN ↗

Perhaps I'm misunderstanding you but this tool expressly has a select and move tool.

4y agoHN ↗

It does, but that selects and moves the cells not the objects and then redraws the cells? Actually, going back to have a play I see that it does allow some modification of existing objects but it isn't terribly flexible.

I've just done a quick search and found one that I've not spotted before, which is a bit closer to what I want in that one respect, but not nearly complete overall (and not seen a check-in in 8 years): https://textik.com/ - that might illustrate the key difference that I see missing in asciiflow.

4y agoHN ↗

If i understand you, the Mac-only Monodraw handles this fine. It lets you draw objects, point to objects (say like a diagram), and then move them around with the pointers auto adjusting to remain correct.

It's a shame that it's mac only.

4y agoHN ↗

It's a shame that it's mac only.

Yeah, that looks to fit the bill nicely but is no use to me with my current mix of operating systems.

4y agoHN ↗

You can drag edges, but it doesn't seem to have a concept of a "square" beyond the tool itself. So after you've placed it, you can't move individual shapes around. The select works more like a text-editor's highlighter than something like the lasso tool in draw.io

4y agoHN ↗

It's a little tedius, but you can highlight sections and then drag the highlighted section around.

Also it would be nice to have some way of snapping boxes to a grid. Similar to creating new elements in figma. It was hard to tell when if all the boxes I made were aligned / same size.

4y agoHN ↗

Hey, maintainer here (sorta). We've both been super absent the last few years unfortunately but this was ultimately on our list for V3.

Now I just need to find some spare time...

4y agoHN ↗

Monodraw is awesome, and has a really great desktop interface.

4y agoHN ↗

At that point it would be better to just split it into several files though.

4y agoHN ↗

Maybe it is, maybe this is just an intermediate file in a build process, optimised for readability.

4y agoHN ↗

Nice. Though it makes me think it would be nice to have this as a built in code editor minimap feature without the multi line ASCII code. The editor would parse special tags in comments and overlay the minimap with the tag text in big letters.

4y agoHN ↗

And in the jump bar (^6, which is then filterable by typing) long before Xcode had the minimap!

4y agoHN ↗

I think that might be derived from The "#pragma mark" feature that was in the CodeWarrior IDE which could be used to have annotations show in the drop-down list of functions in the code editor

4y agoHN ↗

You should add double line drawing characters and shadows (remember the DOS version of Norton Utilities?)

Maybe make a theme set - Turbopascal style, QBasic style etc

4y agoHN ↗

A few years back I wrote a tool that would convert Ascii flow diagrams in source code comments to equivalent source code declarations that implemented the flow. The idea being that the comments didn't just describe the flow visually, but actually defined it.

Tools like this helped greatly with that. Plain old text files don't lend themselves well to such 2D visual descriptions.

4y agoHN ↗

This is a neat tool, but unfortunately, text art like this generates is extremely unfriendly to folks that use screen readers. If you do use this for comment documentation, consider making sure that there is also a written description above/below it with equivalent descriptive content.

4y agoHN ↗

This is a very good point that I hadn't considered for some reason. Thanks!

4y agoHN ↗

Ohhh! Lovely. I was hoping someone might post a nice nvim plugin! Think I'll open a PR to add this to Nix[OS] this weekend

4y agoHN ↗

I love this plugin, came here hoping to see it so I wouldn't have to go lookup the link.

4y agoHN ↗

For 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.

    ─  │  ┌ ┬ ┐
    ┄  ┆  ├ ┼ ┤ ╲ ╱
    ┈  ┊  └ ┴ ┘

    ━  ┃  ┏ ┳ ┓ ┏ ┯ ┓ ┏ ┳ ┓ ┏ ┯ ┓
    ┅  ┇  ┣ ╋ ┫ ┣ ┿ ┫ ┠ ╂ ┨ ┠ ┼ ┨
    ┉  ┋  ┗ ┻ ┛ ┗ ┷ ┛ ┗ ┻ ┛ ┗ ┷ ┛
4y agoHN ↗

I usually copy from wikipedia but that's that's a good idea. In fact, since I have a "cols" command that just prints an ansi-colour table, I've just added "box" to do this.

4y agoHN ↗

can you share the contents of your cols script/function/alias?

4y agoHN ↗

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.

4y agoHN ↗

Sure, last time I used them I documented some file format I needed to reverse engineer.

Here an excerpt. Of course, it's not _necessary_ to do it like that. It's just flavor.

    ┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┳┅┅
    ┃ Chunk 1 Header │ Chunk 1 Body ┃ Chunk 2 Header │ Chunk 2 Body ┃
    ┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┻┅┅

    Chunk Header:
    ┌───────────┬─────────────────┐
    │ Magic Nr. │ Chunk Body Size │
    │   4 Byte  │          4 Byte │
    └───────────┴─────────────────┘
4y agoHN ↗

Biggest problem is with mobile / low horizontal resolution displays. I don't mind scrolling left and right, but in some cases the wrapping is forced (as on the HN phone app I'm using, Materialistic) and it becomes a mess. I've longed for some kind of markup system that allows for textual data to be formatted in tabular fashion irrespective of the character size of the contents, like ummmmmm HTML

4y agoHN ↗

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 distracting compared to said code). Be ready to save an in-code diagram for the 1-to-3 places in the business where they'll be a godsend.

4y agoHN ↗

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 precharge current
    *  and fast-charge current step size the
    *  nearest 1.25mA (<= 318.75mA) or 
    *  2.5mA (<= 500mA).
    */

etc, etc.

[1] https://www.ti.com/lit/ds/symlink/bq25155.pdf

4y agoHN ↗

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 diagrams it can get noisy

4y agoHN ↗

RFCs are now allowed to contain SVGs though.

4y agoHN ↗

Similar here, I use snippets for some of these things as well. As long as you're using a monospace font, I find it nice to take advantage of things like grid layouts in the extra column space for splitting up concepts into groups for example.

4y agoHN ↗

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 iCloud and you can export/import them with plists.

I now want to add table characters like these, just need to come up with a good naming convention…

[0]: https://support.apple.com/en-gb/guide/mac-help/mh35735/12.0/...

4y agoHN ↗

Did you override the hotkey to go to the end of a line for an emoticon? Or are those 3 different examples?

4y agoHN ↗

Vim has digraphs for all of these characters, which I like to use. e.g. you can get ┌ with <C-K>dr (d = down, r = right), and ┨ with <C-K>Vl (V = heavy vertical, l = left). To find the mappings, :digraphs shows the whole list, or copy this block of text and put the cursor over any of the characters in normal mode and type ga and it’ll echo things like “<┠> 9504, Hex 2520, Oct 22440, Digr Vr”.

(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.)

4y agoHN ↗

I know, I've used them in the past. However, I get annoyed by having to remember the exact sequence for the character I want. And often, when drawing a line, I'll just copy some characters that are already there anyway.

Also, I tend to jump a lot between editors/IDEs nowadays so I prefer workflows that don't depend on a specific tool.

4y agoHN ↗

I was daydreaming about something like this the other night. This is even cooler than what I was picturing! My only complaint is the download arrow threw me off for a bit, I wanted to copy to clipboard but did not realize that was hidden behind the arrow. Switching that icon to a clipboard that pops the modal might add some clarity.

4y agoHN ↗

I use TheDraw in DOSBox. Still the best!

4y agoHN ↗

What makes this "semantic code commenting"

4y agoHN ↗

While being an almost daily user of MonoDraw, I utilize Valery Kocubinsky's Table Editor package for Sublime at least a dozen or more times every day. All my daily habit, scheduling, trackers, and labor is in some sort of table. Thank you, Valery!

It isn't maintained but 90% of the features work fine. The project was picked up and is current on Atom.

Grabbing boxes for commenting is within scope of Table Editor but again, Monodraw offers some great flexibility. If you're working with code that's getting printed in a newsletter, drop it in a Monodraw box (remove border) and you can add call-outs on either or both sides of the code and paste it all in the newsletter. Looks nifty, and keeps the aesthetic consistent.

    Sublime Table Editor ... https://packagecontrol.io/packages/Table%20Editor
    Atom Table Editor ...... https://atom.io/packages/table-editor
    Vim .................... https://github.com/dhruvasagar/vim-table-mode
4y agoHN ↗

Cool idea. I recently wanted to draw a diagram of triangles in a code comment, but unfortunately this tool doesn't seem to let you draw lines which aren't axis-aligned, so it doesn't help for that.

4y agoHN ↗

It'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.

4y agoHN ↗

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 not greppable.

Do you need to change some text in that documentation image? Hope you have the vector-based original!

And FWIW, Xcode’s rendering of markdown files and markdown doc comments with media assets in playgrounds isn’t the best experience, IMO.

4y agoHN ↗

A screen reader can’t describe a JPEG or animated GIF.

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.

4y agoHN ↗

Now do a list of all the things you can't do with text.

4y agoHN ↗

It doesn't eat up keyboard evens, my accessibility addon freaks out.

4y agoHN ↗

In the save dialog,"Extended Ascii" should probably be called "Unicode" or "Utf-8" or something. Obviously, no standard named "ASCII" provides box drawing characters and arrows.

The Freeform tool is missing support for the brush consisting of spaces, which would make it useful as an eraser.

4y agoHN ↗

In general I feel like formats like ascii and even markdown are not great for editing. Most useful data has some sort of structure that is mostly lost when using plaintext or even MD.

A simple example is markdown tables... sorting, inserting and removing columns, etc. is incredibly tedious and probably requires tools to draw, anyway.

In this line of thought, a tool like Graph::Easy sounds like a better way to come up with ascii boxes and arrows [1] (this particular tool can output other formats too).

As a plus, the underlying data can be reused for something other than docs (generating code, scaffolding directories and files, etc).

1: http://bloodgate.com/perl/graph/manual/overview.html

4y agoHN ↗

I love this and I'm going to use it for fancy comments in code and in the browser console. It'd be really cool if you could integrate something like http://www.figlet.org/ for inserting ASCII text art.

I 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.