2022-11-10
1386
#typescript
Will Soares
137462
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:

Implementing Infinite Scroll In Next Js With Server Actions

Implementing infinite scroll in Next.js with Server Actions

Infinite scrolling in Next.js no longer requires external libraries — Server Actions let us fetch initial data directly on the server.

Rahul Chhodde
Apr 19, 2024 â‹… 10 min read
Integrating Django Templates With React For Dynamic Webpages

Integrating Django templates with React for dynamic webpages

Create a dynamic demo blog site using Django and React to demonstrate Django’s server-side functionalities and React’s interactive UI.

Kayode Adeniyi
Apr 18, 2024 â‹… 7 min read
Using Aoi Js To Build A Bot For Discord

Using aoi.js to build a bot on Discord

Explore how the aoi.js library makes it easy to create Discord bots with useful functionalities for frontend applications.

Rahul Padalkar
Apr 17, 2024 â‹… 9 min read
Web Components Adoption Guide: Overview, Examples, And Alternatives

Web Components adoption guide: Overview, examples, and alternatives

Evaluate Web Components, a set of standards that allow you to create custom HTML tags for more reusable, manageable code.

Elijah Asaolu
Apr 16, 2024 â‹… 11 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:

    “`dart
    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