Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
JewKiller 3000
Nov 28, 2006

by Lowtax
It may be better than Objective-C, but from a broader perspective (comparing to all languages), I don't see the big deal here. None of the features you've mentioned in this thread were introduced in the PL literature later than the 1980s. What's so good about this new language aside from making fewer mistakes?

Adbot
ADBOT LOVES YOU

b0lt
Apr 29, 2005
Why is the lambda syntax so weird? Why make in a keyword in the first place, instead of just using C++/java style foreach syntax?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
This is a big pet peeve of mine for new projects. Do you have any internal projects using Swift yet? New apps, new frameworks, whatever? I find that a lot of these PLs sound great until you actually go to use them, because nobody actually used them in the real world yet.

I am not going to touch Swift until I hear that you have a moderately sized, going-to-production codebase written in it.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Damiya posted:

I'm not an iOS dev, so maybe this is a dumb question, but since there's no GC does that mean all memory management has to be done by the programmer?

No, it uses ARC so it more or less statically analyzes the code to produce the correct set of retain/release calls.

Are closures blocks? If they are first-class in Swift, then can I interrogate a block to determine its type arguments at runtime?

Speaking of type metadata, it appears that variadic functions can introspect the number and types of arguments. That leads me to believe the Swift type system is fully modern and you have full type fidelity at runtime for anything, including generics and the constraints.

Is there any reason you went with a syntax-block-ish syntax for closures instead of the fat arrow? I believe ES6 adopted the C# fat arrow as well, given the influence of those two languages I was a bit surprised to see Swift takes a different route. The positional $ params are a cute trick though.

Can I export functions to C or objects to Objective-C from Swift? And how would that manifest given the simpler type systems?

lord funk
Feb 16, 2004

Huge congrats, rjmccall! Really excited to dig into Swift.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

JewKiller 3000 posted:

It may be better than Objective-C, but from a broader perspective (comparing to all languages), I don't see the big deal here. None of the features you've mentioned in this thread were introduced in the PL literature later than the 1980s. What's so good about this new language aside from making fewer mistakes?

Heartbleed? Goto fail? is that not enough of a reason to finally admit C has got to loving go? Or do we need another "Internet-wide SSL-compromising, make every. loving. Human. On. The. Planet. change their passwords" sort of vulnerability before we admit relying on human beings to write perfect code to prevent memory corruption is completely stupid and hopeless?



Type inference, full type fidelity, and the tooling around all that should make it easier to make Xcode more helpful* and easier to debug. (*whether that happens is another matter).

Generics are excellent. The caller knows it's an array of strings, the callee creates an array of strings, but put a bird on it? Why not, Objective-C doesn't give a poo poo!

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JewKiller 3000 posted:

It may be better than Objective-C, but from a broader perspective (comparing to all languages), I don't see the big deal here. None of the features you've mentioned in this thread were introduced in the PL literature later than the 1980s. What's so good about this new language aside from making fewer mistakes?

We didn't set out specifically to appease language hipsters, nor are we submitting the language guide to POPL. I personally feel that making fewer mistakes is an admirable goal. Plenty of new languages with more interesting research pedigrees do not, in fact, succeed at making fewer mistakes.

Ultimately, it is just a programming language. Its value is as a tool, and it deserves to be judged on those merits.

ufarn
May 30, 2009
Indeed, grats on shipping.

I don't know if this is your wheelhouse, rjmccall, but do you have any plans regarding community outreach and cultivation?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

b0lt posted:

Why is the lambda syntax so weird? Why make in a keyword in the first place, instead of just using C++/java style foreach syntax?

It's not how I would have defined it, but I don't win every language design argument. I, personally, would probably just use a local func for anything that I thought was complex enough to merit a type signature.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Suspicious Dish posted:

This is a big pet peeve of mine for new projects. Do you have any internal projects using Swift yet? New apps, new frameworks, whatever? I find that a lot of these PLs sound great until you actually go to use them, because nobody actually used them in the real world yet.

I am not going to touch Swift until I hear that you have a moderately sized, going-to-production codebase written in it.

That's understandable. We have some internal things ported, and we've been actively iterating on the design for about half a year with feedback from various dogfooders, but no, we haven't, like, rewritten Mail from scratch in it or anything.

ManicJason
Oct 27, 2003

He doesn't really stop the puck, but he scares the hell out of the other team.

Ender.uNF posted:

Uhh was that a time-reversing debugger in your pocket or are you just happy to see me?

Seriously, is it recording state or using an Elm-style time-traveling debugger?

That was the impressive part of the initial demo to me, and its actual usefulness will probably determine whether I give Swift an honest shot right out of the gate.

lord funk
Feb 16, 2004

You use true and false instead of YES and NO. I liked YES and NO. :(

JewKiller 3000
Nov 28, 2006

by Lowtax

rjmccall posted:

We didn't set out specifically to appease language hipsters, nor are we submitting the language guide to POPL. I personally feel that making fewer mistakes is an admirable goal. Plenty of new languages with more interesting research pedigrees do not, in fact, succeed at making fewer mistakes.

Ultimately, it is just a programming language. Its value is as a tool, and it deserves to be judged on those merits.

Well OK, but where is Apple trying to position this language in the market? Do you expect that, like Java and C and Python, Swift will be used all over the place in many different environments... or do you see it more like Objective-C, a language that is technically just as general-purpose as the others, but in reality is used only by developers for Apple platforms? I'm not trying to push language hipster crap for its own sake, but if I don't see anything here that I can't get from languages I already know, then I'm not going to invest the time into learning a new tool.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Ender.uNF posted:

No, it uses ARC so it more or less statically analyzes the code to produce the correct set of retain/release calls.

Are closures blocks? If they are first-class in Swift, then can I interrogate a block to determine its type arguments at runtime?

All the information is there dynamically, but we don't have the language machinery to actually bind a local type variable. It's likely that what you want to do could be achieved with generics, though.

Ender.uNF posted:

Speaking of type metadata, it appears that variadic functions can introspect the number and types of arguments. That leads me to believe the Swift type system is fully modern and you have full type fidelity at runtime for anything, including generics and the constraints.

You can write a function that takes a variadic number of values of any type; they'll be passed to the function as an array. You can, of course, dynamically ask an array for its size. The empty-protocol type Any can accept arbitrary values and carries the actual type in its representation.

Ender.uNF posted:

Is there any reason you went with a syntax-block-ish syntax for closures instead of the fat arrow? I believe ES6 adopted the C# fat arrow as well, given the influence of those two languages I was a bit surprised to see Swift takes a different route. The positional $ params are a cute trick though.

I think the concern was with parsing a parameter clause in an expression context. I dunno, I disagreed with it. You can file a bug saying that you hate the syntax; maybe it'll get changed. :)

Ender.uNF posted:

Can I export functions to C or objects to Objective-C from Swift? And how would that manifest given the simpler type systems?

Yes. You just can't export something whose type is not expressible in C/ObjC.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

ufarn posted:

Indeed, grats on shipping.

I don't know if this is your wheelhouse, rjmccall, but do you have any plans regarding community outreach and cultivation?

We do, but as you say, it's not my wheelhouse.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

lord funk posted:

You use true and false instead of YES and NO. I liked YES and NO. :(

You can get them back if you feel really raw about it.

Swift code:
var YES: Bool { return true }
var NO: Bool { return false }

hobbesmaster
Jan 28, 2008

Ender.uNF posted:

Heartbleed? Goto fail? is that not enough of a reason to finally admit C has got to loving go? Or do we need another "Internet-wide SSL-compromising, make every. loving. Human. On. The. Planet. change their passwords" sort of vulnerability before we admit relying on human beings to write perfect code to prevent memory corruption is completely stupid and hopeless?



Type inference, full type fidelity, and the tooling around all that should make it easier to make Xcode more helpful* and easier to debug. (*whether that happens is another matter).

Generics are excellent. The caller knows it's an array of strings, the callee creates an array of strings, but put a bird on it? Why not, Objective-C doesn't give a poo poo!

You can write terrible, internet breaking code in any programming language. The OpenSSL team had such terrible standards that I'm sure they'd screwed up in any other language.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Every language always seems to want brevity except in upper/lowercasing string functions. Why uppercaseString()/lowercaseString() instead of just upper()/lower()? :arghfist:

nebby
Dec 21, 2000
resident mog
How does it feel to know you are about to be the recipient of the largest motherlode of bikeshedding arguments in the history of computing?

edit: Serious question, probably one you can't answer, but how is Apple positioning this for adoption internally? Are all teams going to have the option to use Swift instead of ObjC? Are certain teams already planning on moving to it for all future development? Etc. Etc. I find it a bit surprising that this got released without a flagship app already being built in it as a proof of concept.

nebby fucked around with this message at 22:13 on Jun 2, 2014

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

rjmccall posted:

The main limitation here for practical development is that we're not promising source compatibility in 1.0.

Any idea on a timeframe for a 1.0 release for those of us who want to do practical development in Swift?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JewKiller 3000 posted:

Well OK, but where is Apple trying to position this language in the market? Do you expect that, like Java and C and Python, Swift will be used all over the place in many different environments... or do you see it more like Objective-C, a language that is technically just as general-purpose as the others, but in reality is used only by developers for Apple platforms? I'm not trying to push language hipster crap for its own sake, but if I don't see anything here that I can't get from languages I already know, then I'm not going to invest the time into learning a new tool.

Swift is a fully statically-compiled language with a minimal runtime which can interoperate trivially with C and, eventually, C++. That's a language niche that we believe is very poorly filled right now. Languages with comparable expressivity to Swift overwhelmingly come attached to massive managed environments which "natively" wrap or reimplement half the operating system.

We have a very solid ABI stability design; it just didn't make the implementation cut for 1.0 because library development had to take second seat to app development. (The design is largely validated in its technical direction because it's the same implementation design that enables our generics model.)

Objective-C offers relatively little to a programmer who doesn't have a massive library of Objective-C classes to use. It's basically just a class syntax, and people can muddle through with C++.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Don't Rust and Go explore the same space?

... It's going to be "Google's Go vs. Mozilla's Rust vs. Apple's Swift" in the tech news, isn't it... sigh...

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

hobbesmaster posted:

You can write terrible, internet breaking code in any programming language. The OpenSSL team had such terrible standards that I'm sure they'd screwed up in any other language.

That's a dumb excuse and I'm sick of hearing it.

Yes, I could write bad code in any language. But a memory safe language vastly reduces the scope of existing errors and greatly limits the damage one can do. You can't write a "return 64k of random server memory every time someone asks" bug in a memory-safe language without trying extremely hard.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

nebby posted:

How does it feel to know you are about to be the recipient of the largest motherlode of bikeshedding arguments in the history of computing?

Awesome. It feels awesome.

nebby posted:

edit: Serious question, probably one you can't answer, but how is Apple positioning this for adoption internally? Are all teams going to have the option to use Swift instead of ObjC? Are certain teams already planning on moving to it for all future development? Etc. Etc. I find it a bit surprising that this got released without a flagship app already being built in it as a proof of concept.

Rewriting a flagship app is basically just introducing massive risk to the development cycle of the flagship app. That would be true even if we were just rewriting it in the exact same language as before. The language is mature enough that we've been writing some internal apps in it and are now willing to open it up for public discussion.

You're correct that I can't talk about future product cycles or internal positioning.

nebby
Dec 21, 2000
resident mog

Ender.uNF posted:

That's a dumb excuse and I'm sick of hearing it.

Yes, I could write bad code in any language. But a memory safe language vastly reduces the scope of existing errors and greatly limits the damage one can do. You can't write a "return 64k of random server memory every time someone asks" bug in a memory-safe language without trying extremely hard.
for future reference, this is a classic fallacy:

http://en.wikipedia.org/wiki/Nirvana_fallacy

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Axiem posted:

Any idea on a timeframe for a 1.0 release for those of us who want to do practical development in Swift?

I can't answer that more specifically than "I'm pretty sure it'll be this year", sorry. That is probably over-conservative.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Ender.uNF posted:

Yes, I could write bad code in any language. But a memory safe language vastly reduces the scope of existing errors and greatly limits the damage one can do. You can't write a "return 64k of random server memory every time someone asks" bug in a memory-safe language without trying extremely hard.

Nobody writes memory allocators in other languages. They're called "object pools".

nebby
Dec 21, 2000
resident mog
Oh, another question. Where did you guys come down on macros/DSLs? I haven't read any documentation yet but it sounds like there aren't any facilities to extend the language. A huge bummer coming from someone who uses RubyMotion and has seen the benefits. (Though I acknowledge that it has its downsides.)

b0lt
Apr 29, 2005

rjmccall posted:

Swift is a fully statically-compiled language with a minimal runtime which can interoperate trivially with C and, eventually, C++. That's a language niche that we believe is very poorly filled right now. Languages with comparable expressivity to Swift overwhelmingly come attached to massive managed environments which "natively" wrap or reimplement half the operating system.

We have a very solid ABI stability design; it just didn't make the implementation cut for 1.0 because library development had to take second seat to app development. (The design is largely validated in its technical direction because it's the same implementation design that enables our generics model.)

