TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Mendoza: Use stack machines to compute efficient JSON diffs

115 pointsby evenwover 4 years ago

16 comments

thehappypmover 4 years ago
“ Naming a project is always difficult. Since this project is focused on representing changes between JSON documents I naturally started thinking about names like &quot;JSON differ, JSON changes, JSON patch, …&quot;. However, most of these names have already been used by existing projects. While I was muttering &quot;JSON, JSON, JSON&quot; it suddenly turned into &quot;JSON, JSON, Jason, Jason Mendoza&quot;.”<p>This is a reference from The Good Place and it is an amazing name!
feanaroover 4 years ago
This is an interesting tool for computing minimal diffs, but the result is not very human friendly. If this is your goal and you are looking for something better than diff, have a look at graphtage: <a href="https:&#x2F;&#x2F;github.com&#x2F;trailofbits&#x2F;graphtage" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;trailofbits&#x2F;graphtage</a><p>Also works for XML, HTML, YAML and CSV.
评论 #24947272 未加载
评论 #24947523 未加载
评论 #24949729 未加载
anonymousblipover 4 years ago
Interesting approach! But aren&#x27;t JSON arrays a pretty wasteful encoding?<p>Since this is an opaque serialization of an instruction set, why not try to encode more bits per number (JSON floats support lossless integers of many more bits), and moving the &quot;symbol table&quot; (string data) to the end?<p>This way you could also compress redundant symbols into single strings.
评论 #24945183 未加载
评论 #24945136 未加载
Arquover 4 years ago
I&#x27;m super interested in this topic. Recently (and still ongoing) I started on hashing out how to diff large datasets and what that even means.<p>I would love to get an understanding of how the HN crowd sees diffing datasets should be (lets say &gt;1GB in size).<p>Are you more interested in a &quot;patch&quot; quality diff of the data which is more machine tailored? Or is a change report&#x2F;summary&#x2F;highlights more interesting in that case?<p>Currently I&#x27;m leaning more towards the understanding&#x2F;human consumption perspective which offers some interesting tradeoffs.
评论 #24946363 未加载
TheRealPomaxover 4 years ago
Out of curiosity, what problem did you have that this approach solves?<p>Thinking about diffs, plain text diffs are typically compressed for transport anyway, so you end up with something that&#x27;s human readable at the point of generation and application (where the storage&#x2F;processing cost associated with legibility is basically insignificant) while being highly compressed during transport (where legibility is irrelevant and no processing beyond copying bits is necessary).
评论 #24945935 未加载
tomswartz07over 4 years ago
I appreciate the Good Place reference in the name.
评论 #24945615 未加载
评论 #24945341 未加载
评论 #24945348 未加载
remexreover 4 years ago
Have you looked at generating a specialized version of this stack machine for other types than JSON values? It&#x27;d be neat to have a version that works directly on data with Haskell&#x27;s GHC.Generics, or a custom derive in Rust.
remexreover 4 years ago
Why does this contain an implementation of sha256 instead of using the standard library&#x27;s crypto&#x2F;sha256?
评论 #24945762 未加载
mjgp2over 4 years ago
Isn&#x27;t this what <a href="https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc6902" rel="nofollow">https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc6902</a> is for?
narrationboxover 4 years ago
Add a few more lines of code and you have yourself an operational transformation library for collaborative data structures.<p>You may find this relevant: <a href="https:&#x2F;&#x2F;github.com&#x2F;ottypes&#x2F;json1" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ottypes&#x2F;json1</a>
zokierover 4 years ago
Somehow I&#x27;m reminded how patch runs ed beneath and I guess could use more advanced editing commands: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16767509" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16767509</a><p>Also is there enough here to build a turing machine? I guess not, but it does seem pretty close.
tonygover 4 years ago
How does it decide whether two JSON values are equal? e.g. 1 vs 1.00 vs 1e0. (<a href="https:&#x2F;&#x2F;preserves.gitlab.io&#x2F;preserves&#x2F;why-not-json.html" rel="nofollow">https:&#x2F;&#x2F;preserves.gitlab.io&#x2F;preserves&#x2F;why-not-json.html</a>)
georgewsingerover 4 years ago
<a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=MOk4hQXbGDs&amp;ab_channel=ThingsICantFindOtherwise" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=MOk4hQXbGDs&amp;ab_channel=Thing...</a>
dreamer7over 4 years ago
On a tangential topic, how does one go about integrating Sanity Studio with Hugo so non-developers can create content more quickly?
评论 #24944926 未加载
ameliusover 4 years ago
&gt; Mendoza constructs a minimal recipe for transforming a document into another.<p>Is it really minimal, or is it an attempt at minimal?
vicbergquistover 4 years ago
Cool!