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:

Comparing Mutative Vs Immer Vs Reducers For Data Handling In React

Comparing React state tools: Mutative vs. Immer vs. reducers

Mutative processes data with better performance than both Immer and native reducers. Let’s compare these data handling options in React.

Rashedul Alam
Apr 26, 2024 â‹… 7 min read
Radix Ui Adoption Guide Overview Examples And Alternatives

Radix UI adoption guide: Overview, examples, and alternatives

Radix UI is quickly rising in popularity and has become an excellent go-to solution for building modern design systems and websites.

Nefe Emadamerho-Atori
Apr 25, 2024 â‹… 11 min read
Understanding The Css Revert Layer Keyword, Part Of Css Cascade Layers

Understanding the CSS revert-layer keyword

In this article, we’ll explore CSS cascade layers — and, specifically, the revert-layer keyword — to help you refine your styling strategy.

Chimezie Innocent
Apr 24, 2024 â‹… 6 min read
Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 â‹… 6 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