Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Fair point on AST vs semantic. sem sits somewhere in between. It doesn't go as far as checking compiled output equivalence, but it does normalize the AST before hashing (we call it structural_hash), so purely cosmetic changes like reformatting or renaming a local variable won't show as a diff. The goal isn't "would the compiler produce the same binary" but "did the developer change the behavior of this entity." For most practical cases that's the useful boundary. The YAML/JSON ordering point is interesting, we handle JSON keys as entities so reordering doesn't conflict during merges.

By the way creator here.



Hey there, thanks for checking in.

Regarding the custom normalization step, that makes sense, and I don't really have much more to add either. Looked into it a bit further since, it seems that specifically with programming languages the topic gets pretty gnarly pretty quick for various language theory reasons. So the solution you settled on is understandable. I might spend some time comparing how various semantic toolings compare, I'd imagine they probably aim for something similar.

> The YAML/JSON ordering point is interesting, we handle JSON keys as entities so reordering doesn't conflict during merges.

Just to clarify, I specifically meant the ordering of elements within arrays, not the ordering of keys within an object. The order of keys in an object is relaxed as per the spec, so normalizing across that is correct behavior. What I'm doing with these other tools is technically a spec violation, but since I know that downstream tooling is explicitly order invariant, it all still works out and helps a ton. It's pretty ironic too, I usually hammer on about not liking there being options, but in this case an option is exactly the right way to go about this; you would not want this as a default.


Ah right, array ordering not key ordering. That's a different beast. You're making a deliberate semantic choice because you know your consumers are order-invariant. We can't really do that at our level since function ordering in code is usually meaningful to the language. Your use case needs domain knowledge about the consumer, which is exactly why an option makes sense there.

If you do end up comparing semantic toolings I'd love to hear what you find. The space is weirdly fragmented between syntax-aware, normalized-AST, and domain-specific (dyff/jd). Everyone calls it "semantic" but they're solving pretty different problems.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: