The idea and experience of Java programming

Source: Internet
Author: User

What I was able to find at the C + + committee meeting was the smartest group of people in the C + + community who were in the crowd, answering questions for me. I quickly realized that this was a good way to go beyond what I had earned in any postgraduate course. This is a financially cost-effective business, given the opportunity cost of graduate students.

I was deeply attracted and insisted on attending for about 8 years. After I left, the Committee continued, though the standards had not yet been finalized, but Java had emerged, and a number of other (language) drafts had been introduced (the problem of technology-stimulating addicts-I did delve into a language, But I've been looking for more productive means: the language features that look bright in the foreground can distract me effortlessly.

Every time we meet, I throw out a list of the tricky issues I've accumulated about C + +. Usually I will ask them to clarify in a few days. The most valuable thing that the Committee can see is this, and of course, the early exposure to new features that are about to be announced.

In the long run, it is a profound knowledge to add linguistic features into the mystery of C + + and observe it. Now judge is a very simple thing, say what C + + sucks, design too bad and so on. When there is no understanding of the constraints on C + + design, many people blurt it out. Stroustrup (51CTO Editor's note: This Stroustrup is to invite the author to participate in the Stroustrup, that is, the C + + language designer Stroustrup) constraints are, C program should be slightly changed, or best not to make changes, can be compiled under C + +. and whether or not this is completely logical, it gives C programmers a good evolutionary path. But there is a big limitation, and it is necessary to virtualize every difficult trait that everyone complains about. Because these features are difficult to understand, many people have come to the conclusion that C + + design is bad, and this is far from true.

In language design, Java treats this understanding with an arrogant attitude. I've written about this in the Java programming mind and many of my blog posts. So my longtime followers know that because of the negative attitude of C + + by Gosling (the father of the Java language) and the Java language Designer, Java began to twist me in the wrong direction. To tell you the truth, my first "encounter" with Gosling was a bad impression-it was years ago, when I first started using Unix (Fluke, the production of electronic test equipment), the first time I entered the company. A software engineer tutored me and taught me to use Emacs. But the only tool in the company was the commercial version of Gosling Emacs (unipress). If you do something wrong, the program will insult you, call you a turkey, and fill the screen with rubbish. This kind of thing appeared on a commercial product, and our company spent quite a sum of money. Needless to say, when GNU Emacs became stable, the company immediately switched to GNU Emacs (I've seen Richard Stallman. Of course, he's a crazy guy. But he is also very smart: he knows that when you get into trouble, you need help, not insult. (51CTO Editor's note: Richard Stallman, a developer of GNU Emacs, is a hacker in the United States.) He spent 05 years in Sina, with the peak of the road to talk about hacking training. )

I don't know the extent to which this formative experience of Gosling's impressions has influenced the way I think about his work, but in fact, "we see it sucks and we decide to come up with our own language," which is not helpful for C + +. Especially when I began to make it clear in the course of writing Java programming ideas, and repeatedly found that the language features and libraries that were hastily decided had to be revised-indeed, most of them would have to be revised, and some revisions had been made after the programmers had endured them for years. On many occasions, Gosling frankly they have to gallop, or they will be overtaken by the Internet revolution.

I find it helpful to understand why language features exist. If it is up to the university professors to come clean and put them in front of you, you are bound to conceive a myth of the language, saying, "There must be some really important reasons why this language feature exists, and these reasons are only understood by the wise man who created the language, and I cannot understand it, I trust it." In a way, the belief-based acceptance of language characteristics is a burden; it prevents you from analyzing and understanding what is happening. In my keynote speech (Bruce will be taking part in a keynote speech over the next few days), I will look at some features and examine how they are implemented in different languages and why they are implemented.

Here's an example. Object creation. In C, when a variable is declared, the compiler creates a stack space for you (uninitialized, unless you initialize it, it will have junk data). But if you want to do this dynamically, you'll have to use the two standard library functions of malloc () and free (), and be careful to perform all initialization and cleanup tasks manually. If you forget, there will be a memory leak and other similar disasters, which is often the case.

About dynamic object creation: In general, the compiler divides memory into three parts: static storage area, stack, heap. The static storage area mainly holds the global variable and the static variable, the stack stores calls the function related variable, the address and so on, the heap stores the dynamically generated variable, in C refers to by the Malloc,free operation produces the freed storage space, in C + + refers to the new and delete operator the storage area. (Source: 51CTO Tree Hole Technology blog)

