There's been a lot of prior discussion about Swift on HN. I think the general consensus is that it's a fun and somewhat-well designed language that's buggy in places but will eventually make a good Objective-C replacement. I personally have enjoyed playing around with it. If Apple open-sources it, I could see using it as my main language (to replace Java, which I hate).
Swift can call Objective-C APIs, so if you're building Mac or iOS apps, you'll get access to the full Cocoa API. You can't build iOS apps in Scala (as far as I know) and I've never been a fan of Java GUIs.
If you want a strong resemblance, Swift looks spookily like Groovy - to the point where I have to actually check sometimes that I'm not reading Groovy code. I would say much more so than Scala.
let maximumNumberOfLoginAttempts = 10 // let keyword
var currentLoginAttempt = 0 // var keyword
var welcomeMessage: String //type postfixed after colon
if turnipsAreDelicious { // no parens around if-condition
println("Mmm, tasty turnips!")
}
let http404Error = (404, "Not Found") //tuple
println("The status code is \(statusCode)") //interpolated string uses \( ... )
I don't think the syntax looks like Groovy at all!
Yup. Everyone has different needs from their code, an mine primarily needs to run on Linux despite often working on it in OS X. Ruby does that beautifully now. I can't see spending time on Swift until it runs across Unix flavors. That seems quite possible in principal since Swift relies on LLVM.
Comments
There's been a lot of prior discussion about Swift on HN. I think the general consensus is that it's a fun and somewhat-well designed language that's buggy in places but will eventually make a good Objective-C replacement. I personally have enjoyed playing around with it. If Apple open-sources it, I could see using it as my main language (to replace Java, which I hate).
Why wait? There's already a language that bears a strong resemblance to Swift and it even has Java interop baked in. That would be Scala.
Swift can call Objective-C APIs, so if you're building Mac or iOS apps, you'll get access to the full Cocoa API. You can't build iOS apps in Scala (as far as I know) and I've never been a fan of Java GUIs.
Just compile to native code using an AOT compiler like RoboVM.
I want to get away from the JVM
Same here. I want to get away from Java and the JVM. Twenty years old and now owned by Oracle.
Mind if I ask why?
These are probably not very good reasons, however:
-It's slow
-It's annoying for testing
-It's run by Oracle
-It feels antiquated
If you want a strong resemblance, Swift looks spookily like Groovy - to the point where I have to actually check sometimes that I'm not reading Groovy code. I would say much more so than Scala.
The examples on the first page of the documentation ( https://developer.apple.com/library/prerelease/mac/documenta... ) are:
I don't think the syntax looks like Groovy at all!Yup. Everyone has different needs from their code, an mine primarily needs to run on Linux despite often working on it in OS X. Ruby does that beautifully now. I can't see spending time on Swift until it runs across Unix flavors. That seems quite possible in principal since Swift relies on LLVM.
Why bother when OCaml and Haskell already have more compilers to choose from?