OpenGL's program introspection APIs were not very well designed. They grew semi-organically from the original 3DLabs GLSL proposal. But the original design was predicated on querying only attribute/uniform locations and uniform resources.
As GLSL grew, it added a lot more kinds of resources: UBOs, shader subroutines, SSBOs, and others. Also, people realized that querying the fragment shader output variables was also useful.
What this led to was a Frankenstein's API. Every time they added a new resource to introspect, they had to add a couple more API entrypoints. In OpenGL 4.3, they finally decided to just overhaul the whole system.
The generic program introspection system can query everything the old queries could do. And the specification redefines the old queries in terms of the new, generic system. But now, when you add a new resource to OpenGL, you only need to add a few new enumerators to the existing generic queries, not whole API functions.
So long as you're using recent versions of OpenGL, you ought to use the newer query mechanism. If for no other reason than to keep your code looking more uniform.