Objective-C offers relatively little to a programmer who doesn't have a massive library of Objective-C classes to use. It's basically just a class syntax, and people can muddle through with C++.

How do you interop with C trivially when there doesn't appear to be a pointer type in the language?

Toady
Jan 12, 2009

Given Apple's involvement with Clang and LLVM, I was expecting this, but not so soon.

double sulk
Jul 2, 2010

Did Scala have any level of influence on Swift? It seems like there's that kind of a vibe but it could just be me.

usdachoicemustache
Jul 15, 2012
A lot of decent decisions overall.

The treatment of dictionaries and arrays seems ripe for headaches, though. Oh you used let, that means you can't change the collection either, except you can (in some ways) if it's an array. I suspect those rules are to maintain performance or ease of bridging or something, but it seems unnatural to have that rather than allow separate specification of constant|mutable reference & constant|mutable collection.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

nebby posted:

Oh, another question. Where did you guys come down on macros/DSLs? I haven't read any documentation yet but it sounds like there aren't any facilities to extend the language. A huge bummer coming from someone who uses RubyMotion and has seen the benefits. (Though I acknowledge that it has its downsides.)

It depends on what you mean. We don't allow you to define your own true statements, and we don't have a true macro system, but you can do quite a lot of "language extension" within the existing expression syntax via generics, trailing closures, auto-closures, and custom operators.

