News

TypeScript 2.7 Ships, Developers Debate Its 'Bloat'

Microsoft yesterday shipped TypeScript 2.7, adding a bunch of new features as usual -- so many that a debate about bloat in the open source programming language was sparked on a social coding site.

"We've got a lot in 2.7," said Daniel Rosenwasser, a team program manager, in a post yesterday.

In fact, his "bird's eye" view of the changes numbered 10 items:

  • Stricter class property checks
  • Definite assignment assertions
  • Easier ECMAScript module interoperability
  • unique symbol types and const-named properties
  • Cleaner output in --watch mode
  • Prettier --pretty output
  • Numeric Separators
  • Fixed Length Tuples
  • in operator narrowing and accurate instanceof
  • Smarter object literal inference

While Microsoft dev teams often respond to the most-cited developer feature requests in implementing new functionality, a debate arose on Hacker News about too much new stuff being baked into the language, described as a strict syntactical superset of JavaScript that adds optional static typing to the language.

"On the one hand I am glad they are continuing to enhance TypeScript," said one commenter with the handle whitefish. "On the other hand I am concerned that TypeScript is becoming a very bloated language."

While many developers took exception to that, several others agreed, with comments such as:

  • "That bloat in the language and the amount of features added with every release is making me a lot worried."
  • "I agree with others that a language should not become bloated and I think it is heading in that direction."
  • "ESxx is already waaaay too bloated, and Typescript only adds to that."
  • "It is a bit dizzying that the type system keeps getting even more expressive (the next release might have type conditionals!) while the core language and its dynamic semantics is necessarily limited to tracking Javascript (so no operating overloading, no pattern matching)."
  • "Are there actually people out there asking for all of these nuanced features? I've been excited about TS for a while and used it for several side projects with great success...but with each new release and new set of 'features' my excitement wanes a bit."

The answer to that last question was basically "yes" from Ryan Cavanaugh, who said he does some feature planning and feature prioritization for TypeScript. He offered this tit-for-tat rebuttal:

  • The strict class property initialization check was the one of the highest-voted, most-commented, and most-duped "unfixed" issues on the issue tracker.
  • Definite assignment assertions are a necessary co-feature for class property initialization checks to work ergonomically.
  • ES module interop is just TS keeping up with the evolving ES6 / CJS interop story. TS has to support ES modules.
  • "unique symbol" is type system support for the long-present ES6 symbol concept.
  • Cleaner/prettier console output should be uncontroversial as an incremental improvement.
  • Numeric separators are an ECMAScript feature that need to be supported. TS has to support ES syntax.
  • Fixed length tuples were a long-standing proposal (nearly 2 years old) that had a lot of positive feedback from the community. Among people who were using tuples, the prior behavior was seen as very much wrong and we were convinced by the use cases. People not using tuples are unaffected, naturally. It's more of a bugfix than a feature.
  • Better narrowing under "in" and "instanceof" were also long-standing issues. The "instanceof" behavior in particular just looks like a bug; only from a spec-lawyer perspective is it really a feature per se. It's more of a bugfix than a feature.
  • Smarter object literal inference again basically amounts to a bugfix; TS was allowing extremely broken code, essentially due to some implementation details of how types' representations are optimized. It's more of a bugfix than a feature.

"It's definitely understandable that the most exciting features are already in the language, but I don't see anything in this list and see 'bloat,' " Cavanaugh concluded.

Rosenwasser also weighed in with a response to whitefish, whose aforementioned comment further said: "I worry that as long as Microsoft has Program Managers and Development Leads assigned to TypeScript and their job performance is measured by the number of features they add, TypeScript is going to get more and more bloated with obscure features."

Here is Rosenwasser's response:

As a PM on the team, I actually _share_ your concern! ;)

In fact, we're very mindful about the cognitive overhead of new features, but we're also motivated by pragmatism. These features have been highly demanded to help them write real-world code. My coworker Ryan has written up a pretty good explanation of why we tackled the feature set that we did: https://news.ycombinator.com/item?id=16277367 [citing Cavanaugh's comment above]

Keep in mind that TypeScript strives to model JavaScript as it's written broadly. While we could always take the stance that you have to rethink the way you write JavaScript, that would be unnecessarily stubborn. Hope that gives some insight!

Rosenwasser's post details how developers using different versions of Visual Studio can install TypeScript 2.7, which isn't automatically available for Visual Studio Code users yet, though he points to guidance for those devs who want to install it manually right now.

Meanwhile, the project's roadmap shows what's coming, including those conditional types, "which add the ability to express non-uniform type mappings. A conditional type selects one of two possible types based on a condition expressed as a type relationship test: T extends U ? X : Y"

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

Subscribe on YouTube