Will Soares
Nov 10, 2022 ⋅ 4 min read

Comparing Dart and TypeScript

Will Soares I'm a front-end developer and writer based in Porto, Portugal. For more posts, check out willamesoares.com.

Recent posts:

Winterjs Vs Bun: Comparing Javascript Runtimes

WinterJS vs. Bun: Comparing JavaScript runtimes

WinterJS is theoretically the fastest WinterCG JavaScript runtime. Let’s compare WinterJS to Bun, another runtime known for its speed.

Emmanuel Odioko
May 28, 2024 ⋅ 6 min read
Understanding Cross Platform Graphics In Rust With Wgpu

Leverage Rust and wgpu for effective cross-platform graphics

Use Rust with wgpu to work directly with the new WebGPU standard for better control, cross-platform performance, and bug handling.

Mario Zupan
May 28, 2024 ⋅ 36 min read
Leveraging Wasp For Full-Stack Development

Leveraging Wasp for full-stack development

Learn how the Wasp, Web Application Specification, framework simplifies full-stack development by offloading repetitive code tasks.

Wisdom Ekpotu
May 27, 2024 ⋅ 11 min read
Developing Web Extensions With Wxt

Developing web extensions with the WXT library

Browser extensions are an important part of the web ecosystem. They make our lives easier and enhance our web browsing […]

Debjyoti Banerjee
May 24, 2024 ⋅ 8 min read
View all posts

2 Replies to "Comparing Dart and TypeScript"

  1. In the language comparison, it looks like Dart takes twice (16) as many lines of code than TypeScript (8). But that’s because the implementations are different. The Dart code can be greatly simplified to look like a 1 to 1 match of the TypeScript code:

    import ‘dart:math’;

    int multiply(int a, int b) {
    return a * b;

    void main() {
    int a = Random().nextInt(10);
    int b = 3;

    print(‘$a * $b = ${multiply(a, b)}’);

    Now it takes the same number of lines as the TypeScript counterpart: 8, excluding the import and the wrapping main function, which are indeed an unavoidable.

    1. Hey wilsonsilva, thanks for your comment. It’s good to see how that code can be altered to look more compact.

      The comparison in the post though was targeted at showing the differences in syntax between the two, rather than which one needs more lines of code.

      Again, appreciate your feedback and I hope the post helped with giving you insights on the two languages.

Leave a Reply