Without the resistor, it is impossible for the output to be at any voltage other than that of the VCC supply rail, to which it is then directly wired. All the transistor can do in such a case is short out the power supply.
What you drew in the first picture is called "resistor transistor logic" as it depends on a pulling resistor to counterbalance the transistor and provided the limited drive in the other direction. But it wastes power (in the resistor) in one state, and it is slow in the direction where the resistor sources current.
More typically, "transistor transistor logic" was used - there other transistors would function to drive the output high when needed, or to act like the resistor does as something of a current source.` But that's largely faded from use.
Today most logic is CMOS - Complementary Metal Oxide Semiconductor. It is made of field-effect transistors with oxide-insulated gates. And it is "complementary" because there's an approximate mirror image to the schematic, with an upper P-channel FET and a lower N-channel FET which work alternately to drive the signal high or low.