
Swift 1.2 and Xcode 6.3 beta - glhaynes
https://developer.apple.com/swift/blog/?id=22
======
bla2
> Source files that haven’t changed will no longer be re-compiled by default

That's a nice example of "if you're not embarrassed of 1.0, you shipped too
late". 

~~~
pawelwentpawel
If this is actually going to work well - great news for bigger swift projects. 

The compile time caused by this issue was making the development process
really slow.  We had to split the whole application into mini sub projects to
make it bearable. 

------
beltex
_" The number of crashes in the swift-compiler-crashes project shrank -83 %
with today's release of Xcode 6.3b.  Thank you Swift engineers! :-)"_ 

[https://twitter.com/practicalswift/status/564921024782041088](https://twitter.com/practicalswift/status/564921024782041088)

[https://github.com/practicalswift/swift-compiler-
crashes/com...](https://github.com/practicalswift/swift-compiler-
crashes/commit/f6da30450923afbc313fbcac16a5367c3f88aec3)

------
ruddct
Awesome, the ability to unwrap multiple optionals on one line should be
bolded, underlined and all caps at the top of this article.  Seriously though,
this is an everyday pain point that happens all the time when writing Swift. 
Glad Apple is listening to developer feedback on this stuff. 

Translation for those unfamiliar with Swift: Swift has a relatively strong
type system.  If a variable in Swift can be null at any point, it must be
explicitly declared so as part of its type (e.g. an integer that can be null
has the type "Int?",  an integer that cannot be null has the type "Int"). 

Swift has a way to 'unwrap' these optional values and do things with them if
they exist.  Prior to this release, unwrapping multiple optional things
required a bunch of nested if statements.  With this release, unwrapping
multiple optional values can be done in one if statement. 

~~~
archagon
If let (and optionals in general) is my favorite Swift feature and has
immediately made my code 10x more stable from the get-go.  Glad to see it get
expanded like this. 

~~~
WildUtah
if-let is great.  I don't know where it started (apparently upthread they say
Rust and swift have been swapping the idea) but Clojure has had it since
2008.[0]

    
    
        (if-let [name name-whose-value-is-possibly-null]
          (something-to-do name))
    

