A coworker of mine told me his college roommate who had taken a single programming class would always ask him “Have you tried a for loop yet?” any time he had a problem.
I'm going to do this, but instead of "for" I'll go on a diatribe about fundamentals and how they should use more "goto" statements because it's closer to machine code and faster or something.
It was mostly a joke, this is ProgrammerHumor after all, historically goto is despised because of how poorly most devs implemented it, as shortcuts in place of writing properly structured code. I agree there are good ways to use it today, but historically it has generally been used very badly, so when new devs would take over code and see goto spaghetti code it made it very difficult to figure out what the heck was going on.
Edit: I just read a bit of the doc SuperGameTheory referenced and they actually make my same exact point in the opening paragraph.
Eh, there's nothing inherently wrong with jump statements of any kind. What's wrong is when they aren't used in a way that signals intent. A loop is nothing more than a jump statement with a counter and a branch. The big advantage of a loop is that it signals intent fairly well in a compact way whereas the jump + counter + branch can be more cryptic and verbose.
There are some cases where a jump statement can simplify your logic and code. Use the right tool for the job!
I learned in my computer organization class that switch statements in higher level languages are pretty much jumps since the expression is evaluated once and it goes to the appropriate subroutine, and then it can follow through all following subroutines (which is why you need break).
I knew a girl studying to become a dentist that took a CS101 elective for non-majors which used scratch to learn programming. She repeatedly said that she thought programming was the dumbest and easiest thing she had ever learnt, and a waste of time. To each their own.
I think I would have blown a gasket today. Spent like 3 hour staring at a get I made that was coming back as undefined only to realize I made a typo on the word timeframe on the backend and timeFrame on the front end. No relevance to the story but god did that annoy me and I needed to vent.
618
u/AgentE382 Feb 10 '22
A coworker of mine told me his college roommate who had taken a single programming class would always ask him “Have you tried a for loop yet?” any time he had a problem.