So does shorter code = more efficient?

I’m guessing that the less processes the computer needs to run through in the code the faster the program I do? I’ve been doing SoloLearn as an introduction to coding and I see people in the comments talking about how to make examples shorter, to make it “more efficient”.

But I haven’t seen anybody expand on that and explain how much that impacts the program performance compared to other things. Tbh I don’t really understand what kind of things affect performance, since incorrect code just doesn’t let the code compile to begin with

(I’ve been dabbling in c# and c++ if that’s relevant)
usps tracking showbox

When people say “more efficient” in this case, they really mean “easier to read”.

When you are “coding”, youre actually spending most of your time reading your code and not much time adding to it. Therefore, in order to make code more “efficient” and easier to understand, one method is refactor your code by simplifying or removing unnecessary code.

Maintainabilty is one of the most important traits of good code, maybe even more important than your code actually working, because not only might you return to it later and need to understand what you were doing, but others who might need to work on that code after you need to understand it as well.

Shorter code doesn’t make your program faster and that’s why you probably will never see anyone expand on that, but it often makes your code more readable and maintainable.

Code by itself doesn’t affect performance, execution of the code does. If I have very complex algorithm applied to one pixel - that’s still fast and thus performant. If you have 20 million pixel image - the same function might be quite slow and not performant at all.

You don’t want small code. You want efficient code and readable code. Small code often is neither.

Efficient code does what you need without doing anything extra. Efficient code is often, but not always, simple.

Redable code is easy to understand and update.

You don’t want to use as few characters as possible. Code smart, not tiny.