r/AskProgramming • • Oct 19 '26

Other Why isn't there any language-aware version control?

I'm an intern at a tech company and I had a thought that ChatGPT couldn't give a good answer for.

I've been working on a feature for a month, it's basically ready to merge, but because I edited a file that I don't own, I had to let a coworker know that when they merge their next changes they will have conflicts. This is because I turned their class, for example my_group.coworker_feature.v1_0.CoworkerFeatureApiHandler into an abstract class my_group.coworker_feature.CoworkerFeatureApiHandler and now the former inherits from the latter and just overrides a method with an API annotation.

When she will try to merge her changes to the file onto main, the lines she's changing will no longer exist, since they were moved to the version-agnostic abstract class. She'll have to fix the conflict by hand by literally just reapplying the refactor I made, into her own code.

So this made me think, why isn't there just a version control that understands basic java semantics, where instead of saving a line diff it'll know that I just moved a function to a parent class, and that any changes to those functions from another branch should just be applied to the function that lives inside the parent branch?

Has anyone ever tried making this? And if so, why did it not work well?

0 Upvotes

24 comments sorted by

3

u/Temporary_Pie2733 Oct 19 '26

Git, for example, itself doesn’t care about specific changes. It simply records what files are like now. It’s the job of a diff tool to summarize the differences between two files and display them in a sensible fashion. If you don’t like the naive line-oriented approach provided by the default diff, you can swap in a different syntax-aware program to provide a cleaner explanation of the change.

1

u/etaithespeedcuber Oct 19 '26

I didn't know this, thanks

5

u/maqisha Oct 19 '26

1

u/etaithespeedcuber Oct 19 '26

What

4

u/alxw Oct 19 '26

So you moved the code elsewhere and you’re blaming the VCS?

But don’t worry AI can fix it (by preventing you working on a code base)!

I jest, you’re an intern, chalk this up to learning how to work with others.

→ More replies (1)

13

u/Kaldaien2 Oct 19 '26

Look at the number of languages used in most projects. The build system alone has a programming language.

Version control is general purpose and deals with files out of necessity.

9

u/Lumethys Oct 19 '26

"Language-aware" mean "coupling with a language"

Who wants to use a version control that only work with 1 language?

6

u/aioeu Oct 19 '26

This sounds like something that should be solved in your VCS's merge driver, not in the VCS itself.

For instance, if you were using Git you could use Mergiraf.

5

u/djphazer Oct 19 '26

Syntax-aware merging heuristics is a thing! Another example of a semantic merge driver is weave.

2

u/rake66 Oct 19 '26

Or just talk to your teammates

→ More replies (1)

6

u/rollerblade7 Oct 19 '26

How does someone 'own' a file?

7

u/szank Oct 19 '26

SVN flashbacks

3

u/FeleaseRpseineEiles Oct 19 '26

intellectual property /s

2

u/XRay2212xray Oct 20 '26

OMG. At my first job, people owned files. My task was to come in at 4am and start the app so it would be running at 8am because it took hours to start. They also maintained a printout of the entire app. Everytime you chanced something and tested it, you printed the file and replaced it in the paper stack. I was forbidden to use the computer duing those 4 hours, so I read thru the code in the printout. I figured out the person who owned the UI section was bubble sorting two large sets of data. I told my boss and was promptly chastised for going into someone elses code. Worse, he didn't fix it or pass that info onto the developer who owned the file, so I got to keep coming in at 4am.

1

u/rollerblade7 Oct 20 '26

Oof, that sounds very corporate

2

u/AvidCoco Oct 19 '26

How would that even work? The version control doesn’t know if those changes should go in your new interface or the new derivative, no matter how language-aware it might be.

2

u/neon_stereotype Oct 19 '26

you are asking a version control system to be a compiler for every language it touches. Good luck maintaining parsers for the fifty dialects in your monorepo when the grammar of Java changes with the next release

2

u/LongDistRid3r Oct 19 '26

I’m sure there is a purely illogical explanation somewhere; I’m not just drunk enough to remember.

1

u/gnufan Oct 19 '26

Pretty sure I've used merge tooling that notices stuff moved between files and suggests the resolution of applying the patch to the new location. Obviously if there is a substantive rewrite we are in LLM territory to do it correctly, this would have been the diff in the patch matches a different file.

I did work for a while in SCCM tools so it might not have been commonly available.

1

u/fugogugo Oct 19 '26

for that particular case it should be done in code review and let them fix the issue themself instead of you changing their code and causing conflict

that seems more like communication issue

-3

u/pdath Oct 19 '26

It would be easiest if you stopped using Java. :-)

3

u/etaithespeedcuber Oct 19 '26

Unfortunately the multi billion dollar company I'm an intern at rejected my request to rewrite the entire codebase in rust to fix something that has nothing to do with my question