Skip to main content
added 46 characters in body
Source Link

Having a pointer definitely consumes some overhead, but you can see the upside too.Pointer is like index. In C you can use complex data structures like string and structures due to pointers only.

In fact suppose you want to pass a variable by reference then its easy to maintain a pointer rather than replicating the whole structure and synchronizing changes between them(even for copying them you will need pointer ). How would you deal with non contiguous memory allocations and de-allocations without pointer ?

Even your normal variables have an entry in symbol table that stores address where your variable is pointing towards. So, I don't think it creates much overhead in terms of memory(just 4 or 8 bytes) . Even languages like java use pointers internally(reference), they just don't let you to manipulate them as it will make JVM less secure.

You should use pointers only when you have no other choice like missing data-types, structures(in c) as using pointers may be lead to errors if not handled properly and are comparatively harder to debug.

Having a pointer definitely consumes some overhead, but you can see the upside too.Pointer is like index. In C you can use complex data structures like string and structures due to pointers only.

In fact suppose you want to pass a variable by reference then its easy to maintain a pointer rather than replicating the whole structure and synchronizing changes between them. How would you deal with non contiguous memory allocations and de-allocations without pointer ?

Even your normal variables have an entry in symbol table that stores address where your variable is pointing towards. So, I don't think it creates much overhead in terms of memory(just 4 or 8 bytes) . Even languages like java use pointers internally(reference), they just don't let you to manipulate them as it will make JVM less secure.

You should use pointers only when you have no other choice like missing data-types, structures(in c) as using pointers may be lead to errors if not handled properly and are comparatively harder to debug.

Having a pointer definitely consumes some overhead, but you can see the upside too.Pointer is like index. In C you can use complex data structures like string and structures due to pointers only.

In fact suppose you want to pass a variable by reference then its easy to maintain a pointer rather than replicating the whole structure and synchronizing changes between them(even for copying them you will need pointer ). How would you deal with non contiguous memory allocations and de-allocations without pointer ?

Even your normal variables have an entry in symbol table that stores address where your variable is pointing towards. So, I don't think it creates much overhead in terms of memory(just 4 or 8 bytes) . Even languages like java use pointers internally(reference), they just don't let you to manipulate them as it will make JVM less secure.

You should use pointers only when you have no other choice like missing data-types, structures(in c) as using pointers may be lead to errors if not handled properly and are comparatively harder to debug.

Source Link

Having a pointer definitely consumes some overhead, but you can see the upside too.Pointer is like index. In C you can use complex data structures like string and structures due to pointers only.

In fact suppose you want to pass a variable by reference then its easy to maintain a pointer rather than replicating the whole structure and synchronizing changes between them. How would you deal with non contiguous memory allocations and de-allocations without pointer ?

Even your normal variables have an entry in symbol table that stores address where your variable is pointing towards. So, I don't think it creates much overhead in terms of memory(just 4 or 8 bytes) . Even languages like java use pointers internally(reference), they just don't let you to manipulate them as it will make JVM less secure.

You should use pointers only when you have no other choice like missing data-types, structures(in c) as using pointers may be lead to errors if not handled properly and are comparatively harder to debug.