Because malloc () and free () are "just" library functions, the knowledge that should be relevant in the basic programming class is often not imparted, which is puzzling and frightening. When programmers need to allocate a large amount of memory space, they do not learn how to use these functions for processing, instead of allocating a large array of global variables (not joking), the size of the array, far more than they ever thought the space needed. The program seems to be working, and again, it seems like no one will ever use a cross-border-so when it does happen years later, the program is interrupted,and some poor guy has to go in and find out where the mistake is.
http://www.lwinfo.com/uzt/list1/222612.html
http://www.lwinfo.com/uzt/list1/222611.html
http://www.lwinfo.com/uzt/list1/222610.html
http://www.lwinfo.com/uzt/list1/222609.html
http://www.lwinfo.com/uzt/list1/222608.html
http://www.lwinfo.com/uzt/list1/222607.html
http://www.lwinfo.com/uzt/list1/222606.html
http://www.lwinfo.com/uzt/list1/222605.html
http://www.lwinfo.com/uzt/list1/222604.html
http://www.lwinfo.com/uzt/list1/222603.html
http://www.lwinfo.com/uzt/list1/222602.html
http://www.lwinfo.com/uzt/list1/222601.html
http://www.lwinfo.com/uzt/list1/222600.html
http://www.lwinfo.com/uzt/list1/222599.html
http://www.lwinfo.com/uzt/list1/222598.html
http://www.lwinfo.com/uzt/list1/222597.html
http://www.lwinfo.com/uzt/list1/222596.html
http://www.lwinfo.com/uzt/list1/222595.html
http://www.lwinfo.com/uzt/list1/222594.html
http://www.lwinfo.com/uzt/list1/222593.html
http://health.people.com.cn/xywy/wfyxb/tp/8637777212.html
http://health.people.com.cn/xywy/wfyxb/tp/8637755008.html
http://health.people.com.cn/xywy/wfyxb/tp/8637734533.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8637711235.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637698547.html
http://health.people.com.cn/xywy/wfyxb/tp/8637683347.html
http://health.people.com.cn/xywy/wfyxb/tp/8637671793.html
http://health.people.com.cn/xywy/wfyxb/tp/8637655581.html
http://health.people.com.cn/xywy/wfyxb/tp/8637636943.html
http://health.people.com.cn/xywy/wfyxb/tp/8637607563.html
http://health.people.com.cn/xywy/wfyxb/tp/8637592158.html
http://health.people.com.cn/xywy/wfyxb/tp/8637580086.html
http://health.people.com.cn/xywy/wfyxb/npxpf/8637564379.html
http://health.people.com.cn/xywy/wfyxb/npxpf/8637550714.html
http://health.people.com.cn/xywy/wfyxb/npxpf/8637536743.html
http://health.people.com.cn/xywy/wfyxb/npxpf/8637522505.html
http://health.people.com.cn/xywy/wfyxb/wfyxb/8637507933.html
http://health.people.com.cn/xywy/wfyxb/wfyxb/8637490238.html
http://health.people.com.cn/xywy/wfyxb/wfyxb/8637470266.html
http://health.people.com.cn/xywy/wfyxb/wfyxb/8637394856.html
http://health.people.com.cn/xywy/wfyxb/wfyxb/8637376613.html
http://health.people.com.cn/xywy/wfyxb/wfyxb/8637359793.html
http://health.people.com.cn/xywy/wfyxb/wfyxb/8637339558.html
http://health.people.com.cn/xywy/wfyxb/zl/8637310288.html
http://health.people.com.cn/xywy/wfyxb/zl/8637295257.html
http://health.people.com.cn/xywy/wfyxb/zl/8637284454.html
http://health.people.com.cn/xywy/wfyxb/zl/8637268787.html
http://health.people.com.cn/xywy/wfyxb/zl/8637248572.html
http://health.people.com.cn/xywy/wfyxb/zl/8637232687.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637216226.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637186048.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637166433.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637154697.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637139081.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637120805.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637105248.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637073843.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637054696.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637043072.html
http://health.people.com.cn/xywy/wfyxb/kfal/8637025353.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8637010257.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636994418.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636976214.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636958698.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636941657.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636929048.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636900056.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636890097.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636875798.html
http://health.people.com.cn/xywy/wfyxb/yyxw/8636848393.html
http://user.qzone.qq.com/2900841152
http://t.qq.com/changchuny7026


Stroustrup that dynamic allocation needs to be simpler and more secure--this piece has to be placed in the core of the language rather than relegated to a library function. You must also work together with initialization and cleanup, and initialization and cleanup must be provided separately by constructors and destructors to provide the same assurance for all objects.

This issue is a milestone that affects all C + + decisions: backwards compatibility with C. Ideally, the stack (heap) Allocation of an object can only be ignored. However, the compatibility of C requires a stack allocation, so the heap object and the stack object must be differentiated. In order to solve this problem, C + + embezzled the new keyword from Smalltalk. To create a stack object, just declare it, like this: Cat X, or in the case of a parameter, cat X ("mittens");. When you create a heap object, you use new, like this: new Cat x; or new Cat x ("mittens");. With this constraint, we get an elegant and consistent solution.

Java has been created since everything in C + + has been judged to be poorly and overly complex. Ironically, Java decided to discard the stack completely (especially ignoring the failure of the basic type, which I have already pointed out elsewhere). That's nice, since all objects are allocated on the heap, it is not necessary to differentiate between stack and heap allocations. They can easily say cat x = Cat () or cat x = Cat ("Mittens"). Or even better, using union type references to eliminate duplication (but that-and other features like closures (closure)-are "too long". So we can not do without Java's ordinary version, type deduction has been discussed, but I bet that it will not happen, nor should it happen. Because it adds a feature to Java while causing problems).

Guido Van Rossum (the creator of Python) adopted a minimalist approach--the use of often-denounced blanks, which illustrates his quest for language simplicity. Since the new keyword is no longer necessary, he saves it, like this: x = Cat ("mittens"). Ruby may also use this method, but one of Ruby's main constraints is to follow Smalltalk as much as possible, so in Ruby it is this: x = cat.new ("mittens"). But Java has a way of belittling C + + as a guideline, so that using the keyword new is a mystery. After studying the language's decisions elsewhere, my guess is, do they never realize that this is a dispensable thing at all?

So that's what I mean by the language archaeology. I hope that people can look at language design with a better perspective and have more critical thinking processes when learning a programming language.

The idea and experience of Java programming

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.