Better Programming

Advice for programmers.

Follow publication

Member-only story

Here’s How the CPU Handles If Statements and Branching

Nicholas Obert
Better Programming
Published in
7 min readDec 7, 2021
Photo by Onur Binay on Unsplash

These days, there seems to be a holy war going on against if statements and branch programming in the software development community. Branching consists in altering the control flow of a program by switching to another sequence of instructions. The simplest example we’re all familiar with is the use of if statements:

Now, branching and if statements are a staple of programming and have been around since ever. Through the decades they acquired a bad reputation, though; countless YouTube videos, blog posts, and articles talk about why you should avoid using them like the plague. Because of this, I guess most people despise branching just because they heard it’s bad, without really knowing what they’re talking about.

In this article I’m going through the why and when this practice is considered inefficient. I will also provide some alternatives and contexts in which branching is…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Write a response