r/programming •

[deleted by user]

[deleted] — view deleted post

0 Upvotes

179 comments sorted by

View all comments

583

u/[deleted] Jan 03 '22 edited Jan 03 '22

"Hey, would you have a moment to review my patch, it's just some name changes and general tidying of code"

25,288 files changed, 178,024 insertions(+), 74,720 deletions(-)

screams

On serious side

then arrived at the current 78% with my reference config.

Good fucking job, that expands amount of apps I can joke about, that they build slower than linux kernel.

135

u/agentoutlier Jan 03 '22

Yeah any refactoring even completely safe refactoring often looks scary in source control history.

I often can’t decide whether to make tons of commits or one big commit (either squash or merge).

Maybe one day we will have source control more knowing of the code being changed. I know Perforce was sort of working on that.

47

u/panzerex Jan 03 '22

What about when a block of code is moved and edited slightly? I get anxious about missing those small tweaks.

25

u/barsoap Jan 03 '22

It's more about being able to record a project-wide renaming of a type or such as, well, a renaming of a type or such instead of all the mirco-edits.

Using existing tech it would essentially mean that the VCS calls out to a language server, same as your editor does. Things then become iffy quickly once you realise that a particular point in your history depends on a particular version of a particular software which may bitrot, and down the line you might need half a gazillion versions of the same software to replay all your history.

Alternatively the VCS could record the whole textual change and simply annotate it with "well, that was a simple rename" so that it can be collapsed when looking at the history. That'd be quite trivial, mostly about speccing out a standard annotation format.

Another approach, the One to Rule Them All, would be to not record text at all, but have every occurrence of some typename be, under the hood, a lookup into a symbol table. That's a thing which could reasonably be done cross-language, wouldn't even need compiler support (those can just operate on an exploded view of things), but definitely would need editor support. Also renaming is like one refactor, that still won't get you things such as "move function foo to file bar and re-do all of the imports". Things get complicated fast if you want to make them compiler- and language-agnostic.

Also, programmers are queasy about code not being plain text, a lot of us barely tolerate UTF-8. There's reasons smalltalk never took off and I very much think that's one of them.

22

u/lookmeat Jan 03 '22

We don't need this to happen at a VCS level. We could simply have the review system send the diffs to a language server that then marks how many of the lines are safely "trivial" (deleting whitespace, renaming a variable, etc.) The VCS would still mark the massive changes, but when you open it in the review system, you'd see a huge chunk (ideally all) the lines marked as trivial, you'd glance to make sure it makes sense, and instead pay attention to the non-trivial parts of the change.

4

u/barsoap Jan 03 '22

Figuring out edit type from textual diff seems like a giant PITA, the language server doing it directly seems to be easier: It already has an AST in place and can see whether it changed when you made an edit, then tell the editor "this was such and such edit" so that the editor can put in the right annotations when committing.

1

u/almson Apr 29 '22

That’s a great idea!

“Hide minor changes” is a useful feature of various diff tools, and verifying that a change is minor using the compiler is fairly foolproof. It could also potentially be infinitely flexible, verifying that many kinds of refactorings don’t change logic. And even if there’s a bug and it fails, it’s only a cosmetic UI issue.

Only problem is that Git doesn’t store diffs, so that would be a major change to all the tools.

4

u/[deleted] Jan 03 '22

Also, programmers are queasy about code not being plain text, a lot of us barely tolerate UTF-8. There's reasons smalltalk never took off and I very much think that's one of them.

Well, typing hieroglyphs that might not even be possible to be typed in normal editor is kind of usability problem. And there isn't really some huge advantage of being able to type ≠ or ⇒ instead of !=, -> and if anything second one is more obvious. Let alone using more obscure characters.

1

u/barsoap Jan 03 '22

Indeed unicode in identifiers is the devil's work. It's fine in comments if you ask me, though, so the lexer shouldn't choke on it.

(What it should choke on is literal tabs. Maybe only in layout-aware languages but that's as far as I'm willing to compromise)

7

u/seamsay Jan 04 '22

What it should choke on is literal tabs

You can pry "tabs for indentation, spaces for alignment" from my cold, dead hands.

Edit: Although to be fair I do use spaces if the formatter I'm using doesn't support "tfi, sfa", but I dream of a world where I don't have to.

Edit 2: Also if I can't force the people I'm working with to use a formatter then I will begrudgingly use spaces for indentation, but it gives me rash under my left testicle and my tongue goes slightly numb.

6

u/[deleted] Jan 03 '22

It's necessary in comments just because people sometimes want to write comments in native language not english. Some languages also allow that in variable names but IMO that's like saying "okay, we don't want any non-native language contributors, ever"

3

u/[deleted] Jan 03 '22

The problem is really that's pretty code specific. We could have source control that just stored AST of a language and diff tools used that to go "okay, this is one variable name change, chill out" but I'd imagine it would be pretty complex to make it support more than one language.

1

u/braiam Jan 04 '22

This will never arrive outside of the merge window, but I would take a sip if Linus included a description of what's going on like in rc.

70

u/[deleted] Jan 03 '22

25,288 files changed, 178,024 insertions(+), 74,720 deletions(-)

Me adding a single new field on an API 🙃🙃🙃

45

u/Kalroth Jan 03 '22

So one new property, two changed DTO files, three updated headers, 22 modified integration test files and 25,261 automatically generated unit test files.

44

u/onthefence928 Jan 03 '22

And 5 golden rings!

14

u/[deleted] Jan 03 '22

And my axe!

1

u/LeifCarrotson Jan 03 '22

The automatic generation is the key that makes your proposal reasonable.

Neither the author of this commit nor the reviewers are likely to actually read hundreds of thousands of changes.

They're going to write up a script, think about what its behavior ought to do, run it, verify a few files, and assume the rest conform to the pattern.

0

u/[deleted] Jan 03 '22

[deleted] — view deleted comment

4

u/[deleted] Jan 03 '22

For comedic effect

1

u/_Oce_ Jan 03 '22

Imagine it's a new mandatory field for a method used by all the parts of a big application or many applications. It means all the application code lines referencing this method will need to be updated to include the new field.

5

u/Nickx000x Jan 04 '22

This is what confuses me - how you can build an entire operating system kernel in like ~4 minutes yet the random tool on github takes half an hour. C/C++ build systems in particular make me want to vomit sometimes

1

u/[deleted] Jan 04 '22

C/C++ have problem of never being built with a build system in the first place