Naked structs are evil because they are neigh impossible to port across architectures, compilers, programming languages and operating systems. The issues are very real and impossible to solve in a general manner - which is why every programming manual worth its salt will explicitly warn against naked fields in structures.
I’ve never seen this advice in a book before.
Oh, they’ll tell you not to write them to disk or send them over the Internet. But that’s the only portability problem with structs; using “naked fields” in a struct within a codebase is perfectly functional.
What you may be confusing is encapsulation, which has nothing to do with portability. It has to do with maintenance (which is at issue here). It allows you to change the representation of an object without changing its interface. You shouldn’t expose members of real objects because at some later date you might want to change those fields. And then everyone using them would be screwed.
Also, OpenGL has not been ported to non-C languages. Oh, the API has adapters for many languages, but they’re all just layers on top of the actual C API. There is no native Python OpenGL API; IHVs don’t have hooks for getting at a C# implementation of OpenGL.
If OpenGL had structs, it would work no differently. Other languages would simply find ways to adapt. JavaScript had to have new objects created for WebGL to be used as source arrays for buffer objects.
The only sane solution would be to define a new object type with get/set functions to hold the necessary data:
And now, finally, we’ve come full circle. Because this exact the sort of thing, these attribute objects, that was going to be a key feature of Longs Peak.
Before the ARB put a bullet into it.
Or, to put it another way, it’s not going to happen. The ARB will not rewrite the texture creation and allocation API. They’ve tried it twice, and both times it died.
Wanting it to happen will not change that. Writing large posts that detail specific ideas will not change that. Writing you own OpenGL 5.0 specification will not change that.
We all want a better API. But the ARB has made it plainly evident that we’re not getting one. All we will ever get are incremental improvements to functionality. The absolute most we might get is DSA, but even that’s pushing it.
The problem is, we’re far less concerned about “saving programmer time and effort” and far more concerned about “increasing code quality and efficiency.”
Except that we’re not. Code isn’t getting more efficient; it’s getting less efficient. Things like Java/C#, scripting languages, etc are all less efficient than C/C++. But people use them. Because it’s easier.
Why does “code quality” matter? Because someone has to maintain that code, and it is easier to maintain clean code that ugly, difficult-to-understand code. It’s easier to write and debug clean code as well.
In short: laziness: wanting to make things easier on ourselves.
Now perhaps you have a problem with the term “laziness,” equating it with a negative. But it is still accurate: we want to have to do as little work as possible, so we use the languages that allow us to do as little work as possible.
Reference counting smart pointers in C++ are an automatic garbage collection implementation, after all.
No, they really aren’t. I’ve never heard anyone equate reference-counted smart-pointers to actual garbage collection before. They are not the same thing.
Garbage collection is not a generic term for any automatic memory management system. It refers to a specific scheme for dealing with memory automatically, one that is not intrusive and generally does not require writing extra code (with the exception of possibly having weak references).