Explicit vs Automatic Attribute Binding I'm a beginner in OpenGL and I've been doing some research on the topic of shaders and attributes. Most places I go say that explicit attribute binding (whether it be in the shader itself with layout(location=x) or with glBindAttribLocation) is better than letting OpenGL generate some attribute number. However, I didn't completely understand WHY explicit attribute binding is better.

So I guess my question is, what are the pros/cons to explicit/automatic attribute binding, and which one is more conducive to better program design overall?
It basically gives you control of the semantics of the individual attribute indices. This mostly pays off in bigger projects, where you have many different shaders which, however, often use rather common attributes, like e.g. positions or texture coordinates. With explicit attribute locations you can establish a semantic for those attributes and enforce that on all your shaders, e.g. positions are always in attribute 0, texture coordinates always in attribute 1, ...

First, this has the advantage of not having to query the attribute index for every shader. Of course you could query it once and sotre it in e.g. a map from attribute names/semantics to indices, but establishing this beforehand is even better. And it brings us to a much bigger advantage, without explicit attribute binding you would have to bind vertex arrays of a model to the individual attribute channels not only for each model, but also for each shader, since your position array might go to attribute 0 in one shader and attribute 1 in another one.

This is not only a huge hassle, but also basically destroys the advantage of Vertey Array Objects (VAO), which are specfically there to capture all the vertex attribute state, including the enabled attribute indices and their buffer sources so that you can draw your object by just binding the VAO and calling a draw function. Without explicit attribute binding you would still have to reenable/bind the individual arrays at least for each different shader you use. With explicit attribute binding you know that your model's positions always go into attribute index 0.