Recently, while working on a freelance project, I wrote some Python code for about an hour with full concentration and staying away from the terminal.
Then I ran the code.
And Boom! It executed successfully on the very first run.
When was the last time you ran your code successfully on the first try?
Top comments (6)
One thing you learn after about 30yrs of coding is to never write more code than you know will work on the first try. This way you genuinely end up with about 95% of your code just always working every time, on the very first try. I genuinely do that all day every day.
Sure part of this is just the skill level attained from that many decades under your belt but the thing junior developers can learn is only write a few lines at a time. Once you think "I wonder if this is going to work" you've written too much already. Comment out some (to back up) to where you fully understand it again, then test that first, before adding more.
Also when the code DOES fail you know which 5 lines of code to look at and in generally have the 'ah ha' moment the second yo do see it fail, when it does.
Great Advice.
With typescript it happens usually
About 20 minutes ago (granted, the code was
console.log(this);
)Yesterday
Over 100 years ago before I existed.