3 ms·
The problem with diffing goes further than most people think. It's not a problem itself, it's a symptom of a deeper problem: we represent all of our code as pl
by spartanatreyu 4y ago
The problem with diffing goes further than most people think.
It's not a problem itself, it's a symptom of a deeper problem: we represent all of our code as plain text.
We have built almost everything around plain text, for a long time now. The few things that aren't built around plain text tend to require either proprietary software or open software that seldom lasts more than a decade.
Yes, plain text has impressive strengths (see: https://news.ycombinator.com/item?id=30521545 https://news.ycombinator.com/item?id=30521545) but it may be holding some areas back.
There has always been talk of smarter diffing tools (new diff algorithms, syntax aware diffing, semantic diffing) but it tends to get hamstrung around supporting plain text.
Usually the approaches go with one of two ways. Either:
1. a diffing algorithm has a smarter diffing algorithm than what we already have, until it gets into a corner case and ends up worse than what we already have.
2. an LSP-like service goes through the effort of building a full AST to perform diffs with, only to convert everything back to plain text in the end. This makes diffing take longer. The fact that ASTs can't represent some changes and we don't realize until after the work is done doesn't help this.
I'd wager that over the next few decades, new languages are going to migrate away from plain text representation and move entirely to AST representations. ASTs can be perfectly diffed, and only writing code as an AST means that it'll be impossible to write some kinds of code that is almost correct.
There's a few academic research languages around this, but I think one of the more interesting explorations with this kind of AST only development styles has to be by Dion Systems: https://dion.systems/blog_0001_hms2020.html https://dion.systems/blog_0001_hms2020.html
They basically acknowledge that we as developers are not going to move to a new AST-based tool if it's not going to work with our other tools, so they want to experiment across the development workflow to see how well ASTs can work across the development space.
Their 2020 talk about this was fascinating: https://vimeo.com/485177664 https://vimeo.com/485177664
- account42 4y agoThere is nothing preventing you from pretending that a source file is not plain text but rather a bespoke AST encoding that just happens to look like plain text. The only advantage to using a different AST encoding is parsing speed that that by no means offsets the enourmous advantages that a plain text encoding gives you for something that is edited by humans.