4 ms·
Someday I want to write a diff utility specifically for code. Whitespace addition/removal cost like .1, addition/removal of a curly brace .5. There are a handfu
by nwallin 7y ago
Someday I want to write a diff utility specifically for code. Whitespace addition/removal cost like .1, addition/removal of a curly brace .5. There are a handful of other things default diff does that make it really annoying for code.
- apjr 7y agoI did this for a school project, because students would "cheat" on group projects by exclusively changing whitespace in diffs, or moving code around, thereby making it look like they had large commits. We tracked code "moves", whitespace changes, and "trivial" changes via Levenshtein distance--which isn't great for capturing most simple renamings--and then marked them up separately in an "augmented diff". We briefly looked into doing AST edit-distance, but that turned out to be infeasible for many reasons. Over-all it helped the prof grade faster, at least in the degenerate cases.
- bonoboTP 7y agoMeasuring a student's impact by a project on the number of lines of code they committed can be very misleading. Sure, in the extremes it will give sensible results (someone wrote only 3 lines, or wrote 90% of the code base). But minor, questionably motivated refactorings can create huge commits, while someone may come up with some great design while walking around for hours and sketching on paper, which all ultimately boils down to a short function. Dumb metrics like this cannot replace actually talking with the students, asking questions about their choices and alternatives, having them do presentations or lab notebooks/logbooks etc.
- Cogito 7y ago> Dumb metrics like this cannot replace actually talking with the students, asking questions about their choices and alternatives, having them do presentations or lab notebooks/logbooks etc. As said in the parent: >> Over-all it helped the prof grade faster, at least in the degenerate cases.
- truncate 7y agoI never actually used any of these, but have stumbled upon some tools which create/apply diffs on ASTs of your source rather than lines[1]. I think the keywords to search is "semantic diff/patch/merge", "AST diff" or some combination of these. [1] https://lwn.net/Articles/315686/ https://lwn.net/Articles/315686/
- 9nGQluzmnq3M 7y agoDiff already has a number of options for ignoring whitespace changes: https://www.gnu.org/software/diffutils/manual/html_node/White-Space.html#White-Space https://www.gnu.org/software/diffutils/manual/html_node/Whit...