← Back to context

Comment by 1718627440

9 days ago

I don't think this is enough to completely obsolete comments, but a good chunk of that information can be encoded in a VCS. It encodes all past approaches and also contains the reasoning and why not in annotation. You can also query this per line of your project.

Git history is incredible important, yes, but also limited.

Practically, it only encodes information that made it into `main`, not what an author just mulled over in their head or just had a brief prototype for, or ran an unrelated toy simulation over.

  • In fairness to GP, they said VCS, not Git, even if they are somewhat synonomous today. Other VCSes did support graph histories.

    Still, "3rd dimension" code reasoning (backwards in time) has never been merged well with code editing.

    • > In fairness to GP, they said VCS, not Git

      I did say VCS, but I also don't know what Git is missing in this relation.

      > Other VCSes did support graph histories.

      How does Git do not?

      > Still, "3rd dimension" code reasoning (backwards in time) has never been merged well with code editing.

      Maybe it's not perfect, but Git seems to do that just fine for my taste. What is missing there?

    • > Other VCSes did support graph histories.

      Yes, git ain't the only one, but apart from interface difference, they are pretty much compatible in what they allow you to record in the history, I think?

      Part of the problem here is that we use git for two only weakly correlated purposes:

      - A history of the code

      - Make nice and reviewable proposals for code changes ('Pull Request')

      For the former, you want to be honest. For the latter, you want to present a polished 'lie'.

      6 replies →

  • If you throw away commit messages, that is on you, it is not a limitation of Git. If I am cleaning up before merging, I'm maybe rephrasing things, but I am not throwing that information away. I regularly push branches under 'draft/...' or 'fail/...' to the central project repository.

But why would you ever put that into your VCS as opposed to code comments?

The VCS history has to be actively pulled up and reading through it is a slog, and history becomes exceptionally difficult to retrace in certain kinds of refactoring.

In contrast, code comments are exactly what you need and no more, you can't accidentally miss them, and you don't have to do extra work to find them.

I have never understood the idea of relying on code history instead of code comments. It seems like it's all downsides, zero upsides.

  • Because comments are a bad fit to encode the evolution of code. We implemented systems to do that for a reason.

    > The VCS history has to be actively pulled up and reading through it is a slog

    Yes, but it also allows to query history e.g. by function, which to me gets me to understand much faster than wading through the current state and trying to piece information together from the status quo and comments.

    > history becomes exceptionally difficult to retrace in certain kinds of refactoring.

    True, but these refactorings also make it more difficult to understand other properties of code that still refers to the architecture pre-refactoring.

    > I have never understood the idea of relying on code history instead of code comments. It seems like it's all downsides, zero upsides.

    Comments are inherently linear to the code, that is sometimes what you need, for complex behaviour, you rather want to comment things along another dimension, and that is what a VCS provides.

    What I write is this:

        /* This used to do X, but this causes Y and Z 
           and also conflicts with the FOO introduced 
           in 5d066d46a5541673d7059705ccaec8f086415102.
           Therefore it does now do BAR, 
           see c7124e6c1b247b5ec713c7fb8c53d1251f31a6af */

  • Both have their place. While I mostly agree with you, there's a clear example where git history is better: delete old or dead or unused code, rather than comment it out.