Philosophy of Swift


(Jon Hull) #1

I am (somewhat unexpectedly) teaching a class in Swift/iOS starting later this week, and I was hoping to get a couple of quotes to share with my students from the community (and ideally a core team member) about what they believe the general philosophy behind Swift is…

I have heard things like:
“Swift is a practical language”
“Swift is the first Protocol Oriented Language”

How would you define Swift in your own words?

Thanks,
Jon


(Brandon Knope) #2

My favorite is that Swift is an opinionated language :stuck_out_tongue:

"We intentionally want Swift to have a common “center of gravity” and be an
“opinionated” language, rather than fall to the “design by committee” approach that leads to a
watered-down design”
This was from Chris Lattner

Reference: Re: [Review] Replace `typealias` keyword with `associatedtype` for associated ty <http://article.gmane.org/gmane.comp.lang.swift.evolution/2040/match=opinionated>

Brandon

···

On Jun 8, 2016, at 9:03 AM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

I am (somewhat unexpectedly) teaching a class in Swift/iOS starting later this week, and I was hoping to get a couple of quotes to share with my students from the community (and ideally a core team member) about what they believe the general philosophy behind Swift is…

I have heard things like:
“Swift is a practical language”
“Swift is the first Protocol Oriented Language”

How would you define Swift in your own words?

Thanks,
Jon
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Chris Lattner) #3

I’d recommend going back into the swift evolution archives and read posts from the core team in the first month or two. We spent a considerable amount of effort answering basic questions with extensive rationale for why things are the way they are (or why something is considered to be unfortunate and needs to change).

-Chris

···

On Jun 8, 2016, at 6:03 AM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

I am (somewhat unexpectedly) teaching a class in Swift/iOS starting later this week, and I was hoping to get a couple of quotes to share with my students from the community (and ideally a core team member) about what they believe the general philosophy behind Swift is…


(Brent Royal-Gordon) #4

How would you define Swift in your own words?

I'd say this, rather grandly:

Swift does not believe in the no-win scenario. It does not assume that strong typing must be cumbersome, that memory-safe code must be slow, or that a language must choose whether to be high-level or low-level. If two things are desirable, it doesn't just balance them against each other; it finds a way to get more of both than you would have thought possible, usually through careful design and

···

--
Brent Royal-Gordon
Architechies


(Jordan Rose) #5

https://swift.org/about/ has some pretty good verbiage about this. In particular:

"Swift is a safe language."

in that the obvious thing should be safe, and unsafe things should require a bit of reaching. That's more important to me than a lot of other things that happen to be true.

(I've been sneakily saying this in person every time someone asks me, but I guess I can say it out loud here. Please don't call it an "official Apple opinion" or "official swift.org opinion", though. It's "one Swift compiler developer's opinion". :slight_smile: The official swift.org opinion is how it's phrased on swift.org.)

Jordan

···

On Jun 8, 2016, at 6:18, Brandon Knope via swift-evolution <swift-evolution@swift.org> wrote:

My favorite is that Swift is an opinionated language :stuck_out_tongue:

"We intentionally want Swift to have a common “center of gravity” and be an
“opinionated” language, rather than fall to the “design by committee” approach that leads to a
watered-down design”
This was from Chris Lattner

Reference: Re: [Review] Replace `typealias` keyword with `associatedtype` for associated ty <http://article.gmane.org/gmane.comp.lang.swift.evolution/2040/match=opinionated>

Brandon

On Jun 8, 2016, at 9:03 AM, Jonathan Hull via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I am (somewhat unexpectedly) teaching a class in Swift/iOS starting later this week, and I was hoping to get a couple of quotes to share with my students from the community (and ideally a core team member) about what they believe the general philosophy behind Swift is…

I have heard things like:
“Swift is a practical language”
“Swift is the first Protocol Oriented Language”

How would you define Swift in your own words?

Thanks,
Jon
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(J Charles N. M.) #6

+1 Brandon
Sound like the first real fully open source language.

Never been implicate in ruby development process but it seem to be an opinionated language too. But this quote fit well to Swift 2+ until now.

Something that show the uniqueness of Swift will be great.

···

--
J. Charles

Le 8 juin 2016 à 15:18, Brandon Knope via swift-evolution <swift-evolution@swift.org> a écrit :

My favorite is that Swift is an opinionated language :stuck_out_tongue:

"We intentionally want Swift to have a common “center of gravity” and be an
“opinionated” language, rather than fall to the “design by committee” approach that leads to a
watered-down design”
This was from Chris Lattner

Reference: Re: [Review] Replace `typealias` keyword with `associatedtype` for associated ty

Brandon

On Jun 8, 2016, at 9:03 AM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

I am (somewhat unexpectedly) teaching a class in Swift/iOS starting later this week, and I was hoping to get a couple of quotes to share with my students from the community (and ideally a core team member) about what they believe the general philosophy behind Swift is…

I have heard things like:
“Swift is a practical language”
“Swift is the first Protocol Oriented Language”

How would you define Swift in your own words?

Thanks,
Jon
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Brent Royal-Gordon) #7

