Skip to main content
QUICK REVIEW

[논문 리뷰] To Type or Not to Type? A Systematic Comparison of the Software Quality of JavaScript and TypeScript Applications on GitHub

Justus Bogner, Manuel Merkel|arXiv (Cornell University)|2022. 03. 21.
Software Engineering Research인용 수 5
한 줄 요약

이 연구는 SonarQube와 GitHub API를 사용하여 1600만 줄 이상의 소스코드를 포함한 604개의 JavaScript 및 TypeScript GitHub 레포지토리(각각 299개, 305개)를 대상으로 소프트웨어 품질을 비교한다. 결과적으로 TypeScript는 코드 품질과 이해 가능성 향상을 보였지만 버그 발생 가능성이나 수정 시간을 줄이진 못했다. 놀랍게도 JavaScript 프로젝트는 더 나은 버그 메트릭스를 보였고, 'any' 타입 사용을 줄이면 품질이 향상됨을 확인했다.

ABSTRACT

JavaScript (JS) is one of the most popular programming languages, and widely used for web apps and even backend development. Due to its dynamic nature, however, JS applications often have a reputation for poor software quality. As a type-safe superset of JavaScript, TypeScript (TS) offers features to address this. However, there is currently insufficient empirical evidence to broadly support the claim that TS apps exhibit better software quality than JS apps. We therefore conducted a repository mining study based on 604 GitHub projects (299 for JS, 305 for TS) with over 16M LoC and collected four facets of software quality: a) code quality (# of code smells per LoC), b) code understandability (cognitive complexity per LoC), c) bug proneness (bug fix commit ratio), and d) bug resolution time (mean time a bug issue is open). For TS, we also collected how frequently the type-safety ignoring `any` type was used. The analysis indicates that TS apps exhibit significantly better code quality and understandability than JS apps. Contrary to expectations, however, bug proneness and bug resolution time of our TS sample were not significantly lower than for JS: mean bug fix commit ratio was more than 60% larger (0.126 vs. 0.206), and TS projects needed on average more than an additional day to fix bugs (31.86 vs. 33.04 days). Furthermore, reducing the usage of the `any` type in TS apps was significantly correlated with all metrics except bug proneness (Spearman's rho between 0.17 and 0.26). Our results indicate that the perceived positive influence of TypeScript for avoiding bugs in comparison to JavaScript may be more complicated than assumed. While using TS seems to have benefits, it does not automatically lead to less and easier to fix bugs. However, more research is needed in this area, especially concerning the potential influence of project complexity and developer experience.

연구 동기 및 목표

  • TypeScript(TS)가 JavaScript(JS)보다 소프트웨어 품질을 향상시킨다는 광범위한 믿음에 기반해, 실제로 TS가 JS보다 품질 향상에 기여하는지 경험적으로 평가하기 위해.
  • 오픈소스 레포지토리 내에서 JS와 TS 애플리케이션 간에 대규모이고 직접적인 경험적 비교가 부족한 문제를 해결하기 위해.
  • TS의 정적 타입이 더 적은 버그와 더 빠른 수정 시간을 초래한다는 일반적인 가정과는 반대로, 정적 타입이 실제로 버그 수와 수정 시간에 영향을 주는지 조사하기 위해.
  • TS에서 'any' 타입 사용이 소프트웨어 품질 메트릭스에 미치는 영향을 분석하기 위해.
  • 실제 세계 데이터를 기반으로 언어 선택과 소프트웨어 품질 간의 관계에 대한 투명하고 재현 가능한 기초를 제공하기 위해.

제안 방법

  • 1600만 줄 이상의 소스코드를 포함한 604개의 GitHub 레포지토리(JS 299개, TS 305개)에서 데이터를 수집하여 프로젝트 크기를 통제하기 위해 크기 균형을 맞췄다.
  • 코드 품질(1000줄당 코드 냄새 수)과 이해 가능성의 지표로 1000줄당 인지 복잡도를 SonarQube를 사용해 측정했다.
  • 커밋 메시지에 'bug' 및 'fix' 키워드가 포함된 커밋을 자동으로 버그 수정 커밋으로 식별했으며, 0.5% 랜덤 샘플(500개 커밋)을 검증했다.
  • 버그 해결 시간을 Zheng 등(2015)의 정의에 따라 이슈 생성 후 마지막 댓글까지의 평균 시간으로 측정했으며, GitHub API를 사용했다.
  • ESLint에 typescript-eslint 플러그인을 적용하여 TS 프로젝트 내 'any' 타입 사용 빈도를 세었으며, 이로 인한 품질 메트릭스 영향을 평가했다.
  • 다양한 품질 측면 간 비교를 위해 통계 분석(예: t-검정, 스피어만의 ρ)을 적용했다.

실험 결과

연구 질문

  • RQ1실제 오픈소스 프로젝트에서 TypeScript는 JavaScript보다 유의적으로 더 높은 코드 품질과 이해 가능성 향상을 보이는가?
  • RQ2TypeScript는 JavaScript보다 낮은 버그 발생 가능성(더 적은 버그 수정 커밋 수)을 보이는가?
  • RQ3TypeScript는 JavaScript보다 더 짧은 버그 해결 시간을 제공하는가?
  • RQ4TypeScript에서 'any' 타입 사용 빈도는 소프트웨어 품질 메트릭스와 어느 정도 상관이 있는가?
  • RQ5버그 관련 메트릭스에서 JS와 TS 간의 괴리 원인으로서의 복잡도나 개발자 경험 등의 혼란 요인은 존재하는가?

주요 결과

  • TypeScript 애플리케이션은 JavaScript보다 1000줄당 18.5% 적은 코드 냄새를 보였으며, 유의미한 차이(p < 0.01)를 보였다.
  • TypeScript 프로젝트는 1000줄당 평균 1.23의 인지 복잡도를 보였고, JavaScript는 1.35로, 코드 이해 가능성 향상이 확인되었다.
  • JavaScript 프로젝트는 1000줄당 버그 수정 커밋 비율이 60% 낮았으며(0.126 vs. 0.206), 이는 JS 애플리케이션이 더 적은 버그 수정 커밋을 기록했다는 뜻이다.
  • 버그 해결 시간은 TypeScript 프로젝트가 평균 33.04일, JavaScript 프로젝트가 31.86일로, 다소 길었지만 차이는 미미했다.
  • 'any' 타입 사용 빈도는 코드 품질과 이해 가능성과 유의미한 상관관계를 보였으며(피어슨 상관계수 rho = 0.17–0.26), 그러나 버그 발생 가능성과는 상관 없었다.
  • 상관관계가 있었음에도 불구하고 효과 크기는 작았으며, 이는 'any' 타입 사용이 품질에 악영향을 주지만 그 영향은 국한적이며 버그 메트릭스의 주요 원인은 아니라는 것을 시사한다.

더 나은 연구,지금 바로 시작하세요

논문 읽기부터 검토까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.