Live data from Hacker News

Why is it so hard to see code from 5 minutes ago?

web.eecs.utk.edu

41–50 of 424 posts

Re: Why is it so hard to see code from 5 minutes ago?

#41

For anyone that uses emacs, there is an excellent plugin "undo-tree" that solves this problem in a slightly different way. Everytime you undo a series of actions and then perform a new action, it creates a branch in the "tree". You can then visualize the tree and move through it quickly your entire buffer history.

It can even persist history across restarts if you set undo-tree-auto-save-history.

Re: Why is it so hard to see code from 5 minutes ago?

#42
post #32

If looking at a source browser of a previous version of your code is not adequate to understanding how it worked, such that you wish to "rewind" to that version and run it, then your code is very poorly written. It is indeed difficult sometimes to understand our own code some time after it is written, but by following good practices (ideally functional, with mostly pure functions), it should be readable. I will ventu…

Nope. Sometimes I’m rewriting something and I just want to see what the old code looked like before I changed it. There’s nothing smelly about that.

That's what a git browser is for. It's not like your code is gone forever, unless you are undisciplined.

Re: Why is it so hard to see code from 5 minutes ago?

#43

Does anyone know if there’s a good way to do this in VS Code? I often hold cmd-z until I get to some version and copy code from it. Ideally I’d like to have a separate window where I can see a previous version without affecting the current file/view. Before anyone comments, git doesn’t cut it for this because no one commits after every -+1

Like an ongoing stream of history where I have a slider I can drag to revert on-the-fly.. That'd be cool. I mean you could easily record and do this, but that doesn't copy-paste well.

EDIT: And of course I read the article after reading the comments.. Haha, VS Code plug-in in 3.. 2..

Re: Why is it so hard to see code from 5 minutes ago?

#45
post #32

If looking at a source browser of a previous version of your code is not adequate to understanding how it worked, such that you wish to "rewind" to that version and run it, then your code is very poorly written. It is indeed difficult sometimes to understand our own code some time after it is written, but by following good practices (ideally functional, with mostly pure functions), it should be readable. I will ventu…

Are you certain the requirements can always be met without complexity? Have you ever had to build an os kernel, a database, an mmorpg server, a realtime 3d game engine, a production compiler, jit, or garbage collector?

I never said there was no complexity. The idea is to manage it well.

And sure, it may be long ago, but I have some code in a AAA game. Even C++ with hundreds (*edit) of files, we got along just fine without rewind.

Re: Why is it so hard to see code from 5 minutes ago?

#47

For anyone that uses emacs, there is an excellent plugin "undo-tree" that solves this problem in a slightly different way. Everytime you undo a series of actions and then perform a new action, it creates a branch in the "tree". You can then visualize the tree and move through it quickly your entire buffer history.

Undo in region is also pretty useful if you want to revert part of your code but not all.

Re: Why is it so hard to see code from 5 minutes ago?

#48
I learned very early in to "Commit early, commit often!"

That being said, I don't think the reasons viven are honest: > When asked why they did this, they revealed they were trying to view some intermediate state of the code in the middle of a change.

Looking at some GitHub repos, with one single commit, I believe many devs are afraid someone could see all their trial and error attempts and judge them.

I oersonally am too lazy for the undo redo nonsense. Many of my final commits are mostly cleaning up the code. E.g. Refactoring so my code is like reading a story.

I don't have an issue with people thinking I have OCD or something similar. My bigger issue is if I ever have to touch my code again, to waste time on trying to understand it. Or even worse, someone else not understanding it and asking me for help.

Re: Why is it so hard to see code from 5 minutes ago?

#49
post #12

Earlier quoted context omitted.

Yeah and it’s actually decent. That being said I don’t mind committing often. If I have a slew of small commits I squash them. Since I will need to commit at some point, I rather do it incrementally.

Committing removes the diff view in PyCharm, and I can't lose that. By "diff view" I mean I can see all the changes I've done from the main branch.

Personally, when I'm ready to submit a pull request, I usually do a soft reset to the point where I branched off from, then redo my commits and force push to the branch, for exactly that reason. I can't remember exactly which lines I've changed over the past few days unless I see all the diffs together.
Post reply on HN