0

Most of the modern programming compilers such as JAVA etc does not have the support of pointers. But in golang google introduce pointers again. So, i just want to understand how pointer effects a programming language? is there any kind of security thread because of pointers?

if this is because of security then why we have world's most secured system on LINUX and UNIX(both are build in C)

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Atul Agrawal
  • 1,474
  • 5
  • 22
  • 41

4 Answers4

3

Technically, all languages use pointers. When you create an instance of an object in Java or C# or Javascript and pass it to a method you are actually passing a pointer to the piece of memory that contains that object by which you will manipulate the data on that piece of memory. Imagine a language where you could not pass by reference. You wouldn't be able to do much, now would you? Whenever you pass by reference in any language, you're - in the most basic of terms - using glorified pointers.

What you probably mean, however, is "why expose pointers to people; they are so much more complicated", or something of that sort... And the answer is probably speed and tradition. Some of the fastest languages we have are C and C++... They've been around for a relatively long time. They are tried and true, and people know how to use them. Most software is based off of them in one way or another. Most operating systems are written in C or some variation thereof. Even other programming languages.

As for your Go example, we have already had a question on that..

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103
Jax
  • 402
  • 7
  • 24
2

C/C++ pointer is operational. Example

void f(int* a) {
  a++

Direct operation is danger.

But, Golang pointer is not operational.

So, same name and same mean "pointer".

But, there are difference how to use.

user7358439
  • 121
  • 5
0

Pointers makes call-by-reference easier, but are more vulnerable to breach, because through pointers we can directly access to the memory location, and thus can be a security concern.

Those problems can be defensively coded to prevent but that requires users to be knowledgeable and diligent.

clearlight
  • 12,255
  • 11
  • 57
  • 75
0

The 'modern' comparison of JAVA and C# to C++ is the worst thing a programmer can make. JAVA and C# are managed languages and that means that the memory is not managed by the programmer at all (that is the main function of pointers).C++ is an unmanaged language and that is why C++ is so much faster than any managed language. Almost every modern PC game you will ever see is made using C++ because it runs faster than any managed language.

user7358693
  • 503
  • 2
  • 3
  • don't you think it is also a bad think to have because i am loosing throughput control of my system – Atul Agrawal Dec 31 '16 at 06:47
  • 1
    The thing is that every language has a target. JAVA and C# are better suited for bussiness because development is simplyfied and faster. While C and C++ are better for critical performance softwares like Operational Systems and Games. – user7358693 Dec 31 '16 at 06:51