Live data from Hacker News

Swift – observations from Rust’s original designer

graydon2.dreamwidth.org

61–70 of 88 posts

Re: Swift – observations from Rust’s original designer

#61
post #2

Aren't the interfaces-as-generics constraints also from c#? It seems to be c# more than anything else.

One of the Swift developers is a former F# dev:

https://twitter.com/jopamer

The language seems more closer to F# than C# to me. It's all good though!

Re: Swift – observations from Rust’s original designer

#62
post #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…

This is what annoyed me most about the whole Swift presentation. Swift is not in any way shape or form innovative, in terms of language features or design. It is however, another language that aims to be as productive as possible, while still being safe, like Java, C#, Rust, Go etc.

It'd be far more interesting to compare it to them (especially where they have bindings for iOS e.g. Java, C#) in terms of productivity, code maintainability, readability etc, instead of in terms of language features.

Re: Swift – observations from Rust’s original designer

#64
post #24

What are the distinctive features of Rust that Swift has that aren't in some way derived from ObjC? (I'm sure there are some; I just don't know Rust.)

I think graydon is reaching here, while there may be some intersection of features in Rust and Swift, I don't really see any Rust influence at all.

Re: Swift – observations from Rust’s original designer

#65
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.

Bleah, Rust's println makes my eyes bleed.. What's didn't you do 'println!("x value={x}");'?? Yes, I know you can use 'println!("x value={u}",u=x);', it still isn't a good syntax IMHO.

Re: Swift – observations from Rust’s original designer

#66
post #11
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…

You only have to be a paid developer to get the beta of XCode; once it comes out of beta, it'll be available on the Mac App Store for free. That said, it'd be nice to see Swift get open sourced at some point.

I'm afraid that it's going to be tied too tightly to the Cocoa Runtime to make opening the language up feasible without also opening Cocoa up.

Re: Swift – observations from Rust’s original designer

#68
post #63

Couple of things that are still not clear to me, even when people keep saying that it's similar to C#: - How about Garbage Collection? - Many mentions to "type inference", is it then a statically-typed language? Or is it hybrid?

- Garbage Collection is handled via reference counting and ARC. No automatic cycle detection, the programmer has to manually track and resolve reference cycles. Same as using ARC in Objective C.

- It is a statically typed language. Type inference is the same mechanism as is used in C++11 with the auto keyword. Basically, anywhere the compiler can "guess" the type, you don't have to be explicit about it. Unless you want the variable to have a different type from the inferred type, that is.

Re: Swift – observations from Rust’s original designer

#69
post #66
post #11

Earlier quoted context omitted.

You only have to be a paid developer to get the beta of XCode; once it comes out of beta, it'll be available on the Mac App Store for free. That said, it'd be nice to see Swift get open sourced at some point.

I'm afraid that it's going to be tied too tightly to the Cocoa Runtime to make opening the language up feasible without also opening Cocoa up.

I don't think so. It seems to me that they did a good job on the interface between Objective-C and Swift, so one could perfectly live without the other. Objective-C constructs are exposed as native Swift constructs.

Re: Swift – observations from Rust’s original designer

#70
post #66
post #11

Earlier quoted context omitted.

You only have to be a paid developer to get the beta of XCode; once it comes out of beta, it'll be available on the Mac App Store for free. That said, it'd be nice to see Swift get open sourced at some point.

I'm afraid that it's going to be tied too tightly to the Cocoa Runtime to make opening the language up feasible without also opening Cocoa up.

If they open sourced the compiler then maybe you could link against GNUstep on other platforms.
Post reply on HN