Google's Dart Language Gains New Safety Features

The fastest growing programming language by developer adoption in 2019, Dart finishes the year strong with a big new release.

Sean Michael Kerner, Contributor

December 14, 2019

3 Min Read
darts in bulls eye in dartboard
Getty Images

JavaScript and Python may be the most popular programming languages, according to GitHub; however, the fastest growing language of 2019 is Dart.

First publicly announced in 2011, Google's Dart language has undergone a steady stream of improvements in the years since. This has been a particularly active year, with six new releases of the open-source programming language, including Dart 2.7.0, which became generally available on Dec. 11.

Google's Dart language is often closely associated with the company's Flutter project, which provides a portable user interface toolkit for application development. That said, Dart can also work outside of Flutter, enabling developers to build mobile, desktop and web applications.

Dart 2.7.0

Now stable in Dart with the 2.7.0 release is a significant new capability known as Extension Methods.

"These enable you to add new functionality to any type — even types you don’t control — and have the brevity and auto-complete experience of regular method calls," Google Project Manager Michael Thomsen said.

The feature specification documentation for Dart notes that Extension Methods are really just static functions to existing Dart types and allow developers to discover and call those methods as if they were actual methods.

"It will not add any new abilities to the language which are not already available, they just require a more cumbersome and less discoverable syntax to reach," the specification states.

Improving Dart Safety

One of the common problems in programming languages is the handling of a null reference, i.e., a reference in the code that doesn't point to a valid object.

A preview feature in version 2.7.0 of Google's Dart language has landed that provides null safety, which is an important feature to have in a modern programming language. The preview feature adds support for safely accessing object references without triggering null reference exceptions that can crash running application code. To demonstrate the potential of the null safety feature, there is a new null safety playground available in the online DartPad development environment.

Another technical preview in Dart 2.7.0 that can help with safety is the characters package. The default way that Dart encodes characters is much the same as any other language, using UTF-16 encoding. Thomsen noted that UTF-16 strings usually work well; however, when manipulating strings entered by users, there could be a difference between what the user perceives as a character and what is encoded as a code unit in UTF-16. The character package is way to solve the challenge of misinterpreted UTF-16 characters.

"This package supports strings viewed as sequences of user-perceived characters, also known as Unicode grapheme clusters," Thomsen said.

Looking forward to 2020, Dart developers plan on keeping up the rapid release cadence. Among the new capabilities that is expected to come in 2020 is the foreign function interface (dart:ffi), which will enable Dart to call APIs from the C programming language.

Read more about:

Alphabet Inc.

About the Author

Sean Michael Kerner

Contributor

Sean Michael Kerner is an IT consultant, technology enthusiast and tinkerer. He consults to industry and media organizations on technology issues.

https://www.linkedin.com/in/seanmkerner/

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like