this post was submitted on 27 Feb 2025
391 points (97.8% liked)

Programmer Humor

21016 readers
3076 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 1 week ago (2 children)

Wow, so this is possible.

Formatting is so damn arbitrary. Somebody has to have tried storing just the parse tree on disk, right?

[–] [email protected] 2 points 6 days ago

The closest thing I've seen is Combobulate

[–] [email protected] 2 points 6 days ago (1 children)

If you do that, you lose formatting and comments every time you load the source from disk

[–] [email protected] 3 points 6 days ago* (last edited 6 days ago) (1 children)

Losing formatting other than what you've set in your deparser would be the point. Losing comments would be bad, but that seems easily fixable just by giving each comment block a symbol that points to it's contents.

[–] [email protected] 3 points 6 days ago (1 children)

Or by including comments in the parse tree. (& Yes, it is done various places for various languages and formats.)

[–] [email protected] 1 points 6 days ago* (last edited 6 days ago) (1 children)

Do you have some examples?

(That is what I meant by giving them a symbol, maybe I worded it poorly)

[–] [email protected] 1 points 5 days ago

The best example I have is a closed source one and I can't be more specific on what it is than to say that it's probably installed on at least one of your Apple devices (assuming you have any).

Implementation-wise, the syntax tree nodes have additional attributes that hold pre- and/or post-element text. What's on disk is the serialized tree. You edit a text version, and it's parsed on every edit so it doesn't have to be parsed again at evaluation time, and what's stored is the parse tree with enough whitespace and comment hints to reconstruct the text for editing.

This is a case where looking at the textual code is rare, but hundreds of results must get updated in realtime on every change. This might be enough of a hint as to what program it is.