Image source: Photo by Flickr user Tsutomu Takasu Looking back at the entire history of computer development, 1995 was a crazy year: Java was born in that year, followed by JavaScript. Although the latter contains the word "java", it is actually not related to Java. Java is a static programming language that needs to be compiled; while JavaScript is just a simple interpreted scripting language and is a dynamic language. If you have experienced the early development of Java, it is not difficult to forget its unprecedented peak: overwhelming promotion and super-large JavaOne conference. Many people believe that this new programming language will dominate the computer field at all costs. Then this prediction turned out to be only partially accurate. Today, Java still maintains its dominance in Android applications, enterprise-level server applications, and embedded spaces like Blu-ray discs. Although Java has a very wide range of implementation areas, desktop applications and browser programming have always been its weaknesses. The HTML-based applets created by Java and the Java-based development tools are highly recommended by developers. But complex scenarios or actual needs often break this inherent combination. Fortunately, early server-side development has become a field where Java is proud. At the same time, JavaScript, which was previously misunderstood by many programmers as Java's good sister, also began to show its prowess in its own field. It must be admitted that there was a period of time when HTML and the Web were developing vigorously, and JavaScript was like a little Borg, drifting with the flow. But the emergence of AJAX completely changed this situation. Then, Node.js came out of nowhere and attracted many developers in the industry. Compared with Java or other programming languages, the JavaScript-based Node.js platform performs better on the server side - faster! Faster! With the dynamic development of the Web side, Node.js can meet the requirements of data request times and response speed. Twenty years ago, these were unimaginable. Now, what awaits the two J brothers is a tough battle, and the winner will determine who will take the top spot in the programming world. On one side is the static programming language with a solid foundation in engineering applications and architecture; on the other side is the more lightweight and simplified dynamic programming language. Will the old-school compiled language Java hold its ground? Will the fast and flexible Node.js clear all obstacles on the road to JS hegemony? Java's advantages: rock-solid application foundation When I mention this, I seem to hear the developers' devilish laughter. Yes, Java has some minor flaws and bugs, but relatively speaking, it is definitely the Rock of Gibraltar in the programming world (haha, you can hear my praise for it). If Node.js wants to reach this level, it will probably take a few more years. Not only that, in fact, the order of magnitude of regression testing that Sun did when developing the Java virtual machine, JavaScript can't reach this level without decades. If you start a Java virtual machine, then congratulations, you have gained the experience of a senior manager who controls the enterprise version of the server for 20 years! If you resolutely decide to use JavaScript, this will mean that you may encounter a bad-tempered and difficult to get along with work partner: this guy can get along with you sometimes; sometimes he will take out his own set of human principles (JS standards) and launch passive-aggressive attacks on you. Node's advantage: Ubiquitous applicability It is precisely because of the emergence of Node.js that JS finally found its place in the network service platform. Node uses asynchronous programming to achieve the effect of handling concurrent events. Although its reliability needs to be improved, its performance in the industry is already quite good. In traditional web programming, Java implements backend services and JS completes frontend functions; Node.js allows JS to easily handle both the client and the server, especially when we want to migrate the logic layer from the server to the browser level, Node is simply shining. Or the hypocritical boss wants us to move the logic layer back to the server, over and over again, no matter how it is played, Node.js makes code migration easier. Where Java wins: Better IDEs Eclipse, NetBeans and IntelliJ integrate debugging, compilation and services. These are the three top IDEs recognized by Java developers. They have been developing to this day, focusing on user experience and have solid related supporting plug-ins. Node.js developers can write code on the command line or use a text editor. Some people also choose Eclipse and Visual Studio, both of which support node development. The wave of Node.js around the world is bound to breed some new tools and resources. For example, Node-Red developed by the IBM team allows users to write applications by combining various components. However, this new open source IDE still has a long way to go to reach the level of Eclipse. Another example is the front-end development artifact WebStorm, which is a JS development tool under Jetbrains that supports multi-command line development. Of course, these new lightweight tools are more than enough for code editing and simple development. However, if you want the IDE to give developers more guidance when executing source code (just like a doctor holding a scalpel in a chest surgery wants more assistance), the powerful Java development platform can directly kill those idiots - the ubiquitous Java! Where Node wins: Simplifying the process Complex software building tools such as Ant and Maven have brought significant changes to Java programming. However, there is always a problem. For example, the code written by developers in XML is not supported by other compilation environments. It is true that nested tags can be used to display branches, but the annoying conversion problem between Java and XML is still difficult to solve. Java: Remote Debugging Java has always been proud of its ability to remotely monitor server cluster performance. Some features of the JVM itself, coupled with the assistance of performance testing tools, allow programs to easily detect server bottlenecks and failures. The Java stack enterprise version can run extremely complex and cutting-edge servers, and companies using these servers can get the best user experience during telemetry. The monitoring and debugging functions mentioned above have developed to a very mature level, and we will benefit greatly from them when deploying services. Node.JS: Direct access to the database New databases like CouchDB can be accessed directly by writing JS scripts. Node.js and CouchDB statements can be used together without conversion issues, and headaches about syntax differences can be left behind. Similarly, many Java program developers also need to write some SQL statements at work. At this time, they need to use a database written in Java (such as Derby). If you think everything is fine at this step, then I can only say: you think too much! The SQL statements written by the developer need to be further parsed by Derby before they can be loaded into the Java program for compilation and execution. Therefore, Java is indeed a good language, but its syntax cannot be converted to SQL, which leads to the need for a clear division of labor in the development team: you write Java, I write SQL. Java: A rich library Javat provides a huge set of toolkits, which play an extremely important role in daily development. For example, the full-text search engine Lucene and the computer vision library OpenCV are the two most typical open source projects, and they play a mainstay role in some important basic projects. At present, there are also some open source shared tool libraries developed in javascript, which also have eye-catching functions and methods, but compared with Java, a mature resource library, Java wins in this aspect. Node: JSON When the database returns the result, the Java program converts it into Java objects. In this stage, developers will use mapping frameworks such as POLP or Hibernate to process the data, and the configuration and conversion process is very time-consuming. Finally, the Java program will accept these Java objects. In fact, most web servers and databases return data in the form of JSON (a data exchange format that comes with JS). This data format is widely used in Java development, so the problem is obvious. Developers need to use many JSON parsers or library functions to reprocess the data. JSON is a native format of JavaScript, which means that processing JSON data in JS does not require any special API or toolkit, and users can use it directly. Java: A solid engine How many complex component development kits are based on Java's powerful mathematical function library? One hundred, ten thousand, this is already difficult to quantify. Sun spent a lot of time and manpower to develop this set of practical tool classes for Java. Now widely used are big number processing BigIntegre, sophisticated IO library, and open source time/time library based on Gregorian and Julian. JavaScript performs well in handling simple tasks, but its implementation mechanism is confusing. A common example is that when a function method defined in JavaScript returns "nothing", it can be expressed in three ways: undefined, NaN, and null. So which result is correct? In fact, these three are data types of the JS language, which are used to ensure the rigor and logic of the program. At first glance, this weird syntax generally does not go wrong during program operation, but compared with those high-end library functions in Java, it is immediately crushed. Node.JS: Speed Node.js is fast, and most people who use it say it's great. Data is sent and received at lightning speed. It doesn't blindly set up a single thread with the risk of deadlock, nor does it have internal self-checking that might slow down execution. In short, node is already executing your code as soon as you type. Of course, this advantage has hidden dangers. Try to write simple code so that Node.js can ensure that everything goes smoothly. Once a complex code is deadlocked, the entire service will crash. It can be understood that the system self-protection mechanism that operating system developers have worked hard to build can tolerate some program errors. But Node.js completely despises this protection network. This is also what node deserves. Java: Multithreading Fast execution is good, but strong and well-written code is even better. In this round, Java wins hands down. The web server developed by Java framework is multi-threaded. Even though multi-threading takes up a lot of time and memory, this internal consumption is worth it. Because if one thread deadlocks, at least there are other threads to carry it; even if one thread needs to occupy the CPU for a long time, at least other threads will not be hungry and wait. If the above situation is put into Node.js, the result will be terrible: if one thread slows down, everything slows down. Therefore, Node.js is only suitable for single threads. Countless programmers have shed sweat and tears and spent decades of hard work to build an intelligent operating system that handles concurrent events. However, Node has failed to keep up with the times and has regressed to the single-threaded approach of the 1960s. Node: Battery life Our ancestors taught us: thrift is a virtue, and we should be good children who do not waste or ask for anything. Seeing those idiots in Silicon Valley interpreting "innovation" and "subversion" with their own behavior, we are really heartbroken. But looking back and thinking calmly, it is of great significance to get rid of the dross. Java is still as good as ever, and the old Java codes written by our ancestors are everywhere. It is true that Java is also tirelessly providing new IO interfaces, but what will happen to those old interfaces that are out of touch with the times? Small applications and basic utility classes will also face this choice. A win-win situation? Hybrid programming The debate on whether the server should be named J or JS will continue for a long time. There is a middle way to avoid these endless debates - mixed programming of Java and JS, converting Java classes into JS compatible with browsers. The GWT framework does this very beautifully, and many well-known websites have adopted this method. Hey, there is actually another way to go: open source implementations of JS written in Java, such as Rhino, where programmers can directly embed Java code into them. If you are good enough, you can also tinker with this on the currently popular Google V8 engine. In short, don’t fight and kill, harmonious coexistence is the kingly way! |
<<: Uncovering the technical principles of the "Star Wars" robot BB-8
>>: 9 to 5? The daily life of a CTO is not what you think
"The Wandering Earth 2" once again made...
This article will give you a clear answer once an...
Figure robot (Source: Figure) In the predictions ...
Generally speaking, there are three main purposes...
Mixed Knowledge Specially designed to cure confus...
In the cold winter of the Internet, many friends ...
Yesterday, after the road test spy photos of Chan...
February 14th is a special day for lovers all ove...
Before we start discussing topics related to &quo...
I guess everyone has noticed that regardless of e...
I guess only blockchain conferences can be this p...
Beijing Time October 31, 2023 at 8:11 The return ...
I saw a short video some time ago: watching horro...
As an important part of native advertising, infor...
Internet practitioners are certainly familiar wit...