587
submitted 11 months ago* (last edited 11 months ago) by PeriodicallyPedantic@lemmy.ca to c/programmerhumor@lemmy.ml
  • Adding a line: ✅
  • Removing a line: ✅
  • Modifying a line: ✅
  • Moving a codeblock: ❌ i see you've rewritten everything, let me just highlight it all.

RIP reviewers on my PR.

(Meme created by my coworker)

you are viewing a single comment's thread
view the rest of the comments
[-] killeronthecorner@lemmy.world 34 points 11 months ago

I'm convinced there must be a way of using ASTs to do more intelligent diffing of a given programming language, but I'm far too lazy to find out for myself.

[-] omidmnz@lemmy.world 51 points 11 months ago
[-] killeronthecorner@lemmy.world 24 points 11 months ago

Hell yeah, being lazy paid off. Thanks.

[-] omidmnz@lemmy.world 7 points 11 months ago

You're welcome. And have fun trying to break it!

[-] ryathal@sh.itjust.works 11 points 11 months ago

There is, but your dif tool would have to be language aware and likely be slower to show difs.

[-] kibiz0r@midwest.social 6 points 11 months ago

There have been some attempts at semantic diffs, but it’s very uhh… difficult to gain traction with such a thing.

[-] sim642@lemm.ee 5 points 11 months ago

Diffing algorithms on trees might not be as efficient, especially if they have to find arbitrary node moves.

[-] killeronthecorner@lemmy.world 2 points 11 months ago

I wouldn't expect it to be, but I think modern processors can handle the load!

[-] sim642@lemm.ee 2 points 11 months ago

It's not necessarily about the load, it's about the algorithmic complexity. Going from lists (lines in a file, characters in a line) to trees introduces a potentially exponential increase in complexity due to the number of ways the same list of elements can be organized into a tree.

Also, you're underestimating the amount of processing. It's not about pure CPU computations but RAM access or even I/O. Even existing non-semantic diff implementations are unexpectedly inadequate in terms of performance. You clearly haven't tried diffing multi-GB log files.

[-] killeronthecorner@lemmy.world 1 points 11 months ago* (last edited 11 months ago)

Log files wouldn't fall under the banner of compiled languages or ASTs, so I'm not sure how that example applies.

And I'm aware that it can lead to O(n²) complexity but, as others have provided, there are already tools that do this, so it is within the capabilities of modern processors

Yes there will be cases where the size of the search space will make it prohibitive to run in reasonable times but this is - by merit of the existing tools and the fact that they seem to work quite well - an edge case.

[-] sim642@lemm.ee 0 points 11 months ago

Log files themselves don't, but I'm just comparing it with simpler files with simpler structure with simpler algorithms with better complexity.

this post was submitted on 20 Oct 2023
587 points (97.9% liked)

Programmer Humor

32045 readers
1537 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS