Translation | JavaScript beyond browser restrictions


Translator: An Dong (web front end development engineer of Hujiang)
Please indicate the author and source of this article.
Original address:…

The technological world is developing, and JavaScript is also developing at the same time. In its first few years in the software world, JavaScript never wanted to get involved in services applications, mobile applications and robotics. Today, with the development of JavaScript, the language has entered the new fields of chat robots, virtual reality and the Internet of things.

In addition to constantly exploring new areas, JavaScript has become more and more stable in the ecosystem of server-side, mobile terminal and desktop application. In this article, we will first review some of the predictions made last year, and then look at what new sites JavaScript will explore outside browsers in 2017. Let’s take a look at JavaScript in server-side applications.


Node.js It is an open source runtime library for building server-side applications. This kind of JavaScript code does not run in a browser. In the past few years, node has evolved from a popular technology framework among start-ups to the mainstream development technology used by companies of all sizes.

Node’s package management tool NPM is no longer a tool for hosting server-side application modules, but a standardized tool for distributing JavaScript code. Perhaps the number of packets on NPM can best show the development trend of node. In last year’s forecast, we made the following chart to compare the data of package management in various languages, showing the advantages of NPM.

As of December 2015, Number of modules

In the past year, the growth of NPM shows no signs of slowing down. In fact, the number of NPM packets increased from 200000 to about 350000, forcing the entire Y-axis scale to be adjusted.

As of December 2016, Number of packages counted

There are many factors behind the growth, one of which is that many companies use node in basic services. This is in line with our forecast last year.

“In 2016, we can expect more companies to adopt node and its package management tool NPM further. Because of the long-term support plan of node, Microsoft, IBM, Intel, progress and other large companies will continue to use node to replace some traditional enterprise solutions such as. Net and Java. “

From the growth trend of node, the above prediction results are not unexpected. The case study on node shows that a number of medium-sized companies have started to use node, including Netflix, GoDaddy and capital one.

Node has been used in key infrastructure, and NASA is the most eye-catching. You can also take a look at NASA’s research on node, and I’ll just excerpt a few words here.

“When considering the safety of astronauts, a slight hiccup or service interruption can lead to life and death accidents. From EVA data to astronauts in space, Node.js It helps to ensure the safety of all people and things. “

But NASA is not the only one to help with node development. Node’s package management tool NPM has become the best choice for storing cross environment JavaScript code. The unification of package management tools also promotes the development of node.

In this article, each framework and technology we discuss uses NPM to store and distribute its source code. Search for “jQuery”, “polymer”, “react”, “Cordova” or “native script” in NPM, and you can roughly understand the scale of NPM. With the popularity of JavaScript, NPM is becoming more and more popular. The more popular NPM is, Node.js The faster the development. We believe that this trend will continue for some time.

stay The search for “angular” yielded nearly 10000 results. Angular is one of the many class libraries distributed through NPM.

In 2017, we believe that more companies will switch from traditional development methods (such as Java and C ා) to node. We believe typescript will also help drive node’s growth, as it is more friendly to Java and C ා developers. Node’s commitment to support lts versions will also help this trend, as it ensures that the versions used by these companies will be continuously supported and maintained in the coming years.

Generally speaking, large companies don’t like to maintain multiple development systems and languages. With node, these companies can integrate all development systems in a single language, not just server-side code. Let’s take a look at how JavaScript affects the mobile end.

Phonegap and Cordova

Phonegap and Cordova, its cornerstone, are the first attempt of JavaScript to enter the field of native development. Cordova encapsulates the web code in WebView, and uses WebView to drive native mobile applications. This approach allows web developers to use the skills they already have, namely JavaScript, to develop mobile applications, and because of this, Cordova has been an important choice for mobile applications for many years.

But that’s starting to change. Today, Cordova faces the challenge of many alternatives, most of which use JavaScript based solutions similar to Cordova. Perhaps Cordova’s biggest challenge is Google’s dominant progressive web apps (PWAs).

Google’s progressive web apps home page

PWAs brings a lot of similar native functions to the web world, such as push notification, offline access and home screen icon. Last year, we predicted that Google would slowly implement PWA. It turns out that this prediction is still too conservative because Google has made it clear that they will launch a variety of activities to promote PWAs. At the recent chrome developer summit and this year’s Google I / O conference, Google arranged a lot of discussions for PWAs.

PWAs is closely related to our discussion, as it has begun to encroach on Cordova’s domain – Web applications that require native functionality. If your web application needs offline access or push notification, it’s better to choose PWA instead of Cordova. While it’s hard to measure how many people choose PWAs in hybrid applications, there is already a lot of evidence that Cordova usage is shrinking. Here’s how many times a week Cordova has been downloaded in the last two years. As you can see, although the number of Cordova downloads has not fluctuated significantly, the increase is not so obvious.

Weekly downloads of “Cordova” NPM packages from December 2014 to December 2016. (data from NPM- )

There is another reason for the recession. Although we believe that PWA is eating away at Cordova’s share, we also believe that newer development methods in the mobile world are also eating into Cordova’s share.

Native mobile apps

JavaScript driven native mobile applications, which are advocated by appcelerator, have become popular with the help of Facebook’s react native and progress’s native script. Native applications developed with JavaScript do not use WebView, so there is no need to consider the web performance issues encountered by Cordova based applications.

In last year’s discussion, we predicted that 2016 would be a year when these frameworks were mature and widely used, and now it seems that these forecasts are accurate. In the past two years, the number of weekly downloads of react native has continued to increase.

