Skip to content

Document the reasons of putting types before variables #2564

@Leedehai

Description

@Leedehai

This is more of an idea of improvement in documentation rather than an error report.

Hi, Dart adopted a syntax where a variable type is put before the variable name, like C and Java:

const int a = 0;

Given that

  • the newer-ish languages like TypeScript, Python (with type hints), Swift, Kotlin, Rust, and Google's very own Go all elected to put types after variable names (and consequently have a dedicated keyword to declare functions). People wrote a lot to justify this type-last syntax, like
  • users working on mobile apps tend to be used to Swift and Kotlin, and they form the main target user base of Flutter (especially before desktop support),

It feels there's a specific technical reason for Dart to make this choice, not just taste or frugality to save a few characters. For educational purposes, could you document why it is so? (like this question and answer, which is mentioned in the official doc)

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions