Dead Code: Comments or Conditional Compilation?

Quite the impassioned thread based on one throwaway comment!

I’m not looking over your shoulder when you code, and I won’t lie and say I never comment code out while I’m working. You do you.

What I said is that it’s a bad habit (habit means something different from ‘practice’), and that conditional knockouts are better, and I stand by that.

This might be some of it, I suppose. I use Neovim (btw) so commenting out a block is, like, V10jgc. But an if (false) with braces is pretty easy too: V10ksa{Iif (false) jk or something like that. Adding a const XXX = false; is something like mw'hoconst XXX = false;jk'w and I’m back where I started. This assumes that I’ve marked the header, which usually I have.

Not trying to make an argument for Vim supremacy (or… am I?) but it hadn’t occurred to me that one of these could be considered meaningfully more difficult than the other, or break focus more, because for me they’re not. Conceptually, these are the same thing: I decide the result I want, I type things, it happens. Typing the phrase “man bites dog” takes less time than “now is the winter of our discontent”, but not in a way that’s meaningful to how a touch typist sees the world.

And sure, it’s true that some of the advantage of this approach is due to Zig’s insistence on code liveness, so I think some of you are taking the opportunity to get mad about that again. Well it won’t change, so the fact that this strengthens the argument for conditional knockouts over commenting out blocks won’t change either.

Do what you want. If that includes a passionate defense of your habits against something you haven’t tried, so be it. If you’ve tried both and strongly prefer commenting out blocks of code, for some reason or other, it’s probably not the only thing we disagree about. This is fine.