These examples demonstrate various ways to load and compile shaders. All examples must include error handling code.
Shader objects, as created from
glCreateShader do not do much. They contain the compiled code for a single stage, but they do not even have to contain the complete compiled code for that stage. In many ways, they work like C and C++ object files.
Program objects contain the final linked program. But they also hold the state for the program's uniform values, as well as a number of other state data. They have APIs for introspecting the shader's interface data (though it only became comprehensive in GL 4.3). Program objects are what defines the shader code that you use when rendering.
Shader objects, once used to link a program, are no longer needed unless you intend to use them to link other programs.