I remain adamant in my stance that designing regex syntax before, or at the same time as, a true native Swift parsing and pattern-matching feature, is actively harmful and will cause long-lasting damage to the language.
I understand this is a stark position to hold, so please let me explain my reasoning.
We should design a first-class, powerful, and versatile solution for parsing and pattern-matching in native Swift, and we should make it so convenient and so useful that nobody ever wants to use regular expressions instead.
This is a lofty goal. It might even be an impossible goal. But we should nonetheless take it as a goal, and do our level best to achieve it if we can.
If we add regular expressions to Swift before such a parsing and pattern-matching feature, or if we design them at the same time, or if we so much as plan to eventually support regex literals, then we will inevitably fall into a design pitfall which compromises the usefulness of the general feature.
What will happen is, while designing the general feature, there will be a tendency to engineer for complex cases at the expense of simple cases. People will say, “Yes, the general feature is verbose or unwieldy for some use-cases, but those use-cases are simple enough to solve with a short regex instead, so that’s okay.”
Except that is absolutely and fundamentally not okay.
The general solution must be designed for ease of use in simple cases, every bit as much as it must also be designed for comprehensive utility in advanced cases.
It is easy to say, “Of course we will design the general feature for ease of use, and we would never compromise its convenience in simple cases.”
But I am convinced that is exactly what will happen, unintentional though it be.
Even if we make an active effort not to do so, despite our best intentions, it will nonetheless be in the back of everyone’s mind that regular expressions are available for certain use-cases. This will tint our view of the design even if we don’t want it to.
Even if no one ever says out loud, “That’s okay, regexes can handle it,” and even if we consciously endeavor to ignore them while designing the general feature, their mere presence in Swift will subtly affect the way we think about the possible solution space.
Instead, we should design the general feature first, with an overt goal and intention of being so powerful and so delightfully convenient that we will never need nor want to introduce regex literals at all.