I’ll do comments first and then code. It’s a lot faster for me to keep a flow and pseudocode and then write the code in between. If the comments are two pedestrian afterwards (increment i), I will erase the comments.
I started this technique early in my career back in the late 90s after reading “Code Complete”.
It also helps me to pick back up faster if I get interrupted.