3 ms·
actually, what we want is code management tools that work with tokenized code and do not depend on formatting. i want a diff tool that shows me exactly which to
by em-bee 3y ago
actually, what we want is code management tools that work with tokenized code and do not depend on formatting. i want a diff tool that shows me exactly which tokens have changed, and which haven't, regardless of how they are laid out. when we get that, then we should get even less merge conflicts.
- jasomill 3y agoAnd I'd prefer a system with an AST as the canonical representation, allowing each programmer to set their own display formatting options entirely independently of the underlying codebase. Realistically, either of these options would only really work for tools and codebases designed with these workflows in mind, as they'd be useless for inputs to inherently text-based tools like the C preprocessor.
- karma_pharmer 3y agoallowing each programmer to set their own display formatting options entirely independently of the underlying codebase. That's the easy case. The hard case is situations where the formatting (whitespace, etc) is not simply some deterministic function applied to the AST. For example: comment placement and tabular layout of repetitive constant definitions. Or situations where vertical alignment is used to call out parallel structure. Mathematicians have been using horizontal alignment to call out important structure in equations (both written and typeset) for hundreds of years. Here's are two examples if you don't know what I'm talking about: https://kagi.com/proxy/ILVap.jpg?c=085W0W0Vgv9kix8Uo-TAMYM_FT1u23UFqHfiq4zyoC7SNFxXinp9WqjiTM14lkaA https://kagi.com/proxy/ILVap.jpg?c=085W0W0Vgv9kix8Uo-TAMYM_F... https://kagi.com/proxy/Zr5re.png?c=085W0W0Vgv9kix8Uo-TAMb-ZJ9tlIOckKNxTWVDXFV8DwbMWKEFKbX9zuX2S1K7U https://kagi.com/proxy/Zr5re.png?c=085W0W0Vgv9kix8Uo-TAMb-ZJ... The people who stubbornly insist that programmers have no need for this sort of expressiveness seem like innumerate cavemen, frankly. They cheapen our field, reducing it from informatics to mere keyboard labor. The urge to run code formatters is a "language smell" indicating that your language has way, way, way too much odd and irregular syntax. See Haskell for a counterexample. Sure, there are a few code formatters for Haskell, but nobody really uses them. The language's syntax is so minimal and clean that there just aren't all that many preference-based choices to be made.
- tome 3y ago> there are a few code formatters for Haskell, but nobody really uses them I haven't run a survey, but I get the impression that code formatters are widely used in the Haskell world, especially Ormolu and Fourmolu.
- karma_pharmer 3y agoThey are in fact not widely used. Ormolu and Fourmolu That's only one formatter; the latter is a fork of the former... which is the in-house formatting tool of one particular consulting firm. It has only existed since 2018, and is said to be mainly a response to golang/rust people trying to impose their culture on the Haskell world. Pointing at ormolu is kinda like saying that formatters are popular in the Java world because google-java-format exists. The fact that that project exists says more about the company that created it than the community around the language it operates on.
- tome 3y ago> They are in fact not widely used. Ah, as a fact it presumably has some form of evidence that demonstrates it. Would you mind sharing that evidence?
- karma_pharmer 3y agoi want a diff tool that shows me exactly which tokens have changed, and which haven't, regardless of how they are laid out. These already exist: https://github.com/Wilfred/difftastic https://github.com/Wilfred/difftastic when we get that, then we should get even less merge conflicts. Counterintuitively, that is not the case. AST-merge is a much, much, much, much, much harder problem than AST-diff. https://github.com/Wilfred/difftastic?tab=readme-ov-file#can-difftastic-do-merges https://github.com/Wilfred/difftastic?tab=readme-ov-file#can... The fact that diffs can be used to drive a 3-way merge is in fact an accidental property that arises due to the sheer crudeness of the line-based diff format. As soon as you start using more-sophisticated diff formats, solutions to "the diff problem" no longer lead directly to solutions to "the merge problem".