[0] [https://clojuredocs.org/clojure.core/if-
let](https://clojuredocs.org/clojure.core/if-let)

~~~
loqi
C++98 (maybe earlier) has a similar feature:

    
    
        if (mytype* p = find_or_null(blah))
            foo(*p);
    

Still have to dereference p, but at least it's only in scope when doing so is
safe.  Also goes well with auto and std::optional:

    
    
        if (auto opt = find_or_none(blah))
            foo(*opt);

------
sbilstein
Coming to Swift as a Scala developer I really enjoy using the language.  While
it lacks the functional completeness of other functional languages I like
writing it, it's specific set of features is very handy and easy to pick up.  I
think Apple did a great job building a pragmatic language that gives people
good constructs and lets them get their jobs done rather quickly.  I'm looking
forward to Swift on Xcode stabilize and mature. 

------
npalli
This is so strange.  Right now we have

iOS 8.2 beta and 8.3 beta

XCode 6.2 beta and 6.3 beta

How is the release cycle going to work?  When will 8.2 and 8.3 come out and
which is more stable for Swift work. 

~~~
mikeash
Xcode 6.2 basically only exists for the Apple Watch.  I think iOS 8.2 is
similar, but I'm less familiar there.  Xcode 6.2 has no significant Swift
changes that I'm aware of, so if you're just looking at Swift, you should
either use the latest public 6.1 release, or the 6.3 beta to get the newer
stuff.  The release timing will presumably be that .2 comes out with the watch
whenever that ends up being, and .3 will be a bit later. 

~~~
npalli
Thanks. 

------
DaNmarner
This might be easily overlooked: optional has been introduced (back-ported?) 
to Objective-C in the form of nullability annotation! 

~~~
oleganza
Not exactly.  ObjC code cannot usefully benefit from those annotations (yet? 
more likely ever).  At most, it's good for documenting your ObjC code for
fellow readers.  The actual use appears in the Swiftland where instead of
implicitly unwrapped optionals you get proper explicit optionals or explicit
non-optionals. 

~~~
ejdyksen
The benefit to working with the Cocoa APIs will be immense, though. 

I assume that, now that this feature exists, Apple will begin annotating their
Obj-C APIs. 

~~~
oleganza
They already started doing it a few months ago with private annotations.  This
"nonnull"/"nullable" syntax is a result of their work on annotating Cocoa
APIs. 

~~~
eridius
They've been doing it for a while in the Swift overlay module.  I'm really
happy that this is officially added to obj-c because it provides very valuable
API documentation, even if it won't have much practical effect on the code. 

------
melling
This is practical.  It's something you wish for within a couple hours of Swift. 

let x : SomeThing

if condition {

    
    
       x = foo()
    

} else {

    
    
       x = bar()
    

}

use(x)

~~~
bigdubs
short of having a language mechanism for doing an 'uninitialized' let,
conditional operators could work:

let x : Something = condition ?  foo() : bar()

but yeah, it would be nice to defer initialization of an immutable. 

~~~
LinaLauneBaer
often times you want to do more stuff in either case so ?  does not always
work.  The if-else approach is more general. 

~~~
matt_kantor
You could also do this:

    
    
        let x: Something = {
          if condition {
            someSideEffect()
            return foo()
          } else {
            anotherSideEffect()
            return bar()
          }
        }()
    

But it's kind of ugly. 

~~~
masklinn
Sad that Swift doesn't use an expressive if, then you could just write:

    
    
        let x: Something = if condition {
            // do stuff
            foo()
        } else {
            // do other stuff
            bar()
        }

~~~
0942v8653
That's something I really miss in other languages—the ternary operator is just
not good enough for when you have a condition like this.  In lisp it's 3 lines
which is just the right amount when in other languages you have 6 lines (and
until now unnecessary mutability) or only one. 

------
lerno
This is the release that makes you go "people were insane to think that Swift
1.1 was anything near usable". 

------
chakrit
The type inferrence fix ("Type inference for single-expression closures has
been improved in several ways:") is the most annoying one for me.  Glad they've
fixed it.  Sure, compiling faster and having less crashes is nice.  But that
means nothing if it isn't compiling _correctly_. 

------
Osmium
Really happy to see this, was worried we'd have to wait for WWDC for further
improvements.  For me personally, it's nice to see Swift support for GLKMatrix
and GLKVector now, which was an issue I just ran into just a few weeks ago. 

------
NeoProgramming
How about opening Swift compiler source code (and porting it to other
platforms?)  And, what are the OS requirements for xcode 6.3?  Is it possible to
install it to old macosx system (snow leopard, for example)? 

~~~
sigzero
Stop it with the "open and porting".  They are not going to do it. 

~~~
oleganza
I'm not so sure.  Chris Lattner was giving some hints around Twitter on how big
deal they want to make out of Swift (that is, a ubiquitous systems program). 
This gives me hope that it'll become open as Clang and ported to other
platforms. 

~~~
notsony
Just like FaceTime.  It won't happen and all the rumors and gossip based on a
few comments will just give false hope to people.  Swift was designed to lock-
in developers just when objc<->java converters were gaining popularity. 

~~~
matthewmacleod
My understanding is that FaceTime was not opened up more due to the VirnetX
lawsuit, and the subsequent redesign that meant all video streams were proxied
through Apple servers. 

So, I think it's more complex than you're admitting. 

~~~
k-mcgrady
>> "My understanding is that FaceTime was not opened up more due to the
VirnetX lawsuit"

First I've heard of this.  Glad there was actually reasoning behind not making
it open as promising that and then going back on it without telling anyone why
was very strange. 

------
frewsxcv
Why is being logged-in required to view the Release Notes? 

~~~
eddieroger
Because Apple chooses to only give access to betas and their release notes to
registered developers. 

~~~
frewsxcv
How does that benefit Apple? 

~~~
ChrisLTD
For Yosemite they did an open beta:
[https://appleseed.apple.com/sp/betaprogram](https://appleseed.apple.com/sp/betaprogram)

But in that case, it makes sense to get bug reports from non-developers. 

~~~
LeoNatan25
Still, as I remember, the release notes were still only presented to
developers. 

------
k-mcgrady
Glad enums now work correctly with Objective-c.

