TypeScript vs JavaScript: Who’s Winning The 10-year-long Battle?
As JavaScript grew to become a web-dev behemoth, it slowly left behind its legacy of being a prototype object-oriented programming language. However, there has been another one quietly picking up the pieces for the past 10 years. For applications where JS is unsuitable, Microsoft’s TypeScript has seen widespread adoption. Launched in 2012, TypeScript is now approaching v5.0. After 10 years of being out in the mainstream, let’s take a look at who’s winning the battle between JavaScript and TypeScript. JavaScript vs TypeScript While JavaScript first burst on to the scene as a scripting language developed for NetScape 2, the use of JS for WebDev led to it being used as a server-side programming language rather than for client-side applications. This led to JS code for big applications becoming complex and resource-intensive, creating the need for an alternative. TypeScript was created as a superset of JavaScript, with the intention to make writing clear and simple JS code easy. It was developed as a complementary scripting language to JavaScript, similar to the relationship Visual Basic shares with C++. The main differences between the two is that TypeScript adds static typing, classes, and modularization. In the mid 2010s, Microsoft found that their enterprise customers found writing application-scale JavaScript ‘too hard’. This led them to begin development on a JavaScript alternative focused on developing large applications. Anders Hejlsberg, then-chief architect for C# language, said “JavaScript was created as a scripting language. It [wasn’t designed] to structure medium- to large-scale code bases such as classes or modules. JavaScript is an entirely dynamic language that has no static typing, and static typing is really the thing that powers today’s rich IDEs.” The two main types of typing in programming languages are static typing and dynamic typing. Static typing means that the language checks the typed variables for correction before running the program. Dynamically typed languages, on the other hand, only check for type correctness while the program is running. By using a static typing method, enterprise users could develop well-structured programs that would check types before running. This not only saves development time, but also ensures that mission-critical applications run smoothly. The static nature of the language also allows the implementation of better code structuring and other object-oriented programming techniques. To avoid compatibility issues, TypeScript code is compiled into JS code through a process known as trans-piling. This ensures inter-compatibility between both languages, with TS being able to pick up on JS code natively and JS accepting trans-piled TS code. Most, but not all, libraries made for JS are also compatible with TypeScript (more on that later.) Is Typescript Winning? Due to Microsoft’s hand in creating TypeScript, the language has better support for the tech giant’s IDEs such as Visual Code. At launch it had the support for IDE features like IntelliSense, a primitive code autocomplete and syntax checking toolkit. However, the question still remains: Are these features enough to make developers switch away from JavaScript to TypeScript? While the shortcomings of JS led many others to create alternatives such as Dart, Kotlin, CoffeeScript, and more recently Scala, Typescript remains the leader in JavaScript alternatives. It has garnered considerable support from developers, as evidenced by the number of online communities that have sprung up around the language. TypeScript also sky-rocketed in developer usage over the years, as seen by this graph taken from the 2020 State of JS report. In the 2021 State of JS report, 69% of respondents chose TypeScript to be their preferred language that compiles to JS, with the second place, Elm, only receiving 2.4% of the votes. The language also has consistently placed in the top 5 of languages developers love and wish to use in Stack Overflow’s yearly surveys. However, even as TypeScript has garnered considerable love from developers, it comes with its own set of limitations. As it is a statically typed language built on top of JS, it not only requires prior knowledge of JS but also knowledge of OOP concepts, along with scripting know-how. Moreover, it is more suited to deployment in large teams, with most solo developers choosing to stick with JS because of its considerably larger community and relatively simpler code. Moreover, not all frameworks are supported by TypeScript, which means that certain applications which require obscure frameworks need additional configuration to get working properly with TS. TypeScript is also competing against other alternatives like ClojureScript and Scala for developer use. While there are many developers who prefer to use TS, the possibility of this language replacing JavaScript is impossible. Since TS is built on top of JS, it can only compete against other JS alternatives and not JS itself. However, as seen with the developer love and community growing around TS, it is clear that this language has carved out a niche for itself in the ever-growing JS ecosystem.
TypeScript was created as a superset of JavaScript with the intention to make writing clear and simple JS code easy
TypeScript was created as a superset of JavaScript with the intention to make writing clear and simple JS code easy
[]
["programming_languages:R", "AI", "ETL", "Scala", "TypeScript", "C++", "JavaScript", "R", "Java", "programming_languages:JavaScript"]
["AI", "R", "JavaScript", "TypeScript", "Java", "Scala", "C++", "ETL", "programming_languages:R", "programming_languages:JavaScript"]
I am an AI enthusiast and love keeping up with the latest events in the space. I love video games and pizza.