This is an excerpt from Quick Start to using Typescript in Node.js applications
In many languages the compiler plays a role in catching certain classes of coding mistakes. Going by the example just named, in other languages not only will the compiler catch that mistake, the IDE has refactoring capabilities to actively help programmers ensure type changes propagate to all affected code.
Theory: Better programs through compile-time checks
In theory, enterprise-grade systems need the rigor one gets with strictly typed languages like Java or C# or C++.
In theory, in small applications strict type/code checking is not critical because anonymous objects with loosely typed fields is manageable in small programs.
In theory, a software system with millions of lines of code can only work if the compiler and runtime system help programmers find bugs.
In theory, a language with strong typing and other features can prevent certain classes of programming errors.
As a software engineer how do you tell which technology to use? There is the technical assessment — does the technology do what it says, and is it a fit for your projects? There’s also a looser evaluation of whether the technology has “legs” meaning will it be in use for the next 10 years or more?
How popular is TypeScript?
Let’s start with Google Trends — which shows us search query trends. The graphs which follow are set to summarize Worldwide search results, and cover the last five years before May 7, 2019.
Because correlation is not causation we haven’t proven anything other than TypeScript interest is growing.
One strong source for the interest in TypeScript is that Angular 2 uses TypeScript. On the Google Trends page it shows related queries, and the combination “angular2 typescript” is very popular.
Given that Node.js is often used for large applications, it’s interesting that the combination of Node.js and TypeScript is not showing much search interest. Also curious is the stagnant/declining interest in Node.js.
Similarly if we pick Express.js, one of the popular app frameworks for Node.js, we see a similar pattern. Express.js interest is at best stagnant, while TypeScript interest is taking off.
What did we prove? TypeScript interest is taking off, while other tools are at best stagnant.
The Dice Skills Center gives a different view into relative popularity of different technologies.
Like with Google Trends, TypeScript popularity is growing strongly.
And where Google Trends showed Node.js interest leveling off, this shows it growing strongly — and beginning to level off in 2018. In the Google Trends chart, Node.js interest over the same period was more stagnant than this.
The difference is that the Dice Skills graph shows the number of job listings requiring certain skills, versus Google Trends showing search queries.
Wouldn’t it have been cool to graph the trends of languages used in Github projects, or trends of StackOverflow questions? Unfortunately I could not find a source of such graphs.
What are other programmers saying?
Another part of evaluating a technology is to look for blog posts about that technology. Are other programmers complaining about the tool, or praising it to the heavens? And what do they say about the technical merit of different technology choices?
I’ll start with one of my own articles
Shouldn’t someone who worked 10+ years in the Java SE team at Sun Microsystems bleed Java bytecodes and be…blog.sourcerer.io
For over 10 years I worked in the Java team at Sun Microsystems, which meant I was fully steeped in Java for this and Java for that. As a blogger on
I’ve done a bit of TypeScript coding since then, and have mixed feelings. It is nice to have the compiler catch some of the errors. But since it does not support run-time type checking, there’s a lot of potential for error.
With TypeScript rapidly growing in popularity, can it co-exist with its parent language and web incumbent?www.techrepublic.com
This article quotes many leading tech industry commentators who are saying things like:
The popularity of TypeScript has really exploded recently. I like TypeScript, and I like static types. I don’t use…medium.com
This article by Eric Elliot makes the case that while static types are very useful, they aren’t a solution for catching bugs. He says code quality studies of a bunch of open source code repositories show that “bug density” does not improve for languages that use static types. Instead what helps reduce bug density is “TDD” or Test Driven Development.
This study examined several open source projects, looking at bugs found in the project, and then inserted type definitions to see if TypeScript would have found the bug at compile time. They found many instances where the compiler would have caught the bugs.
Any professional software engineer knows that the earlier a bug is detected the cheaper it is to fix the bug. A bug caught at compile time is the cheapest to fix.
This blog post introduces the TypeScript language, including some of its advantages and disadvantages compared to…www.joyent.com
This article demonstrates how useful TypeScript is at describing types and object contents. It’s all looking very good until just before the conclusion.
Drawbacks stated in the article:
- Compilation — The developer workflow is a little more complicated because they now have to compile their code.
- Debugging — Using a debugger with code generated by TypeScript is not straightforward.
It is a new programming runtime built on V8, using Rust instead of C++, and users of Deno write their code in TypeScript. In the talk above, Dahl talks very glowingly about TypeScript, and his preference for it is evidenced by having users of the Deno runtime writing their code in TypeScript.
This article is now available in Japanese and Chinese.medium.freecodecamp.org
This article was written by an engineer seemingly coming from a C#/.NET background. The similarities between TypeScript and C# were therefore welcomed. He had a team of C# developers come on board who were able to quickly get going with TypeScript.
The article names a few downsides including the compilation and debugging issues listed earlier.
The TypeScript project has all the appearances of being a properly executed open source project for which there is a ton of excitement. But we have to raise an issue from Microsoft’s past, one that was alluded to in Eric Elliots blog post linked earlier.
Microsoft has not always been a good citizen of the open source movement. For most of its history the company was extremely negative to open source efforts, and to those of us who came of age in the 1980’s-1990’s Microsoft was the enemy.
Microsoft’s hallmark strategy was Embrace, or to bring in new technologies, Extend, or to add features to the technologies it brings in, and Extinguish, or to make the original technology irrelevant by dint of popularizing the incompatible version.
Looked at through one lens, TypeScript is in the Extend phase of that strategy.
Old Microsoft and New Microsoft are different animals. New Microsoft is very open to open source projects, having launched or contributed to many of them. For example Node.js got a big boost when Microsoft poured a lot of engineering expertise into making sure it ran well on Windows. And then there’s the Visual Studio Code IDE, another open source project, that has become extremely popular.
Old Microsoft would have done none of those things. Let’s hope that TypeScript is one of the hallmark projects of the New Microsoft.
For example Microsoft could promote features developed for TypeScript to the ECMAScript committee to be made a standard part of the language.
The question we started with is to note that TypeScript is getting pretty popular, so should we consider adopting it in our own projects. We suggested the evaluation should include technical merit, popularity, and the future of the project. We’ve found and summarized a lot of information, so let’s try to bring it together into a few bullet points.
- The type checking and other features are widely recognized as being very useful, especially in larger projects.
- Some claim compile time type checking helps find bugs, while others claim it does not. As a matter of experience, any programmer who’s used strict type checking compilers know the compiler detects certain classes of mistakes.
- Since TypeScript does not do runtime type checking, the benefit of switching to TypeScript is lessened.
- The TypeScript project has the backing of a large company, Microsoft.
- The TypeScript language is the brainchild of an engineer with a strong track record of developing incredibly useful programming platforms.
- The TypeScript language shares familiarity with Java, C# and other languages making it easier to learn.
David Herron is an independent software developer and writer living in Silicon Valley. He has written several books about Node.js programming, writes about technology on TechSparx.com, and about electric vehicles onGreenTransportation.info.