Please define “actively harmful” as related to Swift evolution

Hey Team,

Can somebody point me to the official definition of actively harmful within the context of Swift evolution?

I’ve used the phase but I feel that I don’t really have a good grasp of what everyone means when they use it.

If we don’t have a Swift definition, how does one come up with one? Does this itself need a proposal? Is this up to the core team to define?

Thank you,
Chéyo

3 Likes

Here is what I mean when I use the phrase "actively harmful":

In Swift, we aim for designs that actively guide or steer the user towards doing the "right thing." It can be hard to define holistically but it isn't hard to give some good examples:

  • Swift actively steers users towards preferring memory-safe operations over memory-unsafe operations.
  • Swift actively steers users towards considering what to do in the case of recoverable failures rather than ignoring them: for instance, users have to spell out what to do in the case of nil and what to do when a guard condition evaluates to false rather than rely on implicit default behavior.
  • Swift actively steers users towards Unicode-correct operations on strings.

There can be (and, I think we'll agree, already are) suboptimal features in Swift that don't quite accomplish the intended goals, and there can be features that do not help or hurt users to do the "right thing." Those are not "actively harmful"--or even, for that matter, harmful.

A feature is actively harmful when, given two options--one that is more likely to be memory safe, defined behavior, within a human user's ability to reason through, etc., and one that is harmful (by being memory unsafe, or undefined behavior, or beyond a human user's ability to reason through, etc.), the design of the feature is such that it guides or steers users towards the harmful option. The companion bit that's usually implied is that there must be a viable alternative design or course of action that accomplishes similar goals to the actively harmful feature, but that steers the user towards the more salutary option or at least doesn't favor the harmful one.

14 Likes

To extend on @xwu's wonderful response, I also often think of "actively harmful" as encouraging at least some rudimentary empiricism, by inspection of real-world code bases, questions/answers on StackOverflow, etc. Problem areas which are an issue only in theory, without evidence of actual misuse, I would argue, generally do not rise to the level of "actively harmful."

@xwu's post is amazingly great. The magic of a good programming language is how it subtly pushes its programmers/users -- without forcing/limiting them -- into behavior that is deemed positive for users. It is best if this happens by making the easy path also be the "best" path.

-Chris

5 Likes

So an actively harmful feature is the opposite of an opinionated feature? Can actively harmful ever apply to sugar?

I believe that this is exactly the case that was considered for ++ and --

6 Likes