Ack, hit Send while I was still typing.

Swift does not believe in the no-win scenario. It does not assume that strong typing must be cumbersome, that memory-safe code must be slow, or that a language must choose whether to be high-level or low-level. If two things are desirable, it doesn't just balance them against each other; it finds a way to get more of both than you would have thought possible, usually through careful design and

compile-time logic.

···

--
Brent Royal-Gordon
Architechies


(John McCall) #8

+1 Brandon
Sound like the first real fully open source language.

This is not fair to any number of other languages. We're proud of how open the Swift development process is, but we can't claim priority.

John.

···

On Jun 8, 2016, at 8:35 AM, J. Charles M. N. via swift-evolution <swift-evolution@swift.org> wrote:

Never been implicate in ruby development process but it seem to be an opinionated language too. But this quote fit well to Swift 2+ until now.

Something that show the uniqueness of Swift will be great.

--
J. Charles

Le 8 juin 2016 à 15:18, Brandon Knope via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> a écrit :

My favorite is that Swift is an opinionated language :stuck_out_tongue:

"We intentionally want Swift to have a common “center of gravity” and be an
“opinionated” language, rather than fall to the “design by committee” approach that leads to a
watered-down design”
This was from Chris Lattner

Reference: Re: [Review] Replace `typealias` keyword with `associatedtype` for associated ty <http://article.gmane.org/gmane.comp.lang.swift.evolution/2040/match=opinionated>

Brandon

On Jun 8, 2016, at 9:03 AM, Jonathan Hull via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I am (somewhat unexpectedly) teaching a class in Swift/iOS starting later this week, and I was hoping to get a couple of quotes to share with my students from the community (and ideally a core team member) about what they believe the general philosophy behind Swift is…

I have heard things like:
“Swift is a practical language”
“Swift is the first Protocol Oriented Language”

How would you define Swift in your own words?

Thanks,
Jon
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Paul Cantrell) #9

Yes, the opt-out safety is a distinguishing feature.

I’m sure Haskell’s designers would give a grandly worded rebutted to just “Swift is safe,” since Swift allows race conditions, forced unwraps, unsafe memory access, etc. What distinguishes Swift for me is the particular way it emphasizes safety and high-level abstraction, but weighs those against static optimization.

I can’t articulate it as crisply as Jordan did, but my Swift description would be something like this:

• It provides a high-level programmer model.
• It provides pervasive, opt-out safety.
• It compiles to native binaries.
• The compiler can optimize its abstractions to C-like performance most of the time.

The interplay of the first two and the last two is what makes the language unique. For example, structs have a simple, high-level programmer model — “pass by value semantics” — but the compiler jumps through all those COW hoops to make them perform _most_ of the time as if they were C structs statically allocated and then passed by pointer.

