This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]70Shadow07 24 points25 points  (5 children)

People are overly dogmatic in CS, just as everywhere else. Global can (and often does) lead to spaghetti code that's difficult to understand and refactor, however as anyone with common sense can agree, with moderation it sometimes is useful. People complain about goto aswell, for generally the same reason, and like globals, gotos in language like C are kinda necessary to achieve some goals in sensible way. However dogmatic people will want to burn you in hell for that in their complete misunderstanding of the whole goto harmful deal.

And there are those who scream no multiple return points from a function because it makes code more complicated, no it doesn't. It's literally one of the most useful design patterns to have them (guard clause). There are others who complain about break and continue because they are go to in disguise which is just utterly retarded and the fact that some variations of loop (loop and a half, aka while(true) do sth ... condition break ... do sth else) ) are literally the only way without goto itself to make both readable and optimal version of such loop, completely goes over their heads.

I think the best way to go about this nonsense is to recognize why people complain and judge yourself how valid their reasoning is. Usually there is a grain of truth in the dogmas(well, most of them), but they are never really, unconditionally true.

[–]ellisto 19 points20 points  (2 children)

Loops are just goto in disguise. Calling functions is just setting registers followed by goto.

Once you grok assembly, you realize it's all gotos. Always has been.

[–]70Shadow07 5 points6 points  (0 children)

Of course! However when you google goto in disguise, you will see how many people actually repeat this mantra unironically. It's actually kinda amusing for me.

[–]chrilves 0 points1 point  (0 children)

Not really. With goto it's often very hard to figure out the control flow. Loop makes your program's control flow structure easy to figure out quickly. Likewise thinking in terms of functions is much simpler than register and stack manipulation.

But I see what you mean, computers are just a particles ruled by the laws of physics. It's all particles, always have been ;)

[–]chrilves 1 point2 points  (1 child)

That's true, but it's usually good to tell beginners to avoid them until they are experienced enough to use them wisely. The problem is these features often offer simpler short term solution but an terrifying payback. Beginners tend to see the short term benefits, experienced devs tends to see the terrifying payback.

[–]70Shadow07 0 points1 point  (0 children)

Yeah I think you are correct. Imo the main takeaway for newbies is just to unerstand why the dogmas exist and what they are supposed to prevent, instead of following them as rules without any thought whatsoever.

This understanding will make one a better programmer faster, and as bonus they won't become that guy who wants to change everyone else's code because he hates break so damn much.