is a "pointer" a concept that a mature programming language must have?

Source: Internet
Author: User
Tags java reference

https://segmentfault.com/q/1010000003797714

I'm looking at a book written by a Japanese, "conquering the C-pointer," and the quote in the book mentions such a word.

Indeed, the "C-pointer" has a low-level and evil side, but it is also an indispensable concept of "data structures" such as the construction of lists and trees. Without pointers, we couldn't do a decent application. Therefore, any truly mature development language, there must be pointers, such as Pascal, Delphi, Lisp and Smalltalk, and so on, even visual Basic has pointers. Early Perl was criticized for not having pointers, and the concept of pointers was introduced starting with version 5. Of course, Java also has pointers. Unfortunately, there seems to be a deep-rooted misunderstanding of this.

In this book, we will experience how pointers are really used to construct data structures.

A "pointer" is a concept that a mature programming language must have.

I haven't learned any of the languages mentioned above, but according to the Javascript,python and Ruby I've learned, they don't have pointers, what's going on? Is the author wrong, or do I understand that there is a problem?

指针The intention is to save the address of another variable in one variable to provide the ability to quantify the "address" . Without pointers, you cannot refer to another variable with one variable (you can only copy one copy of the value of the variable to another variable).

C语言Provides a complete pointer operation, including assigning values to pointers, allocating memory ( malloc ), taking variable addresses, allowing pointers to participate in operations, and so on, which allows the C programmer to manipulate free memory arbitrarily.

JavaJavascriptthere are pointers in (), except that there are C Java strict restrictions on the use of pointers to programmers, only the assignment operation is allowed, and not any value, only the value of the new object reference or other reference variable that was created. In general, however, instead of pointing Java pointers, 引用 you use ( reference ) to call pointers to objects, but Java you can still find some shadow in the presence of pointers, for example, when an object is null called, calling a method causes an null pointer exception, the 空指针错误 so-called , it Java is true that the internal use is a pointer.

Many basic data structures, such as linked lists, trees, graphs, and so on, must use pointers to store the addresses of precursors or successors, otherwise these data structures cannot be implemented.

If a language does not provide pointers, although in theory it also has full computational power, many of the very simple problems in other languages will become extremely complex (for example, but for the moment, but the conclusion must be correct).

So the author is right, but you need to understand the nature of the pointer, and do not mistakenly think that the concept of a 只有像C语言那样的指针才叫指针 real pointer, please look at my beginning of the sentence.

I've never read the author's book, but there's a difference between a reference and a pointer in Java that doesn't manipulate memory directly.
the individual understands the existence of pointers in order to gain the efficiency of the runtime and the ability to access the underlying , but it is also important to develop the ability to solve specific problems in a mature programming language that is not necessarily a feature of today.

First, pointers to C are fundamentally different from pointers in other languages. C language pointers are arbitrary assignments, arbitrary dereference pointers, other languages are castrated, it is difficult to freely use

Second, theC language pointer is used to manipulate the underlying , in fact it is a language between the high and the assembly between the characteristics. Personally, C + + pointers are purely for C-compatible reservations and are not advocated in the C++11 programming specification.

You certainly did not have the single-chip microcomputer, on the monolithic computer I wanted to use the assembly ... (especially in cases where logic is not complex)
C's pointer is a "low-level operability" of a compromise , as for other children's shoes said the "address" the ability to quantify "that is not the C-narrow" pointer ", after all, the reference is not casually in memory address space on the blind JB moved (for the single-chip computer and hardware to deal with more platforms, That's a good thing, but if you focus on higher-level logic, it's bad, because your attention is often drawn to the pit-daddy stuff like a wild pointer, memory leak, etc.
So, if you have the right tools (such as Java Reference +gc,c++11 Smart pointers) and do not need to deal with the hardware directly in the scene, or try not to use pointers better

is a "pointer" a concept that a mature programming language must have?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.