Live data from Hacker News

Swift – observations from Rust’s original designer

graydon2.dreamwidth.org

51–60 of 88 posts

Re: Swift – observations from Rust’s original designer

#51
post #9
post #3

He seems to generally like it -- similar to Rust in a lot of ways, but a little higher-level, which is appropriate for its intended uses (iOS and OS X apps). He nor I seem to think that it can replace Rust (especially if they don't open it up!), but it definitely seems like a compelling option. EDIT: Does anyone know if it's possible to try it without a paid iOS / OS X dev license? I'd especially like to try the play…

I don't know that there is much question of replacing Rust when it isn't in use except as an unstable experiment with a lot of interest. You could replace Rust with outright vaporware.

Rust is not vaporware under any reasonable definition of that word; there is plenty of Rust there to run. It is not stable yet, to be sure; but there are plenty of people happily using it, some even in production.

Re: Swift – observations from Rust’s original designer

#52
post #40

Earlier quoted context omitted.

They haven't publicly released it yet. Xcode 6 which includes Swift is currently part of the beta available as part of the Apple Developer Program. That means it is still under NDA as well. Most likely after Xcode 6 is released publicly (i.e. available on the Mac App Store) they will do a code dump back to the LLVM project.

> That means it is still under NDA as well. Partially. They made the language manual freely available on the iBookstore.

I'll grant you that. The compiler/llvm/clang parts of it though are still under NDA.

Re: Swift – observations from Rust’s original designer

#53
post #47

He doesn't seem to know much about iOS or Objective-C due to that comment about parameter names probably being unused. You wouldn't be able to make meaningful method selectors calling into the code from Objective-C without them, since the names of the parameters are part of the method name in Objective-C.

Method parameter names are used similarly in Swift as in ObjC. For example two methods can have the same name, as long as they have a difference set of parameters. For example: func methodName(paramName: String) and func methodName(paramName: String, otherParam: Int) are different. I'm still playing with this but there are some interesting/weird things in here. What follows is a bunch of random observations of how na…

> and there doesn't seem to be a way to define optional method parameters

Did you miss the part about default values?

If you're calling an Objective-C selector with more than one argument, you are indeed using an external parameter name, but external parameters are explicitly not required if you're writing pure Swift.

https://developer.apple.com/library/prerelease/ios/documenta...

Re: Swift – observations from Rust’s original designer

#54
post #21
post #6

Earlier quoted context omitted.

How much cleaning up do you expect at this point? It's already both announced and released to developers. Obviously it's not 100% finished, but if they intended to open-source it, I wouldn't expect that announcement to come after publicly releasing it.

They did announce they would not guarantee source compatibility until after the release date. So the language will likely change a bit still.

And promised converters for any source changes necessary. I expect it'll be similar to the Convert to ARC and Objective-C Literals Menu items in Xcode.

Re: Swift – observations from Rust’s original designer

#55

I think the author is seeing a little more than there actually is. There is a lot more overlap between Swift and C#/Java than with Rust. Actually, I see very little Rust in Swift, except for very trivial features that are present in 90% of C-based languages. But hey, any opportunity to pimp your favorite language is fair.

It is common when a new language appears to authors to see similarity with their own language. Actually, most of the features of Swift were already implemented in some older language. Extended pattern matching for example exists in Scala.

Re: Swift – observations from Rust’s original designer

#57

I think the author is seeing a little more than there actually is. There is a lot more overlap between Swift and C#/Java than with Rust. Actually, I see very little Rust in Swift, except for very trivial features that are present in 90% of C-based languages. But hey, any opportunity to pimp your favorite language is fair.

It is common when a new language appears to authors to see similarity with their own language. Actually, most of the features of Swift were already implemented in some older language. Extended pattern matching for example exists in Scala.

... and in many other languages way before scala.

Re: Swift – observations from Rust’s original designer

#58
post #13

I hope ideas will flow the other way too, and Rust adopts some sugar from Swift. I find `if let concrete = optional` sooo much nicer than `match optional { (concrete) => , _ => {} }`. Rust has solid semantics that covers more than Swift. OTOH Apple has put their UX magic into the language's syntax. Some syntax shortcuts, like `.ShortEnumWhenInContext` are delightful. The two combined will be the perfect language ;)

You could always write this yourself with a macro:

    macro_rules! if_let {
      ($p:pat = $init:expr in $e:expr) => {
        { match $init { $p => $e,_  => {}, } }
      }
    }

    fn main() {
      let tup = (2, 3);
      if_let!{(2, x) = tup in println!("x={}", x)}; // prints x=3
      if_let!{(5, x) = tup in println!("x={}", x)}; // doesn't print
    }
It's slightly more heavyweight, but still not too bad.

Re: Swift – observations from Rust’s original designer

#59
post #6
post #5

Earlier quoted context omitted.

I wouldn't be surprised if Apple ends up open sourcing Swift after it cleans it up, perhaps even making it an LLVM project. I see it similarly to how they handled their own AArch64 backend -- proprietary at first, but mostly for secrecy before it was announced and then merging it with the preexisting backend after it was announced.

How much cleaning up do you expect at this point? It's already both announced and released to developers. Obviously it's not 100% finished, but if they intended to open-source it, I wouldn't expect that announcement to come after publicly releasing it.

I agree open sourcing this would be the logical move and maybe even open up its usage outside the iOS/OS X ecosystem long term, which would be in the best interests of Apple, but it's not ready for production use yet - from their announcement page:

And when iOS 8 and OS X Yosemite are released this fall, you can submit apps that use Swift to the App Store and Mac App Store.

This is intended as a beta, and they won't even allow you to use it in production yet, even if you wanted to, so you can expect some small changes to the language spec as they refine it. Typically the xcode betas can't be used to submit, and Apple have released other projects closed source before open sourcing them (for example webkit).

It's interesting that they're moving development on both platforms to this new language. I wonder when we'll see a unified API?

Re: Swift – observations from Rust’s original designer

#60
"Protocols get to play double duty as either concrete types (in which case they denote a reference type you can acquire with as from any supporting type) and as type constraints on type parameters in generic code. This is a delightful convenience Rust stumbled into when designing its trait system and I'm glad to see other languages picking it up. I'm sure it has precedent elsewhere." - C# again.

PS: Apple says "Swift is an innovative new programming language"! Just like everything else they do lately!

Post reply on HN