Live data from Hacker News

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

web.eecs.utk.edu

171–180 of 424 posts

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

#171

In Git you don’t have to actually commit, you can use the staging area. It’s something I do rather often. I’m going to make a non-trivial change and I’m not sure if it’s the right approach, so I `git add -A` first, make my change, and then `git diff —-cached` to review it. This is especially useful when doing things like running formatting tools, so I can see what the tool just did. And it doesn’t require making any…

Eh, I use the dumb approach of:

    cp code.d code.old
if I'm going to make some trial changes :-/

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

#172

Jetbrains IDEs have a local history feature that provides snapshots with diffs and allows partial rollbacks. I only use it when experimenting with different approaches. Mostly I only use the "Local Changes" tab in the Git panel that shows the diff compared to the last commit, or "Compare with branch" to see the overall changes relative to the base branch.

Local history saved my sorry butt yesterday when I thought I lost all my files due to a git-related accident. But Local History still had all my changes and restored my files.

Unclear why this isn't baked into the OS nowadays. It's not like we don't have enough disk space ;)

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

#173

Earlier quoted context omitted.

I do the same - both commenting out and viewing the file in parallel at different spots - vim vertical splits are great for that. In fact, one of my colleagues remarked that he never thought to view the same file alongside itself when he saw me do that when we were pairing.

As an aside, I think I wouldn't mind if a programming language would include two commenting syntaxes, one for ordinary comments, and another for commenting out. These are two very different use-cases, and distinguishing them syntactically might facilitate certain kinds of work-flows.

I'll sometimes use:

    version (all)
    {
        ... new version ...
    }
    else
    {
        ... old version ...
    }
and change `all` to `none` to try the other branch.

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

#174
post #50

Reading the comments, I'm stunned and disillusioned. Are most modern developers struggling to write code without this? If so, there is a fundamental problem that has nothing to do with levels of undo.

I am more stunned by the tone your response. Why are you implying there's a "struggle" or "fundamental problem"? Sorry but your language is very condescending.

Sometimes it's easiest to hit Cmd+Z a few times to check out how something looked at an earlier stage of a change. And then it's easy to Redo everything back to the current state. Rewinding changes back can even jog your memory as to why you did something. It's fast, simple, and effective. What's so bad about that?

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

#175

Sad to see so much judgement in this thread from developers who can't fathom why others would need this. "Sounds like trial an error." "Develop a better memory." Programming is not black and white, there is no right or wrong way to do it. OP discovered a problem they had and wrote a solution for it, believing that others might need to solve the same problem. Clearly they were correct based on plenty of others chiming…

I try to rememberf my local history view in the editor, it sometimes give a better overview.

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

#176

Earlier quoted context omitted.

As an aside, I think I wouldn't mind if a programming language would include two commenting syntaxes, one for ordinary comments, and another for commenting out. These are two very different use-cases, and distinguishing them syntactically might facilitate certain kinds of work-flows.

A common code style rule for C# is // for comments and //// for commented out code (/// is reserved for documentation generation). StyleCop analyzers can enforce this during code analysis passes. While this isn’t a language construct (a comment is a comment after all), Visual Studio can key off these stylistic differences to show code comments vs commented code differently. I find it to be a neat trick to improve cod…

Cool.

I've never touched C#. But that seems like an approach applicable pretty generally. I like it!

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

#178
post #9

If I remember correctly, Eclipse used to have (still has I guess) a feature were it would store code changes in a local history independent from your version control.

Yes, definitely Eclipse local history.

At least 10 years using it. What's interesting though is that such a feature would be off the radar for other editors and even the OP article.

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

#179

In Git you don’t have to actually commit, you can use the staging area. It’s something I do rather often. I’m going to make a non-trivial change and I’m not sure if it’s the right approach, so I `git add -A` first, make my change, and then `git diff —-cached` to review it. This is especially useful when doing things like running formatting tools, so I can see what the tool just did. And it doesn’t require making any…

Eh, I use the dumb approach of: cp code.d code.old if I'm going to make some trial changes :-/

Nothing wrong with that :)

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

#180

In Git you don’t have to actually commit, you can use the staging area. It’s something I do rather often. I’m going to make a non-trivial change and I’m not sure if it’s the right approach, so I `git add -A` first, make my change, and then `git diff —-cached` to review it. This is especially useful when doing things like running formatting tools, so I can see what the tool just did. And it doesn’t require making any…

Are you suggesting that people make commits before reviewing the changes? I never thought of that...
Post reply on HN