[swift-evolution] [Proposal] Refining Identifier and Operator Symbology

Benjamin Spratling bspratling at mac.com
Wed Oct 19 08:04:53 CDT 2016


> On Oct 19, 2016, at 7:18 AM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> How did you decide on those operators instead of ASCII ones?

They are the “correct” mathematical symbols.  On my machine, there is a block of characters explicitly marked as “Math Symbols".  It’s a pretty good start (until you get to the section where latin characters are just drawn in different fonts,at which point, I make no assertions).  ASCII is not the future.  We have unicode for a reason, so we can type what we mean.

>  Obviously, we would want to enable as many operators as possible to continue functioning.
I don’t find this statement to be consistent with the others.  From my perspective, it looks like the proposal deleted as many operators as possible.

> 	•	Operators suffer from low discoverability and difficult readability. They use symbols, not names. This places a cognitive cost on users with respect to both recall ("What is the operator that applies the behavior I need?") and recognition ("What does the operator in this code do?"). 

Requiring a developer to read “formUnion(with:)” is a large cognitive burden for someone trying to use Swift to solve problems in their field.  Not all developers are only UI app makers or coding philosophers.  Many are engineers and scientists trying to find a tool to get their job done.  For these fields, using the correct mathematical operators significantly reduces the difficulty in reading code, which reduces the difficulty finding bugs.  Swift offers a major performance improvement over the tools they may currently be using to get their jobs done, i.e. MatLab and Mathematica.  While those tools offer other features Swift never will, there is always a push in research fields for better performance and independence from a desktop meta-tool, so battle tested algorithms are frequently moved out into stand-alone libraries.  Yes, at times, that has been my job.  Occasionally, someone working on advanced math libraries chimes in on the forum, I know there are folks working on vector libraries out there, I’m sure their code would be more legible using the correct vector-oriented operators.  With the ascii-only operators, there is a lack of distinction between scalar products, and vector products, for example.  Something which can be represented easily with extended unicode operators.

If someone really wants to make the operator sets so restricted, fine, make that a policy at your company.  Please don’t delete it from the language.  In the course on Swift 3 that I’m teaching, I even recommend users don’t create operators they can’t easily type, but keyboards are going to get better.  Heck, I’m paying as much for an Apple keyboard these days as I paid for a cell phone back in 2001.

Look, go easy on me.  I’m still reeling from discovering that weak references cause memory to be persisted until the app itself acts as a garbage collector.  I was unable to bring myself to write code for 2 days following that.  Please don’t take away my icing, too.  I’m not sure I can keep writing code if you do.  Removing standard math operators would make my code look I’m constantly writing 1980’s work arounds instead of clean code.

I have a hard time accepting that essentially reverting the character set for Swift to ASCII is really a good move forward.  I think the proposal reflects some good work on codifying identifiers, but I think the removal of emoji and almost every operator means there’s more work to be done before this proposal is ready for acceptance.

-Ben



More information about the swift-evolution mailing list