What is `Swifty`?

Swifty ってなに?

🥞
Swift・iOSコラム
2 min readAug 5, 2017

--

以前このコラムで書いたとおり、try! Swift India で話すことになり、その後トークのタイトルを「What is `Swifty`?」に決めました💁‍♂️

Swifty」とはよく見聞きしますが、具体的にどのようなことを表しているのか?という単純な疑問からこのような内容にしています。ただ明確に定義できるものではないとも考えています。

トークは短めでかつ英語で行います。この記事はそのために調べたことを日本語で書きます✍️

WWDC ではどのように使われた?

WWDC の動画は https://developer.apple.com で検索できます。
Swifty」で検索すると、どのあたりで言及されたかがわかります🔍

結果、WWDC 2016 の3つのセッションがヒットしました💡
(正確な翻訳ができるとは限らないのであえて訳しません)

Platforms State of the Union

Swift loves clarity and it aims to define away boilerplate. On Swift 3, Cocoa APIs have an elegant feel. You could say they’re totally Swifty.

What’s New in Cocoa

For one thing, we’re eliminating repeated and needless words, which of course makes our APIs more swifty, as you might have heard yesterday.

You’ll see that’s not very swifty because .NSCrayonModeColorPanel is fairly wordy.

Swift API Design Guidelines

They feel a bit not-Swifty. What’s that even mean? Not Swifty? You hear it a lot. But in essence, this is why two years in to having Swift as a platform that many thousands of developers are using, is the right time to reevaluate. Because we have experience from a much larger community to understand what works well in Swift code. And so we set off to design the API Design Guidelines to try to codify what it is to build a Swifty API and help everyone build more consistent, more clear APIs within this language that we love.

They’re used all the time to give them these Swifty makeovers to be beautiful in Swift. I talked a little bit about the scale of the Grand Renaming.

Now, method names will get you a long way towards a Swifty API, but this doesn’t quite go far enough.Here I have some simple code that’s creating a standard Gregorian calendar. But if you look at this, this doesn’t really feel very Swifty, especially NSCalendarIdentifierGregorian, which is a plain string global variable. Plain string global variables, that’s not really how we do Swift.

Swift.org ではどのように使われた?

2016年1月29日付で投稿された記事に登場します🗒

It’s Coming: the Great Swift API Transformation

Fortunately Swift developers created tons of great code in spite of that gap, and along the way, there evolved a sense of what “Swifty” code looks and feels like.

この部分だけを読んでもわかりませんが、記事の中で2つの変更例が書かれています。

このほかメーリングリストを検索すればさらに出てきます📚

さて、現段階で Swifty をまとめるとこのようなイメージでしょうか。

  • Clarity / Clear(わかりやすい)
  • Consistent / Regularity / Coherence(一貫性がある)
  • Eliminating repeated and needless words / Not wordy(冗長でない)

ただ、これではまだぼんやりとしていてもっと踏み込まないといけないですね。長くなるのでいったんこの辺で🏃

このコラムの EDITOR(mono )による関連スライド

(38ページ目以降で Swifty について言及)

--

--