A lot of people are doing this stuff
Evidence, please.
it helps to reduce code duplication of functions/uniforms/…
So does taking advantage of the ability to use multiple strings when you compile a shader. Which also happens to work when you want separate programs, so that the myriad combinations of vertex-to-geometry, vertex-to-tessellation, and so forth don’t explode on you.
Also, how many uniforms are you sharing between your vertex and fragment stages? It can’t be that many. Between vertex and geometry, you might share some, but generally, they need their own parameters.
But to get this to work, you need to insert a #define XXX_SHADER at compile time + a #LINE to keep correct debugging information
No you don’t. Again, take advantage of the fact that you can use multiple strings. Just create a simple header string for all of your shaders and stick it into the first slot in your string array. Your actual shader goes in the second.
Note: I have heard that NVIDIA has an issue with line-numbers on multi-string shaders. If that’s the case, then go bug them to fix their drivers.
because this is not standardized, everybody are using different constants name, hence it is not easy to create tools on top of it.
We did not wait eight years for the ARB to finally give us ARB_separate_shader_objects just so that we could build tools around not using it. Or, to put it another way, tools should not encourage misuse of OpenGL. And putting all of your program code in one file is not good use of the API.
At least, not for anything more than the simplest of cases.
So why not defining constants such as VERTEX, FRAGMENT, __COMPUTE, EVALUATION, CONTROLE and GEOMETRY when a different shader stage is compiled?
Because, as you pointed out, you can do it yourself. And the only downside besides an NVIDIA driver bug is that tools that are promoting API misuse aren’t quite as easy to make.
Personally, I can live with that.