activating PULLUP: what's the difference?

I have come across two different usages for input pins with activated pullup resistor.

What is the difference between

pinMode(pin_number, INPUT); digitalWrite(pin_number, HIGH);

vs

pinMode(pin_number, INPUT_PULLUP);

The last code uses about 120 Bytes less flash memory when compiled. But why is that / what other code is used "under the hood" in the two line code version?

You have the source for the "under the hood" code - why not look at it?

The first one sets the pin as an input, and then writes it high, enabling the pullup, and requires both pinMode() and digitalWrite() to be built.

The second one does it all at once, and only requires pinMode().

It's the need for digitalWrite() that makes most of the difference. You'd find the difference between these to be much smaller:

pinMode(pin_number, INPUT); digitalWrite(pin_number, HIGH); digitalWrite(other_pin, HIGH);

vs

pinMode(pin_number, INPUT_PULLUP); digitalWrite(other_pin, HIGH);

I would have expected the compiler to treat the two versions identical, since there is no additional code between the two code lines of the first version.

halfdome: I would have expected the compiler to treat the two versions identical, since there is no additional code between the two code lines of the first version.

That would make it a very poor quality compiler. The semicolon is meaningful in C++.

In other words, you, the programmer, told the compiler, "These are two separate statements. Treat them accordingly."

But doesn't the compiler get rid of -for example- variables that have been declared but are not called later? That seems like a similar situation to me.

halfdome: But doesn't the compiler get rid of -for example- variables that have been declared but are not called used later?

Maybe. Depends on the circumstances.

That seems like a similar situation to me.

Variables are declarative / not executable.