Weekly downloads of “react native” NPM packages from December 2014 to December 2016. (data from NPM- )

Native script has the same trend.

From December 2014 to December 2016, the number of weekly downloads of “native script” NPM software package. (data from NPM- )

The change is not only reflected in the download data promotion of these JavaScript driven native frameworks, but a recent survey (state of JavaScript 2016) shows that JavaScript developers are interested in both react native and native script.

Results of state of JavaScript 2016 interest survey in mobile development

These results are summarized from the investigation and analysis of JavaScript.

In terms of interest scores, “Cordova” and “phonegap” scored very low, which may be due to their performance problems. Although the mobile browser and JavaScript engine on which Cordova and phonegap rely have been greatly improved, it is still not as good as running native code (such as react native).

In 2017, as more and more JavaScript developers begin to try to build native applications, we expect these frameworks that use JavaScript to build native applications can accelerate the development. The rapid development of react framework will also benefit react native, while nativscript announced that it will complete support for angle 2 in May. Many projects will also be upgraded from angular 1 to angular 2, and native script will also benefit from it. We also hope that JavaScript driven native frameworks will appeal to native IOS and Android developers, because it allows you to build real native applications on both platforms with just one piece of code.

JavaScript has increasingly encroached on the mobile end domain, which used to be dominated by Objective-C and Java. But this is not the only new area JavaScript is breaking into. Let’s move on to desktop applications.

Desktop applications

Traditionally, if you want to build windows or Mac applications, you have to use platform specific tools, such as WPF and windows forms, or cross platform solutions, such as Java or adobe air. However, like other software ecosystems discussed above, javascript based solutions are eating into this area.

In last year’s discussion, we discussed two of the most popular JavaScript frameworks for building desktop applications—— NW.js And GitHub’s electron, while judging that its usage will increase significantly in 2016. In reality, growth has occurred, and electron is now an important choice for developing javascript based desktop applications.

If you compare the number of downloads of “electron” and “NW” on NPM, you will see that the trend of “electronic” (red line) and react native is similar, and NW.js The download curve is relatively flat.

Weekly downloads of “electron” and “NW” NPM packages from September to November 2016. (data from NPM- )

In December 2015, electron had 20000 stars on GitHub, NW.js Today, Elecron has nearly 40000 stars, NW.js Just over 30000.

Electron is also accepted by mainstream desktop applications. The framework now provides support for visual studio code. Visual studio code, provided by Microsoft, is a popular editor with more than five million users by April. Electron also promotes the react and angular communities, so tutorials for using electron in both frameworks can be easily found online.

We expect electron to continue to dominate in 2017. We expect electron to further integrate with the most popular frameworks (mainly react and angular) to gain more attention from software suppliers. And as JavaScript continues to invade areas traditionally dominated by Java and Microsoft based technologies, we hope electron will continue to be used as an alternative to WPF, Java, and adobe air development.

Using a single language to complete all your development needs, this solution is not only attractive enough, but also takes some of the latest development methods of JavaScript. Finally, let’s take a look at the performance of JavaScript in some new software areas.

New boundaries of JavaScript

If you ask analysts what’s going on in developing countries, they blurt out popular concepts like virtual reality, chat robots and the Internet of things (IOT).

Among all these new technologies, JavaScript is the most important in the field of chat robots. People use JavaScript to develop from simple slack robots to complex robots for business transactions. In the field of chat robots, most frameworks integrate node Library in their SDK, including botkit, Microsoft BOT framework and Facebook’s 。 Microsoft’s BOT framework documents even explain why to use node to develop robots.

“BOT Builder based on node is a powerful framework for building robots. It can handle various forms of interaction and give more guidance. It can clearly show these possibilities to users. It uses some frameworks (such as express and Restify) so that developers can develop robots in a familiar way.”

Reusing JavaScript also provides node API for many popular IOT libraries (such as losant and zetta) and devices such as leap motion. Chrome browser team and A-frame framework team are typical among them, and many teams use JavaScript in virtual reality.

The Google Chrome team has an impressive array of virtual reality experiments built on JavaScript that you can try on yourself.

However, in the fields dominated by C + +, Python and C, JavaScript does not have great advantages. For example, oculus rift mainly uses C + +, while Microsoft hololens requires you to write in C.

We expect this trend to begin to change in 2017. With the popularity of JavaScript and the improvement of its running speed, JavaScript will continue to extend to fields such as VR and Internet of things. With the emergence of new software development ecosystems, we expect JavaScript to rapidly rise to first-class citizenship.

Wanjinyou JavaScript

Ten years ago, using JavaScript on a server was unthinkable; today, node has 3.5 million users, growing at an annual rate of 100%. Five years ago, using JavaScript to drive native IOS or Android applications was just a spark. Today native script and react native are growing at an amazing rate. Three years ago, it was rare to build desktop applications using JavaScript. Today, electron downloads more than 10000 times a month.

JavaScript will not be used for programming in all scenarios, because many other languages are more suitable for solving problems in specific scenarios. However, regardless of the development platform, the widespread use of JavaScript is bound to be an important factor. There’s a well-known quote from Jeff Atwood about this topic, which may be appropriate to end with, because his speeches are always full of foresight.

“Applications that can be written in JavaScript will eventually be written in JavaScript.”

Translation | JavaScript beyond browser restrictions
Translation | JavaScript beyond browser restrictions

Ikcamp’s original new book “practical combat of efficient development of mobile web front end” has been sold in Amazon, Jingdong and Dangdang.