The most common cause of security problems and run-time errors are "buffer overflow" errors (C++ Primer 4th ed).
Basically, this means that the programmer has written a program incorrectly. He/she has either tried to access an element of a container that doesn't exist, or tried to assign a value to a class that doesn't accept that type of value. Or something similar.
This sounds like an easy problem to fix--only assign numbers to number-type variables. Assign text to text-type variables. The real problem is that there are a lot of different "number-type" and "text-type" classes. And every different kind of class you can think of and a lot more that you haven't thought about. Even within the type "number" we can talk about whole integer type numbers, or floating point type numbers, imaginary numbers, Marsenne primes, etc.
Another problem; a lot of the types built into the C++ language are non-intuitive. Or rather, the vital differences are difficult to remember and cumbersome. Example, there are three different types of floating point classes, each with different storage capacities. And even the capacities are not set in stone, they depend on the machine that runs the source code a programmer writes.
So why don't we just change the language?
Because it's precise. Everything that C++ is, is that way for a good reason. It is a very powerful, efficient, and precise language. The fact that C++ seems "non-intuitive" really highlights how imprecise we are.
And I'm not saying it's a bad thing. Languages are developed for purposes. Programming languages are developed to solve problems and create data structures. English is a very general purpose language that I think succeeds in its goal. To communicate.
Sometimes its ambiguity is even a good thing. It helps succintly create multiple meanings in literature. We enjoy discovering and creating our own meanings from our experiences. Being able to communicate those meanings gives English--and other spoken languages--a power of their own.
No comments:
Post a Comment