Home > Java > javaTutorial > body text

Is the biggest advantage of java really that it is cross-platform?

伊谢尔伦
Release: 2016-11-26 13:54:48
Original
1244 people have browsed it

The following discussion is only for PC and mobile terminals.

Is the biggest advantage of Java really that it is cross-platform? It used to be, but not anymore.

It is only the client application that has cross-platform requirements, not the server. For example, for desktop applications, your customers may be Windows users or Linux users. If you don't want to invest more in adapting to each platform, then Java's so-called "Write once, run everywhere" will become extremely brilliant. However, today, the entire software world is leaning towards B/S applications (except embedded). Even if the client is to be cross-platform, third-party frameworks such as QT are far more powerful than Swing. Java has basically been eliminated in the field of desktop applications. It is an indisputable fact, and the Applet that Java was so proud of has long since disappeared. If there is any excellence in client-side Java, it is only Android. Android did initially rely on the JVM to shield the differences between different hardware devices and achieved great success, but today, the emergence of ART mode in Android L is about to overturn this situation, and Google may also want to use its own Go language Replaced Java as the first language of the Android platform. So on the client side, Java is almost completely defeated.

Server-side applications do not need to be cross-platform. When building a web server, I don’t think any company would use Linux today and switch to Windows next month, right? If you just change the Linux distribution, such as from Debian to Fedora, essentially the Linux kernel remains unchanged, so there is no problem with purely compiled languages ​​like C++. If you are building a game server, I think almost everyone will choose Linux instead of Win platform. The practicality of Java's cross-platform advantage has actually been greatly weakened. It can be said that it is not obvious in actual applications. Under normal circumstances, it is almost impossible to perceive that Java can be cross-platform. As one of the three major commercial JVMs, JRockets is a compiler-only JVM, that is, all bytecodes will be compiled into local machine code when the application is started. This actually abandons cross-platform to a large extent and pursues performance.

Today, Java’s biggest advantage is its large and complete ecosystem. Whether a programming language can become popular is mainly determined by its ecosystem. The perfection of the Java ecosystem is mainly reflected in the following aspects:

Java has the largest number of programmers in the world. It doesn't matter if you say they are farmers, but depending on the number, the most obvious effect is that when the company recruits people, it will be easier to recruit Java programmers. Just imagine if you want to make a set of software, and you have a great technical solution that needs to be implemented in languages ​​such as C++, Scala or Ruby, but you can't recruit enough people, then the plan will most likely go to waste. At this time, your application Java can also do it, and you can easily recruit enough people, so you are more likely to choose Java.

Java has a large number of third-party libraries. If you want to parse HTML, you will probably have to write your own parsing algorithm library in languages ​​like C/C++. But if it is Java, you can easily find JSoup on Github, use Maven to import the dependencies and get the HTML done in minutes. . For this reason, there is a saying that satirizes Java: "We don't produce code, we are just Github porters." This sentence makes sense literally, but it ignores the improvement in software production efficiency. of great value. For software development, the company's only cost is actually the "capitation fee". Every reduction in development time by one month can help the company save hundreds of thousands and tens of millions in R&D costs.

Java has a powerful IDE. Eclipse can meet almost any development need you have through plug-ins. Although it is a bit slow, you can improve the smoothness of the program through JVM tuning. Never use the default JVM parameters. However, IntelliJ Idea has completely surpassed Eclipse, and the intelligence of Idea is almost comparable to VS under the Win platform. I'm the kind of person who can't live without Vim, and there are Vim plug-ins in both IDEs to keep me alive happily.

Java has many killer applications. Needless to say, Spring, Struts, Hibernate, Hadoop, Tomcat, JBoss, etc.

Java has very few syntax features. Yes, that's a plus too. C++ adds a lot of features compared to C. Not only is it difficult to learn, but it also reduces the readability of the code when used. In fact, it is a waste of time and effort. In today's world, the requirements for programming languages ​​​​are simple syntax and readable code, and performance is the next best thing. Therefore, programming languages ​​​​such as Python and Ruby were born. Many people criticize Java syntax for being bloated in writing. I admit this, but the fact is that programming languages ​​have never been eliminated because of bloated syntax. What determines their life and death is the ecosystem. For critics, here is a quote from Zhihu: “Dynamic types are great for a while, but code refactoring is a crematorium”

Java’s performance is already high enough. The built-in JIT compiler of Sun/Oracle's HotSpot JVM has made great efforts to optimize the bytecode at runtime. After the server application is started, it will sufficiently "warm up" the JVM and give reasonable startup parameters. That’s it. If it is not a system application that is very sensitive to performance, Java is fast enough. There is a simple and feasible way to visualize this. Add +XX:PrintCompilation to the JVM startup parameters to see how busy the JIT compiler is. In today's world, the demand for software is increasing. When the performance is acceptable, development efficiency is the first priority. This is also the main reason why dynamic scripting languages ​​​​such as Python are popular

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!