Advantages
Pointers
are more efficient in handling arrays and data tables. They can be used
to return multiple values from a function via function arguments.
Pointers permit references to functions and thereby facilitating passing
of functions as arguments to other functions. The use of po0inter
arrays to character strings results in saving of data storage space in
memory. pointers allow C to support dynamic memory management. Pointers
provide an efficient tool for manipulating dynamic data structures such
as structures, linked lists, queues, stacks and trees. Pointers reduce
length and complexity of programs. They increases the execution speed
and thus reduce the program execution time.
Disadvantages
Pointers
have tremendous power but the power can swing both sides good and evil.
Pointer if used incorrectly leads to very difficult to unearth bugs
which will most probably make you go wild. Pointers are itself are not
any trouble but the value they are storing can be. If it contains a
incorrect value it can lead to disasters of massive magnitude when used.
When you use this incorrect pointer to read a
memory location, you may be reading a incorrect garbage value which if
unluckily accepted by your program as assumed correct value nothing can
help you. Consider a scenario in banking in which any customers real
account value is switched with this garbage value, he can become a
millionaire or beggar in a second, or think that in a rocket launching
software you use this incorrect value as launching angle and crashing
the billion dollar masterpiece. These scenarios are just my imagination
running wild but you cannot ignore the fact that they are possibility.
Now
when you use this incorrect pointer to write a memory location you may
be writing a unknown memory location. If you have a large memory in the
system maybe you are using a unassigned memory but if that memory by any
luck is a memory used by O.S. or Hardware and you are modifying it you
maybe corrupting your Operating System software or damaging your
hardware and their drivers. Also it is a possibility that you maybe
using a memory location already in use by your software storing some
essential data and you are unknowingly modifying it. You maybe writing
over your own code and data.
Such bugs and
errors created by the pointers may not show up immediately but come up
later and it is at that time difficult to predict that it was the
pointer to blamed.
Due to these drawbacks of pointers, Programming language like JAVA, C# cannot allow pointer operation.
No comments:
Post a Comment
Comment