Home  >  Article  >  Is it necessary to convert Java to Go language?

Is it necessary to convert Java to Go language?

Guanhui
GuanhuiOriginal
2020-06-04 15:34:577776browse

Is it necessary to convert Java to Go language?

#Is it necessary to convert Java to Go language?

You can decide whether it is necessary to switch to Go language according to the situation. If you are interested in Go language and conditions permit, it is recommended to switch to Go language. Go language is a statically strongly typed, compiled language. It is not only The syntax is simpler than Java, the performance is better than Java, and the compilation speed is faster.

Go

#In terms of concurrency, the goroutine and channel mechanisms provide a lightweight and smooth concurrency mechanism at the language level; in terms of performance, they provide various The performance is weaker than Java (performance is a false proposition), but in terms of memory resource consumption, it has obvious advantages over Java and other dynamic languages; in terms of syntax, it has some of the dynamic language features of Python, in terms of object initialization, construction and sequencing. It provides an extremely concise way of expression in terms of optimization, etc., and these processing codes may account for 10% to 50% of the code, especially for data processing, configuration and protocol mapping scenarios. Compared with C, C, and Java, this aspect is clumsy. This is the key to why dynamic languages ​​are so fascinating.

This is also the key reason why the first version of the Go language attracted so much attention when it was released, especially for dynamic languages, it provides concurrency and performance advantages that dynamic languages ​​do not have, Pike The purpose of designing the Go language is to serve as another optional role for C/C (note that it is not a replacement, and its design goal is not to replace it). Pike, the father of the Go language and chief software engineer at Google, mentioned this in his 2012 "Road to Simplicity" speech. Goal is full of frustrations, and here's a quote: "Although we expected C programmers to see Go as an alternative, instead most Go programmers come from languages ​​like Python and Ruby. Very few come from C." The essence of C's value is: the language provides more Extensive abstraction, elegance and flexibility, and these expressive capabilities are at zero hardware cost. The C language has zero hardware cost as its design goal from the beginning, but the language expressive power is solved by C. The direction of Go's thinking is obviously not Zero cost, at least not zero CPU cost, Go's proposition is more about minimizing the programmer's workload.

One is the ultimate pursuit of zero-cost hardware, and the other is to minimize the programmer's workload. No one can replace anyone's most valuable part. Go cannot meet both goals at the same time. It chooses dynamic syntax and gc is destined to choose development efficiency and sacrifice hardware efficiency for development efficiency, so it goes in another direction, which is the application direction that Java is good at, especially the current network and HTTP applications, which requires good Standard library and ecosystem support. In terms of standard library, Go has provided a more lightweight and excellent code library for processing tcp/http/xml/json/encryption and decryption, etc., as well as high concurrency support for http, the core protocol of the network. It has been provided with a stepping stone to leveraging Java.

But we must face its current shortcomings. It is far from mature in terms of important language features and rigor, and there are still many faults or temporary solutions, which will also affect the maturity of its ecology. However, these problems still need to be solved in the new version. The first version of the Go language was officially released on March 28, 2012. Up to now, version 1.7 has been released. Two major versions have been released in almost a year, with several beta and RC versions released in between. This basically shows that the Go language is not yet complete. get ready.

Summary

Go has proven to be an ideal candidate for Python and Ruby in terms of dynamic language performance requirements; in terms of application development, especially HTTP-related applications, it is currently at the forefront. A challenger in front of Java, it also provides another role besides C/C in places where the control over resources is not so strong.

In terms of productivity, its language features and ecosystem are not yet mature, and the version is still being rapidly iterated. Compared with dynamic languages ​​and Java, it does not have any advantages. At this stage, these languages ​​​​are limited in certain scenarios. Optional roles. In the long run, with the full support of Google, new features and library application capabilities will continue to be added. It is a thriving programming language. However, at this stage, it is recommended that the scale and complexity of the program must be controlled. The language and ecology have not yet been fully developed. To provide sound support, we must also be aware of the risks caused by its immaturity and rapid version iteration.

Java

Java's success was due to the strong support of large companies such as SUN, IBM, and Oracle, which were mainly based on Unix systems 10 years ago, which allowed it to gain a firm foothold in the field of enterprise applications and WEB applications, and in the subsequent 10 years In the first half of the year, it relied on the revolution brought by x86 Linux to maintain its share. In the second half, it was the success of android that allowed it to reach the top again after faltering and stopping. In the past two decades, Java has accumulated the most powerful ecosystem. You can say that it is all-encompassing. There is no doubt that Java has long been a huge body of an aircraft carrier, which is enough to prove its status and success. However, the complexity of its language, libraries, frameworks and ecosystems creates huge obstacles for technicians, such as concurrency, the synchronized mechanism of the language, the standard library's notify and then concurrent, and HTTP can also be obtained through the Apache tomcat container. Based on JVM technology, Java has good interoperability with other languages, such as Scala in terms of concurrency. You can choose its Actor or Akka, which is also written in Scala. Of course, there are more mashup scenarios in the industry choosing nginx, etc. Too much...

This is the world of Java. There is never too much, and there is no need to reinvent the wheel. This is the key to the success of Java. It has been precipitated by history, allowing Java to provide too many options, and it is in-depth. Later, I learned that the learning cost of Java is higher than that of C, and the requirements for programmers are higher than C. Unless you are left behind and are still using Java technology 7 or even 10 years ago, technicians must organize the framework and design very carefully. Otherwise, the result of various reuses is to pile up an extremely bloated program, and its consumption of resources during runtime can sometimes scare you. This is the key to the widespread criticism of too many platforms developed based on Java. Reuse is a double-edged sword. It needs to be tailored rather than one-size-fits-all. The scale required by developers is undoubtedly the most demanding, unless the language and standard library provide the best and most direct options.

Recommended tutorials: "Go Tutorial" "Java Tutorial"

The above is the detailed content of Is it necessary to convert Java to Go language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn