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:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 â‹… 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 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