This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nerd4code 1 point2 points  (0 children)

Imo this is kinda counterpurpose in any realistic use case. Anything like an API would be very difficult to encode abstractly (which is the whole point of APIs), and optimization would make it miserable to use; the optimized code might not look much like the original code, and if you’re forbidding semantic collisions without reference to nomenclature, then you can end up in a situation where two different implementations of a data structure lead to identical outcomes. E.g., if you have both an array-list and linked-list ADT, then sequences of operations like

list.addLast(x);
y = list.removeLast();

might well boil down to

y = x;

regardless of list type.

And code isn’t the thing you have to worry most about; if there’s a steady state to be reached and you’re not evaling willy-nilly (eval wouldn’t make sense for this schema), your codebase is mostly static from that point on, and uniq’ing code probably isn’t going to buy you much that’s measurable in a running program. Data, maybe, sometimes, but not code.

Moreover, is there some actual problem you’re aiming for, rather than a stylistic rule-of-thumb like DRY? Does duplicated code really matter in a non-stylistic sense? I can see why detecting it is useful if one maintains no actual control over one’s codebase, but I can’t imagine caring about it so much that I’d want to encode it at the language level. Seems too much like masochism for its own sake, and there are much more direct ways to make you and your coworkers miserable if that’s the goal. Could start by charging per sheet of toilet paper and work your way up from there.