Aren't the interfaces-as-generics constraints also from c#? It seems to be c# more than anything else.
The language seems more closer to F# than C# to me. It's all good though!
61–70 of 88 posts
Aren't the interfaces-as-generics constraints also from c#? It seems to be c# more than anything else.
The language seems more closer to F# than C# to me. It's all good though!
"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…
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.
- How about Garbage Collection?
- Many mentions to "type inference", is it then a statically-typed language? Or is it hybrid?
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 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.
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.
Link: https://itunes.apple.com/us/book/the-swift-programming-langu...
Hope it helps.
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?
- 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.
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.
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.