Written in Java for a month later

Source: Internet
Author: User

LearningProgramming LanguageIt is to learn programming ideas, so we should try to learn a language that is very different from the ones we are familiar with, in order to expand our thinking. Java and C ++ look too similar, so they have no interest in learning it until they are used at work. I spent a month talking about the following points:

1) Lengthy

As long as there is a good ide, writeCodeNot too tired, it is a little effort to read the code. I used the Java getting started book "Java programming ideas". I always felt that the code in the book was too long and it was very tiring to extract useful information. So I mainly read the text and seldom read the code. This is half because of Java's lengthy nature, and half because of the common problem of many programming books-too much waste of code.

2) Security

Exception MechanismProgramPersonnel are more willing to handle exceptions, which is suitable for scenarios where input is not clear.

Type security allows programmers to focus more on the program itself, instead of learning something extra to ensure type security-for example, in C, C ++, the following code embeds bugs:

 
If(Cppisbest =True) {Javaisbest=False;}

In C, cppisbest can also be of the int type (in C ++, we cannot determine what the strange type is). in Java, the above Code is correct, it's just that the perception is easy to cause the embarrassment of C programmers ......

Then there is memory security. All Java objects are created on the heap. Of course, GC is installed. You can rest assured that new is the first thing to do. Now I am used to it ......

By the way, we can refer to objective-C, which is currently very popular. Apple has been reluctant to enable objc to support GC on iOS (in fact, the iPhone can support GC when it is a little thicker), allowing programmers to manually manage the cited technology. Now we have an arc to allow clang to automatically manage the reference count. This shows that the previous manual management method is cumbersome and meaningless.

3) No local static variables

I don't understand Why JAVA designers do not support this feature. The consequence is that all the static variables that are supposed to appear in the function are in the class, this can cause unnecessary name pollution and seriously reduce code readability.

4) The Lambda expression is missing.

Compared with other mainstream languages, Java does not have sufficient abstract capabilities and does not have build-in Lambda. The closure structure can only be implemented through internal classes-this is not intuitive enough and there is another problem ......

5) generic?

When I was writing Java code, I tried implementing Lambda through closures and generics to better abstract and reduce duplication. The result shows that the file cannot be compiled, and the template parameters will only be considered as the object type ...... For this reason, I wrote another interface to dispel the idea of generics. The code written in this way is not intuitive enough, and the name is contaminated.

Finally, learning JAVA does not bring many new programming ideas ......

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.