Software

Is JavaScript destined to be usurped by TypeScript?

With TypeScript rapidly growing in popularity, can it co-exist with its parent language and web incumbent?

Year after year JavaScript features among the top 10 most widely used programming languages worldwide, but is a challenger emerging to the venerable web favorite?

An analysis by TIOBE, which counts the number of hits for each programming language returned by major search engines, suggests that Microsoft's TypeScript is enjoying an explosive growth in popularity and encroaching on areas previously dominated by JavaScript.

"TypeScript is slowly becoming the new and improved JavaScript," according to the TIOBE analysis, which highlights how TypeScript is rocketing up its rankings.

"Last month we announced that TypeScript entered the TIOBE index top 100 for the first time. TypeScript appears to keep growing in popularity. This month it entered the top 50."

SEE: Hiring kit: Python developer (Tech Pro Research)

The rapid growth in the use of TypeScript is also reflected in which programming frameworks are increasingly being used, TIOBE says, highlighting "the rising popularity of Angular". Angular is a front-end web framework designed by Google that relies on developers writing TypeScript, and whose earlier incarnation was based on JavaScript.

Tiobe predicts it is only "a matter of time" before React, a widely used framework for building user interfaces, also switches from JavaScript to TypeScript.

That rapid growth in demand for TypeScript was also reported by IT Jobs Watch, which sources its data from IT recruitment services in the UK.

In the year to July the fastest growing languages in terms of demand were:

    1. ECMAScript 2015 (JavaScript ES2015, ES6)
    2. Microsoft TypeScript
    3. Java SE 8
    4. ECMAScript 2016 (JavaScript ES2016, ES7)
    5. Go (Golang)
    6. PHP 7
    7. Elixir
    8. Apple Swift
    9. F#
    10. C

      So how likely is it that JavaScript will slowly be edged out by TypeScript?

      With a little bit of work, TypeScript can be used as a replacement for JavaScript. Because it compiles to JavaScript, it can be used wherever the developer normally uses JavaScript, whether that be for a web app running in the browser or backend code in a node.js environment.

      TypeScript is also a superset of JavaScript, that is it allows the developer to write in standard JavaScript if they want to, but also adds new features designed to help developers build larger and more complex programs. These additions include static types and other features that make it easier to work with classes and modules, as well as supporting simpler to use tools for verifying and checking the structure of the code.

      Kris Borchers, executive director of the JS Foundation, says that TypeScript is more a complement to JavaScript than it is a replacement, and that the popularity of both are growing side-by-side.

      "TypeScript is a strictly typed superset of JavaScript, so it's great to see TypeScript's adoption rising as it helps address the needs of JavaScript developers that want a bit more type safety and insight into potential issues in their application at compile time as opposed to runtime.

      "The JS Foundation is continuing to see JavaScript grow. The versatility and open source ecosystem that surrounds JavaScript has propelled it to become more than just the backbone of web applications.

      "It now fuels frontend, backend and IoT development, and is moving into new areas like distributed ledgers and Artificial Intelligence."

      As JavaScript continues to spread into new domains, the need for robust tools for writing and refactoring code becomes ever more important. In describing why the Angular team at Google made the switch from JavaScript to TypeScript Victor Savkin, who was previously on the Angular core team at Google, said TypeScript can substantially reduce the risk when changing code.

      "The biggest selling point of TypeScript is tooling," he wrote.

      "It provides advanced autocompletion, navigation, and refactoring. Having such tools is almost a requirement for large projects. Without them the fear changing the code puts the code base in a semi-read-only state, and makes large-scale refactorings very risky and costly."

      John Grant, data scientist and director of IT Jobs Watch, agrees that TypeScript helps compensate for shortcomings of the base JavaScript language, although he says the language is becoming more robust with each generation.

      "JavaScript lacks language features making large-scale application development difficult, although not impossible," he said.

      "Successive versions of ECMAScript, the standard JavaScript language specification, continues to add syntax and features to improve performance and developer productivity.

      "Robust code and developer productivity are probably the key reasons behind the Angular team adopting TypeScript."

      Like Borchers, however, Grant sees TypeScript as co-existing with JavaScript, rather than usurping it.

      "Will TypeScript replace JavaScript? No, not in the short term. Given TypeScript is a typed superset of JavaScript, most developers will probably need to be comfortable working with JavaScript even if they are principally TypeScript developers."

      Also see

      young developers writing code
      Image: iStockphoto./GaudiLab

      About Nick Heath

      Nick Heath is chief reporter for TechRepublic. He writes about the technology that IT decision makers need to know about, and the latest happenings in the European tech scene.

      Editor's Picks

      Free Newsletters, In your Inbox