Why BABEL[?BE?BL] will drive the development of JavaScript

Source: Internet
Author: User

 Babel is a conversion compiler that converts ES6 to code that can be run in a browser. Babel was created by developer Sebastian McKenzie from Australia. His goal is to enable Babel to handle all the new syntax for ES6 and to have built-in react jsx extensions and flow type annotation support.   
According to Codemix founder Charles Pick, Babel is the most compatible with ES6 specifications in all ES6 conversion compilers, even surpassing Google's long-established traceur compilers. Babel allows developers to use all of the new features of ES6 without compromising compatibility with older versions of the browser. In addition, it supports many different build & test systems, making it easy for developers to integrate it into their toolchain.
Charles believes that Babel is fundamentally a platform, which is the biggest difference between it and Compile-to-js language Coffeescript and typescript. Babel's plug-in system allows developers to customize the code converters and insert them into the compilation process. These converters receive an abstract syntax tree and manipulate the code before it is translated into executable JavaScript. Codemix has tried to develop plugins such as static & runtime type checking, closure cancellation, JAVASCRIPT health macros (hygienic macros).
Babel not only tracks the progress of ES6, but also the ES7 or ES2016 test site. For example, it already supports async/await, making it easier for developers to write asynchronous JavaScript code, and the code is simpler and easier to understand than using callbacks or promises. While it may take several years for mainstream browsers to support this asynchronous JavaScript code, Babel allows developers to use it now. This is thanks to the high level of consistency between Babel and the JavaScript Technical Committee (TC39), which provides developers with real-world implementations prior to the standardization of ECMAScript new features. At the same time, this also facilitates JavaScript's further development, as its team can get feedback from the real world before the ECMAScript specification is finalized.
Babel also increases the speed of JavaScript execution. Because the slow loading and execution of JavaScript files can severely affect the user experience, JIT does not have time to perform all technically feasible optimizations at runtime. In contrast, Babel is run at compile time, and there is no such a strict timing limit. With powerful scope tracking and type inference capabilities and plug-in systems, developers can build converters to perform such optimizations, such as the closure elimination mentioned above, which translates closures into normal functions. The Babel itself has some optimizations built in, such as constant merge/constant propagation through the utility.deadcodeelimination converter. In the next few months, we are also expected to see the following plugins:
arbitrary function Inline: the function is inline to the call point, maximizing performance, avoiding polymorphism and function call overhead;

function Replication: In JavaScript, polymorphism is a common cause of slow code execution. Therefore, in a place where the function cannot be inline, a copy of the function should be generated to ensure that the function remains a single state;
in-loop invariant code extrapolation: Move the unchanged code in the loop body outside the loop body;

loop unfold: If the number of cycles n is fixed, the loop is removed and the loop body is copied n copies.

Codemix will post several plugins that perform such optimizations, and interested readers can contact them or follow their Twitter. There are several different optimizations that can be made about the JavaScript engine, which can be viewed here.
Babel plug-ins are limited to performance improvements, for example, you can do these things:
i18n/Translator: Translate specific strings and replace them;
Custom Logging System: Set the log level through environment variables, control the granularity of log;
compile-time converters for optional templating systems (such as mustache or handlebars): Convert label template strings directly to JavaScript code;
Document Builder: Generate documents with Flow type annotations and type inference.
part of the above plugin has been implemented.
in short, Charles believes that Babel is an excellent software that will become part of every web Developer toolkit, and as ECMAScript's proving ground, it is likely to be a major driver of ES6 and esnext applications and development in the near future.

Why BABEL[?BE?BL] will drive the development of JavaScript

Related Article

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.