Why isn’t Swift Haskell or ML? Because of that constraint of providing only abstractions that allow aggressive static optimization.

Why isn’t Swift C or Eagle? Because of the goal of making the abstractions as high-level as possible, and making the language’s safety features opt-out instead of opt-in.

Why isn’t Swift Go? Because of the goal of making the abstractions as high-level as possible, and the distaste for a heavyweight runtime.

Why isn’t Swift Rust? Because it doesn’t insist on zero-cost abstraction; instead, it weighs having a high-level programmer model and readability against abstraction cost.

Cheers,

Paul

···

On Jun 8, 2016, at 4:07 PM, Jordan Rose via swift-evolution <swift-evolution@swift.org> wrote:

https://swift.org/about/ has some pretty good verbiage about this. In particular:

"Swift is a safe language."

in that the obvious thing should be safe, and unsafe things should require a bit of reaching. That's more important to me than a lot of other things that happen to be true.


(Dave Abrahams) #10

Rather grand and inspiring indeed!

···

on Wed Jun 08 2016, Brent Royal-Gordon <swift-evolution@swift.org> wrote:

Ack, hit Send while I was still typing.

Swift does not believe in the no-win scenario. It does not assume

that strong typing must be cumbersome, that memory-safe code must be
slow, or that a language must choose whether to be high-level or
low-level. If two things are desirable, it doesn't just balance them
against each other; it finds a way to get more of both than you would
have thought possible, usually through careful design and
compile-time logic.

--
Dave


(Dave Abrahams) #11

I have no argument with most of what you wrote, but this part is just
inaccurate. Plain structs are never CoW'd, and the compiler doesn't
introduce CoW. The standard library implements CoW “manually” for
specific types like Array and String.

···

on Wed Jun 08 2016, Paul Cantrell <swift-evolution@swift.org> wrote:

The interplay of the first two and the last two is what makes the
language unique. For example, structs have a simple, high-level
programmer model — “pass by value semantics” — but the compiler jumps
through all those COW hoops to make them perform _most_ of the time as
if they were C structs statically allocated and then passed by
pointer.

--
Dave


(Paul Cantrell) #12

So then only language/runtime magic is isUniquelyReferenced(), and all the other “hoops” are in the standard lib?

I guess I just lump compiler and standard library together in my mind too carelessly!

P

···

On Jun 8, 2016, at 6:13 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:

on Wed Jun 08 2016, Paul Cantrell <swift-evolution@swift.org> wrote:

The interplay of the first two and the last two is what makes the
language unique. For example, structs have a simple, high-level
programmer model — “pass by value semantics” — but the compiler jumps
through all those COW hoops to make them perform _most_ of the time as
if they were C structs statically allocated and then passed by
pointer.

I have no argument with most of what you wrote, but this part is just
inaccurate. Plain structs are never CoW'd, and the compiler doesn't
introduce CoW. The standard library implements CoW “manually” for
specific types like Array and String.


(Dave Abrahams) #13

It's the right user model most of the time. In this case, though, you
don't want to give people the impression that these things will be done
for them.

···

on Wed Jun 08 2016, Paul Cantrell <paul-AT-bustoutsolutions.com> wrote:

On Jun 8, 2016, at 6:13 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:

on Wed Jun 08 2016, Paul Cantrell <swift-evolution@swift.org> wrote:

The interplay of the first two and the last two is what makes the
language unique. For example, structs have a simple, high-level
programmer model — “pass by value semantics” — but the compiler jumps
through all those COW hoops to make them perform _most_ of the time as
if they were C structs statically allocated and then passed by
pointer.

I have no argument with most of what you wrote, but this part is just
inaccurate. Plain structs are never CoW'd, and the compiler doesn't
introduce CoW. The standard library implements CoW “manually” for
specific types like Array and String.

So then only language/runtime magic is isUniquelyReferenced(), and all
the other “hoops” are in the standard lib?

I guess I just lump compiler and standard library together in my mind
too carelessly!

--
Dave