Tech

This $1 billion startup spent 18 months rewriting its entire codebase from JavaScript to TypeScript — and its lead engineer explains why it was worth the mammoth effort

  • Sentry is a $1 billion startup that makes open source error monitoring software.
  • In the last 18 months, Sentry rewrote its entire frontend codebase from JavaScript to TypeScript.
  • The developer team now has increased productivity and fewer bugs in production.
  • See more stories on Insider’s business page.

After 12 months, 95,000 lines of code, and the work of dozens of engineers, Sentry — a startup that makes open source developer software — finished rewriting its entire front-end codebase from JavaScript to TypeScript.

The firm decided to embark on this massive undertaking because its engineers realized that, with JavaScipt, they were shipping software bugs that Typescript would have caught automatically. 

26-year-old JavaScript is the most popular programming language — a stunning 97.3% of all websites use it — but TypeScript is a newer, more modern language: Microsoft launched it in 2012 as a powerful alternative for running large-scale applications that’s better at automatically flagging potential issues for developers. 

While the effort to make the switch took Sentry far longer than expected — the engineers had an “overly ambitious” plan to complete it in about four months — it’s created a groundswell of benefits, including increased productivity, the company said. 

Here’s why the startup (valued at $1 billion on the heels of a $60 million fundraise in February) decided to make this switch — and why it recommends it to other firms if they’ve been running into JavaScript errors.

Sentry decided that 

When Sentry’s founders first started building their product in 2008, TypeScript didn’t even exist yet. However, fast forward nearly a decade and the company was having a “wellspring of problems” with JavaScript, according to Sentry principal developer Mark Story. 

“JavaScript is not exactly a very durable language,” he told Insider. “It’s not known for its resiliency.”

In the fall of 2019, the company was shipping “more frontend bugs than what was acceptable,” many of which were so-called runtime errors, or bugs that occur while the software is executing.

Story and others realized that TypeScript’s features would have allowed it to detect these kinds of errors before the code went live on the website. He team estimated that it would take between five and eight engineers about four months to switch over to TypeScript. While some worried this would be an ineffective use of the engineers’ time, they realized that, in the long-run, it could help save the company time by avoiding mistakes. 

“There was pushback initially from certain people around the cost and the complexity it introduces,” Story told Insider. “But those people didn’t have good solutions for preventing all the runtime bugs.”

So, in August 2019, the team made a plan to switch its codebase over by the end of the year, an aggressive timeline that would have required engineers to convert 74 files per week. They would quickly realize how unrealistic that initial timeline would become. 

The reality was much more intense than expected

The team broke its switch strategy into three phases. 

The first was educating the team on how to code in Typescript, which meant providing additional resources and materials. Sentry shared a list of introductory articles and had a technical committee that helped train the team and carefully reviewed all the new code.

“We didn’t approach it from a ‘stick’: It was more of a ‘carrot’ approach. So instead of hitting people and saying ‘Use TypeScript!’ it’d be more like ‘If you use TypeScript, you won’t have these kinds of bugs,'” Story said. “Internally we approached it from a teaching angle versus a punitive one.”

Once the team was educated on the new language, step two was writing all new projects using TypeScript. Building new features in TypeScript also helped developers gain experience while working on lower-risk parts of the code that customers didn’t have exposure to.

In the third and final step, the team had to convert all existing JavaScript files to TypeScript. They predicted the project would be completed by the end of the year but by that landmark, the team had only completed 40% of the files they needed to convert.

Sentry's progress to completion

Their progress was only 20% after 8 weeks, which meant they were nowhere close to their goal.


Sentry



Workers had too much new work to spend so much time on the conversion.

“We didn’t take into account the ability to sustain the energy level for that long for that much work,” Story said. “People just didn’t have the amount of time available to focus on backfill work so that just kinda blew out our timelines.”

Throughout the beginning of 2020, contributors felt burnt out and discouraged by the length of the project. However, a light-at-the-end-of-the-tunnel moment came over the summer: The team hit the 70% conversion mark and felt excited to cross the finish line.

They hustled through to the end of the project, which took a grand total of 18 months from start to finish. In the process of migrating the frontend codebase to TypeScript, the team created over 1,915 Typescript files and finally had zero JavaScript files. 

The benefits of TypeScript and what the team learned 

Since the team completed the shift, the company now has increased productivity and greater protection from mistakes, including fewer bugs in production, Story said.

Because of the way annotations work in TypeScript, developers also have a better experience where they’re spending less time on documentation. TypeScript also has an active community, which came in handy when the Sentry team needed to ask questions of other developers.

He recommends that any other company interested in making the switch should also take it slow (instead of trying to rip out all the JavaScript at once).

“The approach we took is the path I would suggest: It has the drawback of being slow but doesn’t require halting other product work and lets you focus on correctness versus completion,” Story said.

Once the team accepted that they would miss their initial timeline, they gave themselves permission to gradually and carefully chip away at the project instead of rushing. That allowed them to balance the undertaking’s scale with the other important work they had to do to keep building out Sentry’s software.

Overall, Story says the project has benefitted the company significantly and he’d recommend a similar strategy to other firms in the same position. 

“I would recommend it if other organizations are running into the kinds of errors that TypeScript can help with,” Story said. While TypeScript might not be able to solve all of an organization’s issues, “it can help with a bunch of problems that are hard to catch with testing and code review.”

Most Related Links :
nativenewspost Governmental News Finance News

Source link

Back to top button