I think we'd like a proper (hygienic, Scheme-like) macro system eventually.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

b0lt posted:

How do you interop with C trivially when there doesn't appear to be a pointer type in the language?

There's a generic UnsafePointer type, we just intentionally didn't privilege it with syntactic sugar.

double sulk posted:

Did Scala have any level of influence on Swift? It seems like there's that kind of a vibe but it could just be me.

We're generally aware of Scala, but I don't remember borrowing anything specifically from it. Frankly, I think your vibe might mostly be a "everything looks like something in Scala because Scala has no sense of shame" thing. :)

usdachoicemustache posted:

A lot of decent decisions overall.

The treatment of dictionaries and arrays seems ripe for headaches, though. Oh you used let, that means you can't change the collection either, except you can (in some ways) if it's an array. I suspect those rules are to maintain performance or ease of bridging or something, but it seems unnatural to have that rather than allow separate specification of constant|mutable reference & constant|mutable collection.

Arrays used to be a pure value type, but there was some performance panic about it at the last minute. It's likely something that we'll iterate on.

rjmccall fucked around with this message at 23:16 on Jun 2, 2014

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Why can't Any contain a function? Is there some reason not to treat functions as first class objects?

Also I didn't see anything about custom attributes but I haven't read the whole doc yet...

Just in case you were missing @ it makes an appearance, check the section on custom operators and how you define attributes. It's a drat sight prettier than __((attribute))

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Ender.uNF posted:

Why can't Any contain a function? Is there some reason not to treat functions as first class objects?

It's just a bug. We're already tracking it.

I'll mention custom operators in :siren: my talk :siren:, and I'm pretty sure they're covered in the guide, but essentially you just declare the operator somewhere in the program:

Swift code:
operator infix|postfix|prefix %%% {
  // You can skip these and Swift will just complain if you ever write this next to another binary operator.
  // associativity left|right
  // precedence some-magic-number
}
And then you define a global function with that name:

Swift code:
func %%%(a: Int, b: Int) -> (Int,Bool) {
  // whatever
}
(Advanced Swift, Thursday at 11:30)

nebby
Dec 21, 2000
resident mog

rjmccall posted:

(Advanced Swift, Thursday at 11:30)
Promise me there's at least one "A Modest Proposal" reference

haxored
Oct 7, 2003
j00 h4x0r m3
Since it was so widely publicized, Swift is probably the name Apple are sticking with. I am curious if there was much contention over the name given the existing project at http://swift-lang.org

Deus Rex
Mar 5, 2005

Suspicious Dish posted:

Don't Rust and Go explore the same space?

No. Rust emphasizes zero-cost type & memory safety and explicit memory management. Go emphasizes pragmatism and simplicity at the expense of those things. They share little in common.

Adbot
ADBOT LOVES YOU

lord funk
Feb 16, 2004

rjmccall posted:

(Advanced Swift, Thursday at 11:30)
:dance:

Stupid question for anyone: how exactly do I open the Swift Programming Language iBook in Playground?

The Swift Programming Language posted:

NOTE

For the best experience, open this chapter as a playground in Xcode. Playgrounds allow you to edit the code listings and see the result immediately.

  • Locked thread