One of the great things about starting a new company is that you get to pick all the components of your dev stack from scratch. We get a chance to evaluate languages, frameworks, and other dev tools from the best of what’s out there today.
TypeScript lets us cut through a lot of the pain of development
For the majority of the software we build at Unbounded Systems, we’ve chosen TypeScript as our go-to language. We’ve found that TypeScript lets us cut through a lot of the pain of development and focus on what we’re trying to build. Although there are quite a few ways that TypeScript helps alleviate developer pain, I’ll just focus on the three that we think give us the best productivity boost.
Because TypeScript is basically JavaScript with types, the entire universe of JavaScript libraries on NPM is still available to us. For many of those modules, especially the more popular ones, TypeScript type information is already available, so we immediately get the benefits of type checking. And although you can use a module without type information, just like you would normally in JavaScript, we typically go ahead and create type information (a TypeScript declaration file) for modules that don’t have them already.
Modules available on npmjs.com — 2/27/2018
The vast set of libraries available for JavaScript means we get to leverage the great work done by many of the open source projects out there and spend less time re-inventing.
TypeScript code compiles directly to JavaScript, which means that it runs pretty much everywhere. We can use it in the browser for the front end of our web apps with frameworks like Angular and React. And we can run it in a Node.js environment on the back end. We also don’t have to worry about what version of JavaScript each of those different runtimes support because the TypeScript code can compile to earlier versions of JavaScript…all the way back to ES3.
In a startup-sized engineering team, this means we get to develop a stronger internal community of expertise around a single language and our full stack engineers spend less time context switching.
Although the first two benefits above are shared with JavaScript, it’s the addition of the type system, along with an awesome ecosystem of tools, that make our development more productive with TypeScript. It’s the type system that validates API contracts and flags potential bugs earlier, rather than finding bugs during testing. Or worse yet…in production.
In fact, with the awesome IDE integration (we love VS Code), the TypeScript compiler incrementally re-compiles, giving you feedback and flagging errors as you type. That’s a huge productivity boost!
VS Code giving feedback as I type
And in case you’re not convinced about the value of types, a 2017 study of JavaScript projects found that adding types with TypeScript or Flow was able to detect 15% of publicly reported bugs. While you may not think 15% is huge, consider that the study was performed on already committed code that had already been through the projects’ testing and review process. Just think how many bugs you could avoid finding in unit testing if your tools flagged the bugs as you type.
While TypeScript is the language we use the most often and in the most places, it’s still not the answer to every problem. There are also some places where TypeScript isn’t the right fit. In a follow-up post, I’ll cover why and where we use Go, C++, JavaScript, and Python.
Connect with Unbounded Systems on our blog, Twitter and YouTube to keep up with the latest dev tools and trends. And an occasional rant.
Originally published on the Unbounded Systems Blog.