26 ms·
Introducing Swift
- pw 12y agoLooks neat, but I'm disappointed that Apple didn't go with Ruby for their next-generation language. Things like MacRuby and Ruby Motion make it seem like that was a possibility, albeit a pretty distant one.
- 3rd3 12y agoHopefully there are some of Bret Victor’s "lost" ideas in there: http://worrydream.com/Apple/ http://worrydream.com/Apple/
- skizm 12y agoSo is swift an extension of c like obj-c is? In theory, can I have a program/app that uses swift, obj-c, and c syntax all in the same file?
- ff10 12y agoSame project, not mixed in files.
- Udo 12y agoAs someone who always disliked Objective C, I think Swift looks very promising. I'll check it out right away :) Software-wise, I feel these current WWDC announcements are the most exciting in years. Looking at the Swift docs right now, I can see many interesting inspirations at work: there's some Lua/Go in there (multiple return values), some Ruby (closure passed as the last argument to a function can appear immediately after the parentheses), closure expressions, strong Unicode character support, a very very neat alternative to nullable types with "Optionals". Operators are functions, too. It has the concept of explicitly capturing variables from the surrounding context inside closures, like PHP does, instead of keeping the entire context alive forever like Ruby or JS. Hell there is even some shell scripting thinking in there with shorthand arguments that can be used as anonymous parameters in closures, like "sort(names, { $0 > $1 } )". Inside objects, properties can be initialized lazily the first time they're accessed, or even updated entirely dynamically. Objects can swap themselves out for new versions of themselves under the caller's nose by using the mutating keyword. There is the expected heavy-weight class/inheritance scheme which accommodates a lot of delegation, init options, bindings, and indirection (as is expected for a language that must among other things support Apple's convoluted UI API). But at least it's syntactically easier on the eyes now. Automated Reference Counting is still alive, too - however, it's mostly under the hood now. Accordingly, there is a lot of stuff that deals with the finer points of weak and strong binding/counting. Swift has a notion of protocols which as far as I can tell are interfaces or contracts that classes can promise to implement. I think generally there are a few great patterns for method and object chaining, function and object composition in here. The language has C#-style generics, and supports interesting type constraint expressions.
- seanalltogether 12y agoHe mentioned the desire to drop the "C" from objective-c, but I'm curious what this means for using c/c++ libraries now. Do they need to be wrapped by objective-c before being visible in swift?
- FreezerburnV 12y agoIt seemed like it could interoperate with C just fine based on the slide talking about all three. Also because it uses the Objective-C runtime and compiles to native, it might just see C functions as normal functions. Though what little I've looked at the free book hasn't given me any hints about that yet.
- Udo 12y agoI suspect that as long as it compiles to LLVM, anything goes.
- quonn 12y agoSwift uses a special "bridging header" to expose Objective-C code to Swift. This header will presumably be processed by the Swift compiler. In the other direction, XCode will automatically generate an Objective-C header to expose your Swift code to Objective-C.
- outworlder 12y agoThe ibooks guide references a "Using Swift with Cocoa and Objective-C" document. Is that where you got your information?
- deleted 12y ago[deleted]
- eevilspock 12y agohttps://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/index.html https://developer.apple.com/library/prerelease/ios/documenta... For discussion: https://news.ycombinator.com/item?id=7837468 https://news.ycombinator.com/item?id=7837468
- pat2man 12y agoGoing to get confused with http://swift-lang.org/ http://swift-lang.org/
- anilmujagic 12y agoAnyone have any links or resources?
- moinnadeem 12y agoHere you go: https://itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11 https://itunes.apple.com/gb/book/swift-programming-language/...
- bobz 12y agoAnybody have any reference to language docs?
- paperwork 12y agoSupposed to be on ibooks
- moinnadeem 12y agoHere you go: https://itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11 https://itunes.apple.com/gb/book/swift-programming-language/...
- scotth 12y agoUgh, not available in Canada. Way to kill my excitement, Apple. Edit: Canadian link worked! Sorry Apple.
- adregan 12y agoDoes this one work for Canada? https://itunes.apple.com/ca/book/swift-programming-language/id881256329?mt=11 https://itunes.apple.com/ca/book/swift-programming-language/...
- InnocentB 12y agoNote: replace "gb" in the URL with your country as appropriate.
- deleted 12y ago[deleted]
- Jtsummers 12y agoYour other post is dead, just FYI. The filters will kill duplicate posts from the same user (within a time period?)even if under different threads.
- conorh 12y ago
- akras14 12y agoCan anybody find a link to the Swift guide that they mentioned in Keynote? All I see is Taylor Swift books.
- deleted 12y ago[deleted]
- chrisrhoden 12y agoThis appears to be a different swift.
- ashearer 12y agoIt turns out that this is a different language. Apple overloaded the name "Swift".
- agumonkey 12y agobest part, one of this swift's authors is called wozniak https://webcache.googleusercontent.com/search?q=cache:Qvltqf6POLoJ:swift-lang.org/papers/SwiftLanguageForDistributedParallelScripting.pdf+&cd=1&hl=fr&ct=clnk https://webcache.googleusercontent.com/search?q=cache:Qvltqf...
- rsynnott 12y agoIt's traditional: http://en.wikipedia.org/wiki/Go!_(programming_language) http://en.wikipedia.org/wiki/Go!_(programming_language)
- outworlder 12y agoIs that the same language? It looks completely different.
- judofyr 12y agoWrong language.
- deleted 12y ago[deleted]
- outworlder 12y agoOk, what about runtime support for older devices/iOS versions? They didn't say anything about it.
- serg_chernata 12y agoThey mentioned complete compatibility with C so it sounds like it should be ok.
- k-mcgrady 12y agoThey said that they were accepting apps built with Swift for iOS 8 and OSX 10.10 so sounds like it won't work with older OS version. They weren't all that specific about it though so I could be wrong.
- chenzhekl 12y agoNew language runs on Obj-C runtime. Maybe apps written in Swift can run smoothly on existing OS.
- curmudgeon224 12y agoPerhaps the bridging to all the Cocoa libs won't be supported pre iOS8
- wvenable 12y agoThe keynote says it uses the Objective-C runtime and it compiles to native code -- so one would imagine that it's compatible with older devices and versions. But that is no guarantee.
- IneffablePigeon 12y agoNot sure. They said apps with Swift code would be accepted once iOS 8 was released, so possibly not.
- mantrax5 12y agoIt'll be available for all devices supported by iOS 8, so going back to iPhone 4S. The runtime of Swift is also the runtime of Objective-C, but the runtime might need some upgrades to fully support the Swift semantics in a safe manner. EDIT: Correction. It's available also on iOS 7. Just confirmed by Apple. Great :)
- jasonvolpe 12y agoLogo looks a lot like a hammer and sickle.
- houshuang 12y agoThe live REPL is totally out of Bret Victor, very impressive.
- enen 12y agoThat. Was. Awesome. Totally Bret Victor type of stuff. I was just meaning to play with Light Table but as an iOS developer.. oh my god.
- chrisdevereux 12y agoBret Victor used to work in R&D at Apple, so that probably isn't a coincidence
- Osmium 12y agoFirst thing I thought. I wonder if Bret had any input into this? Very happy to see his ideas in a production environment anyway.
- justinhj 12y agoCheckout Scala worksheets (Eclipse and IDEA) and LightTable too.
- jerdavis 12y agoYeah.. Because Scala doesn't have a metric ton of problems. AVOID!
- 12y ago
- kunstmord 12y agoOh God, they just compared the speed of Objective C, Swift and... Python! It's nice to see Swift being faster than Objective C, etc., but what has Python got to do with coding native iOS/OS X apps? Of course it's going to fail at speed when compared to a static compiled language. What a weird and pointless comparison, imo (I mean the inclusion of Python, seems so random to me).
- stcredzero 12y agoI mean the inclusion of Python, seems so random to me It's supposed to be a "mainstream" scripting language. Also, it's an easy way for them to get favorable numbers for their presentation.
- kunstmord 12y agoYes. But what has that got to do with writing native apps?
- stcredzero 12y agoIt has everything to do with modern languages with powerful features.
- mitchty 12y agoNothing. Don't look too far into it. They probably just used python as an example of something most people would know. Its probably the most known scripting language out there so why not use it. Besides ALL benchmarks are pointless, even when you have the source of the benchmarks and know what they ran on software/hardware wise.
- freehunter 12y agoOn the Ars liveblog, I didn't see any mention of Swift support for other platforms. Are we going to see Swift on Linux and Windows as well?
- stcredzero 12y ago
- yconst 12y agoThis is massive.
- malandrew 12y agoLooks like they've learned a lot from Haskell (but with none of the parts of Haskell that force you to construct things purely). Looking forward to the Lambda the Ultimate discussions on this new language.
- LoneWolf 12y agoNow where to read some code examples, they may say its better but until I read some code I remain unconvinced (still anything sounds better than Objective-C)
- sidcool 12y agoSwift was the biggest announcement today. Looking forward to it.
- nlh 12y agoI'm not even an iOS developer but this is by far the most exciting thing I heard in the keynote. As an amatuer/hobbyist programmer who's self-taught with Ruby, JavaScript, etc., the one thing that was keeping me from experimenting with iOS apps was Objective-C. I know I could tackle it, but it's been hard to take the plunge. I don't know much about Swift yet, but from what I've seen it looks very exciting. So if Apple's goal was to get new devs into the iOS world, at least from 10k feet, it's working. I'm excited!
- dfc 12y ago> So if Apple's goal was to get new devs into the iOS world, at least > from 10k feet, it's working They just announced Swift, at a conference for Apple developers, with live streaming that is only easily accessed from an ios device. I think it is probably premature to pop the corks and celebrate the efficacy of the get new developers initiative.
- tylermac1 12y agoHow else are they supposed to announce it? It's simply that, an announcement. People are talking about it now and there's info on the Apple site. I see this as a huge push forward for new developers.
- stonemetal 12y agoThe announcement was fine, it is the "its working" part that is odd considering it is less than a day old. Let's see if it actually attracts new developers before we declare it a mighty success.
- mtrimpe 12y agoWell; based on the promise of immediate inclusion in the app store and a very well thought out book about the language available for free I'd say they're doing rather well so far already.
- dfc 12y ago
- Jordan15 12y agoGreat!!!!! i never liked Objective-C anyways
- kondor6c 12y agoWhat kind of benchmark produced 220 times something faster than Python? My guess is that they did it on a mobile device and used an application like this: https://itunes.apple.com/us/app/python-2.7-for-ios/id485729872?mt=8 https://itunes.apple.com/us/app/python-2.7-for-ios/id4857298...
- stcredzero 12y agoWhat kind of benchmark produced 220 times something faster than Python? Python and Ruby are resource profligate dynamic languages in comparison to other dynamics langs like Lua and Smalltalk. If you are surprised that someone could come up with a benchmark that disadvantages Python by a factor of 200, then you have a lot of neat reading to look forward to in language implementation and Python internals. For some reason speed is easy for our reptilian brains to grasp at. It's not the be-all end-all of a language.
- GFK_of_xmaspast 12y agoIf you're doing anything at all computational (that doesn't fit into the numpy/etc solution spaces), it's pretty easy to get those kinds of speedups.
- rsynnott 12y agoEh, something on that magnitude is certainly doable: http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=all&lang=gcc&lang2=python3&data=u64q http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t... Python's pretty slow.
- plainOldText 12y agoSwift has also pattern matching which I think is really awesome.
- vladimirralev 12y agoYes. They even have ranges in the patterns inside tuples. Not sure if any other language has that particular syntax.
- MichaelGG 12y agoF# has that. And also allows you to define your own constructors to pattern match on anything you want.
- AlexanderDhoore 12y agoThis is its greatest feature if you ask me... Imperative, classical OO language WITH pattern matching. It's a crazy world we live in.
- juliangamble 12y agoYou can see the pattern matching inspiration was from Clojure: https://twitter.com/jckarter/status/473557476302802944 https://twitter.com/jckarter/status/473557476302802944 https://twitter.com/jasonyeojs/status/473562520930635776 https://twitter.com/jasonyeojs/status/473562520930635776
- kclay 12y agoMaybe I'll pickup iOS dev, do you still have to have an mac to dev?
- tim333 12y agoIn my experience it's hard work without a mac.
- octopus 12y agoYes, you need a Mac, especially if you want to be able to use Xcode and Swift. If you are short on money, you can try to buy a second hand iMac or a MacMini (just be sure it will support the next OS X version 10.10).
- burningion 12y agoYou do need to have a Mac to do dev, although you can go the Hackintosh route. I just built one using tonymac86's guide. There are a few gotchas, but it just basically works, and can be a good way to get started without buying something brand new.
- arenaninja 12y agoI'm facing the same entry barrier. I am considering buying the hardware for it at this point
- stcredzero 12y agoThe demo from the WWDC keynote is quite impressive. Unfortunately, this site seems to have been slashdotted. (Basically, Swift is "Apple acquires their own LightTable.") It's touted as a language for parallelism. I'm curious about its concurrency primitives. Since distribution is shown as a top feature, I'm going to guess that it has an Erlang-like actor model. Having ARC and not needing GC will end up being a big fundamental advantage for its parallelism story. (The problem with GC, is that one thread does work, then a GC thread comes along and possibly causes an additional cache miss.)
- rayiner 12y agoSwift doesn't seem to have anything to do with the parallel language at swift-lang.org. In any case, reference counting is disastrous for the parallelism story. GC thread coming along and causing an additional cache miss is way better than having to do atomic operations on reference counts all the time.
- stcredzero 12y agoSwift doesn't seem to have anything to do with the parallel language at swift-lang.org. Whoops. Should've corrected that when I copied the comment over. In any case, reference counting is disastrous for the parallelism story. GC thread coming along and causing an additional cache miss is way better than having to do atomic operations on reference counts all the time. Why are atomic reference counts necessary? You wouldn't generally need them with an Erlang-like Actor model or for special concurrency primitives like Go channels. (That is to say, you'd only need them in the special mechanisms.)
- pcwalton 12y agoI'm not sure you can be Objective-C compatible without a shared heap. If you have a shared heap, you need atomic reference counting.
- stcredzero 12y ago
- clebio 12y ago"...we wondered what we could do without the baggage of C." Is that tongue in cheek? It's not even a particularly large, encumbered language, C.
- stormbrew 12y agoIt is when you have to maintain compatibility with it in your new shiny language that's based on it. C alone may not be particularly large or encumbered (though it does have that vexing parse), but as the foundation of other languages it can cause problems.
- mkremins 12y agoI suspect they were referring more to the syntactic baggage in Objective-C – which is at least partially a result of the fact that ObjC was originally implemented as a simple C preprocessor. To avoid syntactic conflicts with C, ObjC uses lots of weird syntactic constructs that contribute to the language's characterization as ugly. A good example is the liberal use of the @ character to denote ObjC literals – even in front of strings and numbers, because raw C strings/numbers have different semantics and won't play well with the standard ObjC APIs.
- clebio 12y agoThat's good context, thanks. When I dabbled in Objective-C, I found the excessive bracketing strange. Thanks for the background.
- stcredzero 12y agoIs that tongue in cheek? It's not even a particularly large, encumbered language, C. This would make a lot more sense if you knew about the history behind Objective-C. http://en.wikipedia.org/wiki/Smalltalk http://en.wikipedia.org/wiki/Smalltalk
- clebio 12y agoThat's a good point, thank you!
- kudzoo 12y agohttps://developer.apple.com/swift/ https://developer.apple.com/swift/
- sloankev 12y agohttps://developer.apple.com/swift/ https://developer.apple.com/swift/
- basilbthoppil 12y ago"When Apple announced Swift at WWDC, it got the largest cheer out of the developer audience than any other single feature." :D Sigh of relief!
- octopus 12y agoThis is probably the biggest announcement from a developer perspective. Swift looks like a language in which you can code as fast as you code in languages like Ruby or Python, while having the speed and performance of a language like Objective-C.
- deleted 12y ago[deleted]
- Freaky 12y ago> language website: http://swift-lang.org/ http://swift-lang.org/ Nope, completely different. Really scummy of Apple to just nick the name of an existing language for their new one, it's been five minutes and people are already confused.
- sathyabhat 12y agothat site's not related to Apple's Swift language
- rqebmm 12y ago“You also don’t need to write semicolons at the end of every statement.” Please. Please. PLEASE don't be whitespace delimited!
- gberger 12y agoRuby doesn't have neither semicolons nor whitespace syntax
- andybak 12y agoOh. I was rather hoping it would be! But still, there's not a lot to hate. It looks like a cleaner javascript at first glance. Not quite as pretty as Python but then, what is. :)
- patrickmay 12y agoCommon Lisp.
- dom96 12y agoTry Nimrod: http://nimrod-lang.org http://nimrod-lang.org
- tim333 12y agoYou're ok. It's {}
- stcredzero 12y agoPlease. Please. PLEASE don't be whitespace delimited! One of the prime examples I give for how HN/reddit has gone downhill was being downvoted by some clueless hipsters for suggesting that it would be easy to cross-compile from a whitespace-delimited language to a non-whitespace-delimited one. It's not some kind of huge fundamental divide in languages. For any non-whitespace delimited context free language, it should be possible to write a homomorphic transformation to a whitespace delimited one. This is something that people should consider trivial and be beyond discussing.
- rileyjshaw 12y ago[Book link](https://itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11 https://itunes.apple.com/gb/book/swift-programming-language/...)
- abruzzi 12y agoUnicode variables, I love it: let 🐶🐮 = "dogcow" Moof!
- aneisf 12y agoYou can do this in C# (and presumably other languages). I've seen people using Greek symbols in mathy code before. It's kind of fun.
- abruzzi 12y agoI'm stuck doing most of my work in php, so this is kind of neat. (I also like that the example in the text resurrects the famous 30 year old dogcow joke.)
- unfunco 12y agoIt's fun once. It's impractical for someone editing the code later though, I don't want to have to look up the unicode character each time I want to remember it, and I don't want to have to copy and paste it either, it's better to stick with the characters available on a keyboard.
- mturmon 12y agoI have to agree. I had a love affair with unicode put directly in LaTeX markup (delta, integral signs, element-of, etc...) and it was very fun at first. Then I had to send the paper to a collaborator while writing a follow-up article together. I ended up removing all the unicode, and in subsequent work I didn't do it any more.
- xtreme 12y agoWhy would you want to put math symbols in LaTeX using unicode? What would be the advantage over using a package like amsmath or even the native math environment? I'm genuinely curious.
- 12y ago
- acmecorps 12y agoIs anyone getting the vibe that swift is golang for writing Cocoa apps, or is it just me?
- tree_of_item 12y agoJust you, Golang would never buy in to modern language features like generics.
- roma1n 12y agoTo me it feels more like a kind of Vala for Cocoa.
- general_failure 12y agojust you
- neovive 12y agoThis is a fascinating development. I wonder how Swift will impact the many cross-platform mobile frameworks. Objective-C was a big barrier for many beginners and small companies and a free and easier development language provided by Apple and supported with good docs and third-party tutorials will likely command a good amount of mind-share. It's going to be an interesting few months in the mobile development world.
- tptacek 12y agoI just skimmed the tour, and my impression is: Swift is a compiled, Objective-C compatible Javascript-alike with an ObjC-like object model, generics, and string interpolation. No exceptions. Based on LLVM and appears to inherit the same data structures as Cocoa apps (Dictionaries, Arrays, &c). It feels very lightweight, sort of like an analog to what Javascript is in a browser.
- pavlov 12y agoI think it uses the Objective-C runtime directly, so it has access to all the frameworks and Swift classes can be loaded into Objective-C projects as well. There are a few other languages that do this with the Obj-C runtime, for example a Lisp variant called Nu[0]. [0] http://programming.nu/ http://programming.nu/
- tinco 12y agoThere's a Ruby implementation by a former Apple employee that does this as well: http://www.rubymotion.com/ http://www.rubymotion.com/
- Karunamon 12y agoUnfortunately it requires a $200 up front investment before you can even toy with the language. RubyMotion was my first thought when I saw the code happening on the keynote, but at least this will be free with the OS.
- mpweiher 12y ago[1] Objective-Smalltalk http://objective.st/ http://objective.st/
- nardi 12y agoIt's also apparently super fast, and implicitly typed, and designed for safety.
- deleted 12y ago
- erokar 12y agoInferred types, first class functions, closures, great speed -- this looks very promising.
- gverri 12y agoI just started learning Objective-C a week ago. Was almost finishing the Stanford iOS 7 course. Coming from a Ruby background I couldn't be more surprised and excited!
- slashnull 12y agowww.mcs.anl.gov/papers/P1818.pdf Swift: a language for parallel scripting, 2011, mostly from University of Chicago Anyone knows if it's related?
- slashnull 12y agoRight yeah it's completely unrelated. My bad.
- slashnull 12y agoSomebody leak this manual please for the love of everything that is holy ... well I meant put it somewhere I could download from my Debian
- deleted 12y ago[deleted]
- robert_tweed 12y agoI really hope this language is going to become an open standard quickly. Here's hoping the language design is not too tightly coupled to the OS APIs.
- AlexanderDhoore 12y agoThis is going to be as open as objective-C. (Whether objective-C is open is left as an exercise for the reader.)
- chrisBob 12y agoDoes anyone know when the new (beta) Xcode will come out?
- andybak 12y agoI'm reading the manual and liking nearly everything. But then I stumble across: > Alternatively, remove a key-value pair from a dictionary with the removeValueForKey method. Is that the day where an Objective-C got to choose method names? Why not dict.delete() or similar?
- julian_t 12y agoI’m with you, and that’s one thing I really don’t appreciate about Obj-C and Apple APIs. You find yourself looking at classes with names like UICollectionViewDelegateFlowLayout and methods called minimumLineSpacingForSectiontAtIndex. I’m not a one-character variable name type of person, but this makes my fingers (and my brain) ache, and for me makes the code harder to comprehend (wood for the trees, I guess, or something like that)
- msie 12y agoThat sounds bad. Heh, you can define your own extension and rename that method.
- taharvey 12y agoYou mean an API than you can actually read and understand? How dare them take your 1970s 80-char display away from you!
- andybak 12y agoYou mean a methodNameThatOverlyExplainsEverythingEvenThoughTheContextMakesItClear()?
- streblo 12y agoAt a glance, it looks like ScalaScript
- pmalynin 12y agoAs someone who's biggest hurdle was the syntax of Objective-C, this is absolutely massive personally. Just the other day, me and my friend was discussing how hard Objective-C is to properly learn. Of course, the jury is still out on Swift until I read further on it, but it can't possibly be worse then Objective-C. Looking forward to it.
- Osmium 12y agoPerhaps it was just for the benchmark, but it seemed ambitious that they're testing encryption algorithms with it already. Does anyone know if Swift, by design, could help avoid issues like they've had recently with Secure Transport?
- creativeembassy 12y agoSlightly disappointed that I won't be able to try it out yet, because I'm not a Mac Developer. I can't get the XCode 6 beta without it, so I'd have to cough up $99 to try a new language... It seems to me like that might hurt its adoption.
- tim333 12y agoI think you should be able to get it when it's out of beta without the $99 thing. Also I have paid my $99 and have not been able to get it yet.
- deleted 12y ago[deleted]
- goblin89 12y agoSwift reminded me of CoffeeScript a little, in a good sense (judging by what they showed during WWDC demo). Complexity and low-levelness of Objective-C is (was?) how I justified my reluctance to program for Apple devices, so I'll be looking forward to Swift. The IDE they demoed looks very interesting on its own—it reminded me of Bret Victor's posts (http://worrydream.com/LearnableProgramming/) http://worrydream.com/LearnableProgramming/). Immediate interactive code visualization, quite impressive.
- sriku 12y agoThe `enum` part of the language seems to be Haskellish algebraic types - like you can have enum "cases" with parameters in addition to just named enumerations .. and these enums can have methods. Cool!
- jfischoff 12y agoThis is a hidden killer feature
- phaedryx 12y agoFirst question that comes to mind: how open is this language? (I can't find any references to it)
- maaaats 12y agoExtremely closed, at least at the moment. Can't even read the language reference without Apple products.
- deleted 12y ago[deleted]
- binarycrusader 12y agoYou can actually read the language reference with a "standard browser": https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ https://developer.apple.com/library/prerelease/ios/documenta...
- Ph0X 12y agoHmm, can't seem to change page in Chrome. In Firefox, it works slightly better but still doesn't really. I'm guessing it only works on Safari? How can they release a language and not have proper documentation that is accessible by anyone? It'd be great if someone could get the book, convert it to PDF and post it online.
- epistasis 12y agoI can switch pages in both Chrome and Firefox. ePub[1] has been posted elsewhere in this comment thread. [1] https://news.ycombinator.com/item?id=7835994 https://news.ycombinator.com/item?id=7835994 (accidentally said PDF instead of epub before)
- YPetrov 12y agoPDF - https://www.dropbox.com/s/wkxqv1zcgrg28m4/The%20Swift%20Programming%20Language.pdf https://www.dropbox.com/s/wkxqv1zcgrg28m4/The%20Swift%20Prog...
- manojlds 12y ago> Looking for the Swift parallel scripting language? Please visit http://swift-lang.org http://swift-lang.org Apple knew there was Swift-Lang, and still called this Swift. At least they link to it from their website!
- namuol 12y agoTheir icon even looks the same. It's also almost identical to the icon used by http://swift.im http://swift.im Sigh.
- _deh 12y agoPhrased with admirable restraint: "The Swift parallel scripting language web is experiencing heavy load due to Apple's announcement of a new language by the same name. We'll have a raft of new web servers online shortly to handle this trafic. Please check back in a few hours! -- The Swift team..."
- Cub3 12y ago"The Swift parallel scripting language web is experiencing heavy load due to Apple's announcement of its new Swift language. We'll have new web servers online shortly to handle this traffic. Please check back in a few hours! -- The Swift team..."
- JonnieCache 12y agoI guess they thought, if google can get away with it, so can they.
- 12y ago
- Osmium 12y agoQuestion: It sounds like the Xcode 6 beta is available on the dev center but I can't find it. Do you have to be a paying developer to have access to it, or does anyone know if it's going to be made available for free to (unpaid) registered developers?
- jaydz 12y agoI can't think of a reason why they wouldn't allow unpaid devs to play with Swift.
- Huperniketes 12y agoTo get more devs to pay.
- tannerc 12y agoTo access the Xcode 6 beta you must be a registered developer. Non-beta releases of Xcode are free to all.
- k-mcgrady 12y agoPre-release software is usually for paying devs only. Xcode is listed under the iOS 8 beta tab which is hidden to non-paying devs.
- gulpahum 12y agoFor those without iBook, here's an excerpt from "The Swift Programming Language": http://pastebin.com/xsr401gt http://pastebin.com/xsr401gt
- mercer 12y agoIt works in Calibre, provided you can get your hands on the epub file in some way...
- kd0amg 12y agoI got it from Apple's ebook store. It showed up in ~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books
- smackfu 12y agoAlso, the dev pages went live: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2 https://developer.apple.com/library/prerelease/ios/documenta...
- kjjw 12y ago"The company says that Swift apps are significantly faster than Objective-C apps, outperforming them by over 93x." With a graph showing ObjC at 127x faster than Python, Swift 220x faster than Python. Thus the conclusion is 220 - 127, Swift is 93x faster than ObjC. Someone needs to resit their GCSEs.
- maaaats 12y agoFor context: This story previously pointed to an article, but has now been changed to point to Apple.
- cjslep 12y ago"93x faster" sounds roughly like a 46.5x improvement in marketing.
- stcredzero 12y agoIt's not only possible, it's even not uncommon for a C programmer to get a 90X improvement in speed in their own C program. If you have naive memory management, or incorrectly implemented concurrency or parallelism, you can easily lose 2 orders of magnitude speed.
- cjslep 12y agoMy most painful personal experience dealing with this exact problem was with CUDA warps, during my undergrad research work.
- pling 12y agoThis. In my case a 1Mbyte memcpy in the middle of a loop this morning. Enough to blow the CPU cache out of the water... 300x improvement instantly by moving it out of the loop.
- dbaupp 12y agoAre you sure it wasn't just because you were then no longer doing a large memcpy repeatedly?
- dang 12y agoWe changed the url for this story from http://thenextweb.com/apple/2014/06/02/apple-announces-swift-new-programming-language-ios http://thenextweb.com/apple/2014/06/02/apple-announces-swift.... If we pick the wrong url, happy to change it again, so let us know. The goal is to have one discussion about each significant announcement, and have the best url for each.
- neals 12y agoDoes this mean I can finally get around to porting my phonegap plugins over to iOS without having to dive deeply into Objective-c?
- tim333 12y agoSwift looks quite similar to javascript - it may be fairly easy to port, I hope.
- protomyth 12y agoSo, they have the weird syntax the MacRuby people were using. I really hate they removed the Smalltalk selector syntax and replaced it with the half-thingy.
- fra 12y agoA lot of the syntax is incredibly similar to rust.
- JamesSwift 12y agoI've been looking into Rust recently, so I wasn't sure if it was just the freshness in my mind or what. Glad to see I wasn't imagining things.
- kibwen 12y agoThe syntax is so similar that I'm quite curious to know whether the Swift developers have been watching us from afar. :) That said, it could just as easily be convergent evolution... which would be quite an impressive validation of our syntax decisions.
- gulpahum 12y agoYes, but Swift looks much cleaner thanks to ARC memory management. I wish Rust has something similar, all those sigils make it messy.
- pcwalton 12y agoWhat sigils? All Rust has is & now. Using ARC removes control from the programmer and has a significant runtime overhead (atomic reference counts), which violates Rust's zero-overhead principle. What Swift works well when you need deep Objective-C integration, of course.
- phaylon 12y agoCould "'" count as type-parameter sigil for lifetimes? It could at least look like a sigil on a first look.
- kvark 12y agoerr.. Rust doesn't have neither '@' or '~' any more. And there is "std::rc::Rc<T>" in case you want reference counting. A big fat difference is that you are not forced to use it.
- niutech 12y agoThere will be the Swift language developer center at http://swiftlang.eu http://swiftlang.eu - right now it redirects to the Apple website. The Swift eBook is available at http://book.swiftlang.eu http://book.swiftlang.eu What would you like to see there beyond reference docs, guides and examples?
- krrishd 12y agoOne thing I'm very interesting in knowing is how this affects the whole 'hybrid/web app' space. Many web developers (like myself) have used Phonegap/Cordova in conjunction with tools like the Ionic Framework for our apps, primarily due to the nearly esoteric (for some of us) nature of Obj-C, but Swift almost looks like JS, which certainly has motivated me to learn it and use it in future apps. I wonder if the aforementioned tools will lose market share because of that. Let's see.
- yesimahuman 12y ago(disclaimer: Ionic creator here): I think Swift will definitely get more people building iOS apps. But we still see a ton of demand from Ionic devs for Android support (perhaps more than iOS!), so unless the world moves 100% to iOS we think Ionic will still be incredibly important.
- higherpurpose 12y agoSo Google...still not going to push Go to Android, already?
- tkubacki 12y agoIt's more likely, they will push Dart as next Android lang
- chadzawistowski 12y agoGo is more of a server-side language; there's no need for it on Android.
- anton_gogolev 12y agoSo is Swift a managed language or what?
- yonran 12y agoIt uses Automatic Reference Counting like Objective C. You must avoid strong reference cycles by declaring your fields weak and optional or unowned. It has deterministic deinit.
- seanalltogether 12y agoWhat i don't really see in the docs is how to calls to objective-c methods are sorted out. For instance, if I have an objective-c class with a method -(void)addNumber:(NSNumber*)num withString:(NSString*)str; How is this called in swift? Is it myobj.addNumber(42, withString:"Hello World")?
- rmrfrmrf 12y agoIn AppleScriptObjC, Objective-C methods are converted from -(void)addNumber:(NSNumber)num withString:(NSString)str; to addNumber_withString(num, str) Swift could be different, though.
- ulhas_sm 12y agoThe whole function name is addNumber:withString: so if it has to be something, it might be myobj.addNumberWithString(42, "Hello world")
- octernion 12y agomyobj.addNumber(42, withString:"Hello World") edit: I see you removed your equals - your guess is now correct :) for more details, see this link on apple's docs (may change) https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4 https://developer.apple.com/library/prerelease/ios/documenta...
- msie 12y agoThere is a section in the docs about it. Similar to what you propose. https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4 https://developer.apple.com/library/prerelease/ios/documenta...
- seanalltogether 12y agoUIColor *color = [UIColor colorWithRed:0.5 green:0.0 blue:0.5 alpha:1.0]; let color = UIColor(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0) Wow, this just brings up more questions, is the compiler removing the "colorWith" semantics or do you write your own translator?
- habosa 12y ago1) This looks much less intimidating than Obj-C, I may finally write an iOS app. 2) Hopefully this puts some pressure on Google to make Go on Android easy (although I'm a Java guy myself). 3) What about swift-lang (http://webcache.googleusercontent.com/search?q=cache%3Aswift-lang.org http://webcache.googleusercontent.com/search?q=cache%3Aswift...). It has the same name and almost the same icon. Did they work with these people or just screw them?
- jballanc 12y agoRe: 3)... Look at the bottom of the page. There's a link to the swift-lang site...from an Apple web property. That's probably more publicity than the swift-lang folks could have hoped for in a million years.
- y14 12y agoAutomatic Reference Counting Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management “just works” in Swift, and you do not need to think about memory management yourself. ARC automatically frees up the memory used by class instances when those instances are no longer needed.” Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/il/jEUH0.l https://itun.es/il/jEUH0.l
- bsaul 12y agoIt "automatically" works until it doesn't. Pointer semantic is the first thing i've looked, and unsurprisingly, they still have the "weak / strong" pointer semantic. You can still point to nil pointers and crash the program because of it, and you can still have retain cycles which creates memory leaks. That language really looks more of trying to make good compromise rather than create a revolution or a breakthrough. In a way, that feels like a much safer choice.
- krrishd 12y agoNow, if Go was implemented on Android, I'd probably develop a lot more for mobile.
- moogly 12y agoLook into Kotlin for Android development. It's a nice-looking language.
- diegoloop 12y agoHere are some coding styles I found for Swift: http://codingstyleguide.com/lang/23/swift http://codingstyleguide.com/lang/23/swift
- klrr 12y ago"innovative" "new" "concise" "expressive" "lightning-fast" God, I love Apple. Now I just wish real innovative languages could market themselves as efficient.
- deleted 12y ago[deleted]
- bigtunacan 12y agoI'm a bit surprised by this move. I see that there are some advantages to this new language, but Objective-C is not as unapproachable as the unwashed masses make it out to be. If Apple wanted to add official support for a new language I would think it would have been a better move to use something that already has an established following and could potentially attract new developers over. Something like Ruby/Python/Lua would seem to fit the bill nicely. We've already seen Ruby can be done successfully on Mac with MacRuby and RubyMotion, but it nevers get full support from Apple. Adding an additional programming language that binds me only to Mac platforms doesn't give me a whole lot of incentive.
- deleted 12y ago[deleted]
- kolev 12y agoI'm super excited about Swift as Objective-C was always a barrier for me as I dislike it very much. This was the greatest news from Apple today, I hope to see compilers on other platforms as well soon.
- kristofferR 12y agoHere's the book for those without access to an iTunes account: http://kristofferr.com/files/The%20Swift%20Programming%20Language.epub http://kristofferr.com/files/The%20Swift%20Programming%20Lan...
- viventor 12y agothks :) , BTW I've used this firefox extension to view https://addons.mozilla.org/en-US/firefox/addon/epubreader/ https://addons.mozilla.org/en-US/firefox/addon/epubreader/
- lartoa 12y agoSwift looks promising and looks like a step in the right direction. However, looking at the reference and everything, I fail to find an answer to this question. Does the concept of private members (methods and variables) in Swift's object system not exist? It looks like every single variable is exposed fully without any way to prevent it from being so.
- tbeutel 12y agoAny ideas on how easy it will be to slurp JSON with Swift?
- ah- 12y agoAny hints on how hard it is to call C libraries from within Swift? This might be a great way to quickly develop a native UI.
- jonhendry 12y agoI dunno, but you could always call the C libraries from Objective-C, and call the Objective-C from Swift.
- psibi 12y agoI'm interested to see the license under which Swift is released but it isn't mentioned anywhere. Is it under EULA or released under some open source license ?
- vetinari 12y agoLicensing is specified in the language specification document: > No licenses, express or implied, are granted with respect to any of the technology described in this document. Apple retains all intellectual property rights associated with the technology described in this document. This document is intended to assist application developers to develop applications only for Apple-branded products. It is pretty closed, if you ask me. Legally binding a language to a specific brand of product is a new low.
- meshko 12y agoReading people compare Swift to other languages is pretty hilarious. OCaml.. Haskell.. CoffeeScript.. Ruby.. Go... Kotlin... JavaScript.. Scala... No one is saying it so I will: It looks like damn Java 8. It is probably not a good sign that it can be immediately compared to every modern (and not so modern) language in existence.
- emp 12y agoAnd Swift seems to resemble another Apple language Dylan, which was based on Scheme/Lisp. All languages since the are in trouble! I really like that it is incorporating good parts of many, more terse languages. Nothing wrong with selectively absorbing good ideas. But a huge part is the interactive nature. I dabbled in Smalltalk some years ago and have been annoyed at compiled languages ever since, resorting to things like http://injectionforxcode.com http://injectionforxcode.com to gain some of that back (on iOS). Having a live environment can only be appreciated once it has been taken away. I think developing for Apple devices might just become one of the more programming pleasant experiences.
- deltasquared 12y agoIt does look a bit like Dylan. I wonder if it has more than a passing resemblance. Also I wonder if they are doing SBCL real time compelling.
- Randgalt 12y agoNothing about concurrency. Nice. STOP MAKING NEW LANGUAGES!!! This is like environment pollution and should be shunned.
- jack9 12y agoI didn't see anything justifying: > Swift is the result of the latest research on programming languages What research? The Apple marketing went a little overboard here. I know Objective-C is subjectively bad from trying to use it. Swift is a step up and that's the exciting part. That's a good thing for ios development.
- shunya 12y agoAs someone who has written apps in Lua using Corona SDK. This is exciting. Syntax looks a lot like Lua/Ruby and we are not stuck using the watered down version of Lua that Corona provides.
- deleted 12y ago[deleted]
- solutionyogi 12y agoEnumerations (from: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html#//apple_ref/doc/uid/TP40014097-CH12-XID_185 https://developer.apple.com/library/prerelease/ios/documenta...): Unlike C and Objective-C, Swift enumeration members are not assigned a default integer value when they are created. In the CompassPoints example above, North, South, East and West do not implicitly equal 0, 1, 2 and 3. Instead, the different enumeration members are fully-fledged values in their own right, with an explicitly-defined type of CompassPoint. +100 for that. This will help developer avoid whole class of bugs. Enumerations also support associated values. Enums in .NET are very poorly defined. Looks like Swift got it right.
- jevinskie 12y agoIndeed. Luckily C++11 took care of the issue on the C++ side. http://en.wikipedia.org/wiki/C++11#Strongly_typed_enumerations http://en.wikipedia.org/wiki/C++11#Strongly_typed_enumeratio...
- platz 12y agoDo Swift's enumerations allow recursive definitions?
- oldguysrule 12y ago>Unlike C and Objective-C, Swift enumeration members are not assigned a default integer value when they are created Well that’s gonna make storing persistent values tricky.
- lassejansen 12y agoDid anybody find information regarding namespaces?
- Profpatsch 12y agoHijacking another programming language name for your own cheap JS-syntax clone? Nice move, jerks!
- ff10 12y agoIs that it? You have nothing more to say? JS, really? Can I say Scala?
- hrktb 12y agoI found the notion of "Optionals" surprising and a bit hard to handle at first. In Objective C it was really easy to lazily allow values to be nil and still do things on them, so it's a bit of a departure. Thinking about it a bit longer, is it because of the clear distinction between non nullable values ans optionals that the compiler can optimise the code so much more ? (I am thinking about the xx times faster than Objective C claims)
- AlexanderDhoore 12y agoThis might increase performance, but I'm pretty sure it's mostly there for safety. It forces the programmer to check for nil. It's like Haskell's "maybe" type.
- cdmckay 12y agoOr Scala's Option or Java 8's new Optional (http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html http://docs.oracle.com/javase/8/docs/api/java/util/Optional....)
- jcromartie 12y agoIt's because it has a grown-up type system. This is a great step in the right direction. ObjC's treatment of nil was handy for a long time, but a basic Option type is far better to show the intent of code.
- MBlume 12y agoI think this is much less to do with performance and more to do with safety. If anything can be nil, NPEs are a fact of life. If you're forced to annotate for the compiler which values can be nil, and then forced to handle the nil case when you consume them, the problem disappears.
- hrktb 12y agoI don't think the problem disappears so easily. It puts a signifiant burden on the programmer (on the top of my head, if I have a set of 20 properties in an object, all optionals, I'll have to unwrap them all, even if I can guarantee by knowledge of the data that they're not nil), it will still throw an error if a value became nil after the test, and there is still the implicit unwrapping system that would cause runtime exceptions on nil values. I see the value of the safeguard, but it seems cumbersome as a language level rule; I hated The boilerplating in Java, and it goes a bit in the same direction. I'm not sure I like the bureaucracy of explicitely testing every single variable that could be nillable to use them, but I'd love to be proven wrong.
- Alupis 12y agoWill it still cost me an Arm, a Leg, and my first born to obtain the dev tools and compile code?
- codezero 12y agoThe beta currently requires that you are a member of one of the Developer programs (iOS or Mac) which costs $99 per year. Release versions of Xcode are freely available at no cost (except that you need a Mac)
- paperwork 12y agoThe documents for ios 8 show all examples in objective-c. Can't wait for them to be updated to swift. I'd love to start with 'getting started' and work my way through rest of the docs. I'm a programmer but could never stomach objective-c.
- based2 12y agohttp://en.wikipedia.org/wiki/Society_for_Worldwide_Interbank_Financial_Telecommunication http://en.wikipedia.org/wiki/Society_for_Worldwide_Interbank...
- lechevalierd3on 12y agoI really wish we could play with it, without having to be a paid member. It's crazy how Apple is always so scared to release dev tools, at the end it will be out-there on bittorrent anyway...
- atburrow 12y agoVisual Studio isn't free in that regard either. What exactly are you comparing this release to?
- MichaelGG 12y agoVS has non-paid versions. And C# and F# compilers are open source.
- msie 12y agoYes, but you need Windows and a Windows PC to run them. I guess you could get Linux for C# and F# but you still need to buy a PC.
- CurtHagenlocher 12y agoHow are you doing development without a non-mobile OS? But I imagine http://www.tryfsharp.org/ http://www.tryfsharp.org/ works even for mobile.
- finnnk 12y agoNo, F# runs everywhere C# does - you don't need a PC.
- tonyabell 12y agohttp://fsharp.org/use/linux/ http://fsharp.org/use/linux/ feel free to give F# a try. Apple hardware ( or MSFT tax) not required.
- emp 12y agoI am pretty sure you can sign up without paying - but your code will be limited to running on the simulator. The $99 is to build for device, and submit to the store.
- domluna 12y agoIt looks pretty nice, I hope they didn't forget about concurrency and parallelism. I don't see anything talking about this in the iBook.
- jakejake 12y agoThey link over to this site from the Apple page about Swift http://swift-lang.org/ http://swift-lang.org/ - I couldn't tell if they are the same thing or if Apple Swift is just based off of this..?
- lukeholder 12y agoyour trolling.
- jakejake 12y agoI actually was not, I didn't understand the relationship between the two languages. I see now that they are not related at all. By the way, it's "You're trolling"
- mkehrt 12y agoI'm sure that the main mechanism will be the existing dispatch queue libraries Apple's other languages use.
- georgewfraser 12y agoYou appear to be advocating a new: [ ] functional [X] imperative [X] object-oriented [X] procedural [X] stack-based [ ] "multi-paradigm" [ ] lazy [ ] eager [X] statically-typed [ ] dynamically-typed [ ] pure [X] impure [ ] non-hygienic [ ] visual [ ] beginner-friendly [ ] non-programmer-friendly [ ] completely incomprehensible programming language. Your language will not work. Here is why it will not work. You appear to believe that: [X] Syntax is what makes programming difficult [ ] Garbage collection is free [ ] Computers have infinite memory [ ] Nobody really needs: [X] concurrency [ ] a REPL [ ] debugger support [ ] IDE support [ ] I/O [X] to interact with code not written in your language [ ] The entire world speaks 7-bit ASCII [X] Scaling up to large software projects will be easy [X] Convincing programmers to adopt a new language will be easy [X] Convincing programmers to adopt a language-specific IDE will be easy [ ] Programmers love writing lots of boilerplate [ ] Specifying behaviors as "undefined" means that programmers won't rely on them [ ] "Spooky action at a distance" makes programming more fun Unfortunately, your language (has/lacks): [ ] comprehensible syntax [ ] semicolons [ ] significant whitespace [ ] macros [X] implicit type conversion [ ] explicit casting [ ] type inference [ ] goto [ ] exceptions [ ] closures [X] tail recursion [ ] coroutines [ ] reflection [X] subtyping [X] multiple inheritance [ ] operator overloading [X] algebraic datatypes [ ] recursive types [ ] polymorphic types [X] covariant array typing [ ] monads [ ] dependent types [ ] infix operators [ ] nested comments [ ] multi-line strings [ ] regexes [ ] call-by-value [ ] call-by-name [ ] call-by-reference [ ] call-cc The following philosophical objections apply: [ ] Programmers should not need to understand category theory to write "Hello, World!" [ ] Programmers should not develop RSI from writing "Hello, World!" [ ] The most significant program written in your language is its own compiler [X] The most significant program written in your language isn't even its own compiler [X] No language spec [X] "The implementation is the spec" [X] The implementation is closed-source [ ] covered by patents [ ] not owned by you [X] Your type system is unsound [ ] Your language cannot be unambiguously parsed [ ] a proof of same is attached [ ] invoking this proof crashes the compiler [X] The name of your language makes it impossible to find on Google [ ] Interpreted languages will never be as fast as C [ ] Compiled languages will never be "extensible" [ ] Writing a compiler that understands English is AI-complete [ ] Your language relies on an optimization which has never been shown possible [ ] There are less than 100 programmers on Earth smart enough to use your language [ ] ____________________________ takes exponential time [ ] ____________________________ is known to be undecidable Your implementation has the following flaws: [ ] CPUs do not work that way [ ] RAM does not work that way [ ] VMs do not work that way [ ] Compilers do not work that way [ ] Compilers cannot work that way [ ] Shift-reduce conflicts in parsing seem to be resolved using rand() [ ] You require the compiler to be present at runtime [ ] You require the language runtime to be present at compile-time [ ] Your compiler errors are completely inscrutable [ ] Dangerous behavior is only a warning [ ] The compiler crashes if you look at it funny [ ] The VM crashes if you look at it funny [ ] You don't seem to understand basic optimization techniques [ ] You don't seem to understand basic systems programming [ ] You don't seem to understand pointers [ ] You don't seem to understand functions Additionally, your marketing has the following problems: [X] Unsupported claims of increased productivity [X] Unsupported claims of greater "ease of use" [ ] Obviously rigged benchmarks [ ] Graphics, simulation, or crypto benchmarks where your code just calls handwritten assembly through your FFI [ ] String-processing benchmarks where you just call PCRE [ ] Matrix-math benchmarks where you just call BLAS [ ] Noone really believes that your language is faster than: [ ] assembly [ ] C [ ] FORTRAN [ ] Java [ ] Ruby [ ] Prolog [ ] Rejection of orthodox programming-language theory without justification [ ] Rejection of orthodox systems programming without justification [ ] Rejection of orthodox algorithmic theory without justification [ ] Rejection of basic computer science without justification Taking the wider ecosystem into account, I would like to note that: [ ] Your complex sample code would be one line in: _______________________ [ ] We already have an unsafe imperative language [X] We already have a safe imperative OO language [ ] We already have a safe statically-typed eager functional language [ ] You have reinvented Lisp but worse [ ] You have reinvented Javascript but worse [X] You have reinvented Java but worse [ ] You have reinvented C++ but worse [ ] You have reinvented PHP but worse [ ] You have reinvented PHP better, but that's still no justification [ ] You have reinvented Brainfuck but non-ironically In conclusion, this is what I think of you: [X] You have some interesting ideas, but this won't fly. [ ] This is a bad language, and you should feel bad for inventing it. [ ] Programming in this language is an adequate punishment for inventing it.
- Mistral 12y agoCan't find the link to download Xcode beta!
- bendyorke 12y agoYou have to be a developer but... [xcode6 link] https://developer.apple.com/devcenter/mac/index.action https://developer.apple.com/devcenter/mac/index.action Edit: You then have to click "OS X Yosemite Developer Preview". Then scroll down, it's at the bottom of the page
- Mistral 12y agoAh, you have to pay to play!
- zwieback 12y agoI like the "value binding" for switch statements with tuples.
- bsaul 12y agoOne question to the audience : i've had a look at the swift iBook and noticed that dictionary are strongly typed. Which is great in a way, but now i wonder : how would you create a json deserializer ( which conveniently deserialized into NSArray and NSDictionnary of anything ) ? I didn't see any "object" or "id" type equivalent.
- mmcconnell1618 12y agoThere is a special type called AnyObject that represents Objective-C id values
- chc 12y agoThere's one thing that bothers me about Swift, and I feel like I must not be getting it. For the most part it looks like a very well-designed language, and the choices they made are extremely pragmatic. But the way collection mutability is determined seems positively insane. You can't have a mutable reference to an immutable array, or vice-versa. I don't get the reasoning behind that.
- Alphasite_ 12y agoI can't check it, but i presume you can do something like Rust and redefine immutable variables.
- pocketstar 12y agoI feel like I could do most of this stuff with lua...but I haven't touched lua on iOS in years.
- deleted 12y ago[deleted]
- headgasket 12y agoI hope some of the debugging UX will cross over to objC dev; my experience is that this is the weak point of the XCODE IDE.
- cw0 12y agoHR departments around the world are going to have to update their mobile dev job postings to include "3+ years of experience with Swift."
- bigdubs 12y agoOne of the things I look for in a language right off the bat, as it's a sign that powerful features can be built as libraries later, is some type of reflection api. There appears to be none (though attributes seem cool).
- thumbtackthief 12y agoSo, I picked up Objective-C a few weeks ago, and I've been struggling (only coming from a Python background, with only the CS-knowledge I've picked up along the way). I just figured it would be fun to be able to make some apps. What would your advice be? Stick with Objective C, or switch over to learning Swift? Swift looks a lot more friendly, but I don't want to sell myself short. I'm also thinking big picture, where learning Obj-C might eventually be helpful in learning other languages.
- gtrak 12y agoI know neither. I'd skip Objective-C and learn Swift to actually make a thing. If you want general language knowledge, a really hairy production language and toolset isn't the place to look. You'll be fighting with lots of incidental stuff along the way. Learning different kinds of languages will help you learn more languages.
- Oculus 12y agoAs a detached Apple-related news follower, can some please update me: Is Swift going to become the new main development language for iOS?
- tree_of_item 12y agoIf it's actually faster than Objective-C like Apple claims, then I'd bet on it, yeah.
- jkubicek 12y agoEven if it's not faster, yeah. Most apps don't have any performance bottlenecks, and the ones that do can just drop down to Obj-C/C/C++
- Oculus 12y agoAs a very detached Apple-related news follower, can some please update me: Is Swift going to become the new main development language for iOS?
- callmeed 12y agoSomeone bought swiftcasts.com today ... http://whois.domaintools.com/swiftcasts.com http://whois.domaintools.com/swiftcasts.com
- X4 12y agoI'm a learning addict. Has somebody tasted it and is this worth it?
- darrellsilver 12y agoOur mentors & curriculum developers went bananas when they heard about Swift – so we announced the first course teaching Swift: https://www.thinkful.com/a/dlp/learn-blue/base/IOS-002 https://www.thinkful.com/a/dlp/learn-blue/base/IOS-002
- darkhorn 12y agoHas some features from Lisp.
- darkhorn 12y agoDo they have a pdf book?
- jbclements 12y agoI'm assuming that there's no memory safety guarantee for Swift code that interacts with Objective C code. Can anyone shed any light on this?
- msie 12y agoNested multiline comments. :-)
- chrisdevereux 12y agoAnyone know how Swift might achieve its claimed speedup vs. Objective-C? I can't see how it could get the advertised numbers without method inlining, which appears to be incompatible with the dynamic object model that it inherits from Objective-C
- cwp 12y agoWhy would method inlining be incompatible with dynamic dispatch?
- chrisdevereux 12y agoI was thinking more about runtime method replacement.
- jonhendry 12y agoLess ambiguity, allowing the compiler to optimize more?
- Xelom 12y agoAs a C# developer, I've felt familiar to this lanuage. I don't know why...
- owenwil 12y agoWe're writing a story for The Next Web on Swift. If anyone's interested in being interviewed for an article, can you flick me an email on owen@thenextweb.com with brief answers to some or all of the following questions. I'd love to talk to anyone who's used Objective-C before and share your opinions/experience: 1) How does Apple releasing Swift make you feel as an Objective-C developer? 2) Are you excited to code using Swift? 3) What about Swift makes you most excited? 4) Do you worry about upskilling to Swift? 5) How do you think Swift will change the way you work? 6) What concerns do you have about swift? Keen to understand how this impacts people and share that if you have time to talk to me :) If you don't want to email, just reply here.
- owenwil 12y agoThanks for all the responses - we ran this :) http://thenextweb.com/apple/2014/06/03/developers-apples-swift-huge-potential/ http://thenextweb.com/apple/2014/06/03/developers-apples-swi...
- p0nce 12y agoMy thoughts while browsing the site: - function-level type inference much like Rust - no constness in the type-system (I like it) - class are reference types, structs are values types, much like D and C# - runtime dispacthed OO interfaces called "protocols". Blend the difference between runtime or compile-time polymorphism. Classes, structs and enums can implement a protocol. Available as first class runtime values, so the protocol dispatch will be slow like in Golang. - enumerations are much like Ocaml ADT, can be parameterized by a tuple of values, value types, recursive definitions (nice) - worrying focus on properties. - strange closure syntax - optional chaining, another anti-feature in my eyes - normal arithmetic operator throws a trap on integer overflow (!). This must be incredibly slow. - looks like Array is a fat slice to a reference-counted array - operator overloading is in, supercharged with custom operators, custom precedence (!?) - builtin tuples syntax - break with C integer promotion, like Rust. - no pointers - convenience is a keyword! - no exceptions (!) - unsigned integers: check - type inference is "bidirectional by expression or statement" - classes have deterministic destructors, structs have no destructors - It seems the only RAII source is through RC and classes. - no single root class Make your own opinion.
- ysleepy 12y agoTrap on Overflow is not that expensive: http://www.sei.cmu.edu/reports/10tn008.pdf http://www.sei.cmu.edu/reports/10tn008.pdf I am thrilled they did this. Implicit Overflow is the stupidest shit I know that everyone takes for granted. Also with CPU support it could be free, and adds negligible complexity to the silicon.
- roryokane 12y agoThe part of that paper that says how expensive Trap on Overflow is: > At the `-02` optimization level, our compiler prototype showed only a 5.58% slowdown when running the SPECINT2006 macro-benchmark. Although that percentage represents the worst-case performance for AIR integers (because no optimizations were performed), it is still low enough for typical applications to enable this feature in deployed systems.
- njharman 12y ago> you don’t even need to type semi-colons. But you still need to type curly braces. Which are utterly redundant with indentation, pain to type, brainless task that languages should take care of, and a source of bugs.
- wyuenho 12y agoJust glanced thru the Swift book in about 3 hours. Conclusion: all your programming language are belong to Swift, mostly stolen good ideas, some innovations, a few gripes. I can say Swift takes inspiration and improves on at least these languages: C: typealias struct control structures labeled statements AKA gotos varargs C++: default arguments class instance construction syntax // comment superclass, implementing protocol declaration syntax semi-virtual class init, deinit Go: No parentheses around the condition part of control statements Unicode identifiers shorthand for signed and unsigned integer types U?Int(8|16|32|64) C#: in-out params properties subscript access of class member values Objective-C: ARC protocols extensions param names as method names willSet/didSet nil? Java: enum @final super keyword override method keyword Scala: Local type-inference, blend of an ML flavored FP with OOP without the noise and believe it or not, even more powerful in specifying generic type constraints. No stupid JVM type erasures either so you can actually create an instance of a generic type, just like C++ templates. Self: self Python: for i in enumerate(seq) for key, value in dictionary Type(value) explicit type conversion syntax No public/private/protected class member access modifier bullshit Array literals, dictionary is also like Python but use [] instead of {} Ruby: 0..100, 100_000 Lisp: closures Scheme, Coffeescript: ? optional type modifier Bash: $0, $1... inside short callback closures Innovations --------------- break-less switch, optional fall-thru, comma as multiple case, case can be any value of any type, condition or a type constraint for pattern matching, supports method call shorthand generic type constraint queries overflow operators @prefix, @postfix, @infix, @assignment modifiers for operator overloading Trailing closure as partial function application Gripes ------ Seems like array[4..6] is even more useless than Javascript's Array#slice, and a far cry from Python's slices. No set literals and list/set/dict comprehension. Nothing for concurrency???? No yield, no generators, no channels, not even the synchronized keyword. There's no decorator or annotations, and Swift isn't Objective-C, what's with the odd-ball @ modifiers? I don't see namespaces as mentioned in the WWDC slides, and goto is definitely still here so you might just write another gotofail. Looks like Swift is Apple's answer to Go, Rust, Scala, Java, PyObjC/RubyMotion, Unity, Xamarin and all these HTML5 + JS/Phonegap people. I'll definitely pay attention to Swift. If the performance results hold up, Swift + iOS8 will definitely leave Android's ancient Java 5 crap way out in the dust. https://itunes.apple.com/us/book/swift-programming-language/id881256329?mt=11 https://itunes.apple.com/us/book/swift-programming-language/...
- mblakele 12y agoIn the playground REPL, am I missing an easy way to display errors as they happen? It seems any error messages aren't visible by default. Xcode shows a red "!" disc next to the line, and that's it. The usual shortcuts for "Jump to next/previous issue" are disabled. Opening the issues tab with command-4 works, but it's empty. Apparently I have to mouse over and click on the tiny red disc to see any error message at all, and then it displays as text that can't be selected or copied. EDIT: ctrl-command-M turns "Show all issues" on or off. It seems to be a little buggy, which may be why it's off by default. Hopefully we'll get the ability to copy the error text in the next refresh.
- ekeren 12y agoIt is exciting, the language is full of modern stuff... This is what I catch at a glance of the book: - Optionals (Java's @Nullable) - Tupples - Functions as first class citizens - let vs var (immutable vs mutable) - Operators are functions - Closures - Extensions (Adding things to an existing class) - Value object (struct - are passed by value -- and so are Strings!!! ) - Reference Objects (class) - Generics (lets hope it will be better than Java's version) - External Parameters ?? - @final keyword (to prevent overrides - like Java's final) It kinda looks like C# meets Ruby meets the let keyword Very complex... And More - object reference operator === and !== - typealias (~ typdef) - Optional Binding (if let x = y.f() { } else {} - for-in loops (for i in 0...count) - The default behavior of switch is not to fallthrough
- rvillas 12y agoOh! Finally! swf files on iOS :-)
- MaysonL 12y agoAnyone else see quite a lot of Scala here?
- anilmujagic 12y agoYup...
- chj 12y agoThere are cool things in Swift, but I hope they just promote Javascript to a system language so that all platforms can go towards a single code base.
- axman6 12y agoiPhone apps need to be more webscale and NoSQL compliant too. And what about event based? (Hmm...)
- roberthahn 12y agoMy first instinct was to be cautious about new languages from Apple - Dylan was supposed to be something awesome until Apple cancelled it. But I only learned of the existence of Dylan years after it was cancelled. Looked awesome, but it was so niche I didn't want to spend time learning it. So I took a moment to look at why Dylan was cancelled.[1] Veryin interesting stuff. What it came down to was: - Apple was in dire financial straits - Apple needed to axe all projects that didn't show commercial viability - At the time, when Apple was transitioning to PowerPC, Dylan was 68K only, and needed another year or two to be ported - Most damning, the project was not finished - it wasn't even in the optimization stage. None of these factors are in play here. So. My worries are assuaged. I do want to learn this, and it looks really easy to pick up so far. I'm really curious now about two (unrelated) things: 1) is this good enough to build web apps with? 2) how would one manage the transition of an Obj-C based project to a Swift-based one? Assume I don't have the budget or manpower to perform a ground-up rewrite. [1] http://en.wikipedia.org/wiki/History_of_the_Dylan_programming_language#End_of_Dylan_as_commercial_product http://en.wikipedia.org/wiki/History_of_the_Dylan_programmin...
- gcv 12y agoBased on my skimming of the Swift documentation, Dylan is a much nicer language (both in its original form and in its modern OpenDylan incarnation). That said, Swift just needs to improve on Objective C, which does not set the bar high.
- jonhendry 12y agoYou can mix Objective-C and Swift code in a project, so it would be easy to progressively port code one class at a time. Porting NSView subclasses first would give you a win, because if you use Swift the classes can draw themselves at design time in Interface Builder. (Objective-C view subclasses just draw a white rectangle in IB.)
- Someone 12y agoI don't have access to a machine with the new Xcode yet, but reading the book in iBooks, I found: NOTE For the best experience, open this chapter as a playground in Xcode. Playgrounds allow you to edit the code listings and see the result immediately. Downloading gives me https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.playground.zip https://developer.apple.com/library/prerelease/ios/documenta..., a zip file with about 50 html files, a .css, about 40 .swift files and two files Results.playgrounddata and contents.xcplayground Does that mean that playgrounds can be used for literate programming?
- coherentpony 12y agoI wonder how many years, n, from now it takes for people to claim they have N > n years of experience with Swift on their CV.
- jdludlow 12y agoPresumably 0, since there are already people who can legitimately claim multiple years of experience with Swift.
- reuven 12y agoI find it a bit sad that with all of the languages that already exist, Apple found it necessary to invent a completely new one -- and then make it proprietary. Why not use Ruby, or Python, or JavaScript -- or even Go, Rust, Clojure, or Scala? (Yes, I realize that the latter two run on the JVM, which would have been problematic in other ways.) Heck, they could have bought RubyMotion and made Ruby the high-level language of choice for development. I realize that Apple has a long tradition of NIH ("not invented here"), and in many cases, it suits them, and their users, quite well. But there are so many languages out there already that it seems like a waste for Apple to create a new one. Just the overhead of developing the language, nurturing its ecosystem, and ensuring compatibility seems like it'll cost more time and money than would have been necessary if they had gone with an existing language.
- coldtea 12y ago>Why not use Ruby, or Python, or JavaScript -- or even Go, Rust, Clojure, or Scala? (Yes, I realize that the latter two run on the JVM, which would have been problematic in other ways.) Heck, they could have bought RubyMotion and made Ruby the high-level language of choice for development. Because OBVIOUSLY none of them solve the problems they wanted to solve (interoperabillity with Objective-C, fast, native, IDE integration, etc. Including RubyMotion which is a half-arsed implementation.
- oblio 12y agoI'm not sure if you're kidding or not. IDE integration for a new language? They wrote it themselves. Do you think it would have been harder to integrate an existing language? Fast & native also also trivially solvable. I don't know about interop with Objective-C, that's probably the hardest part from your list. But complaining about IDE integration when they're also the creators of the IDE is... silly...
- MrGando 12y agoI see that you don't really understand what's needed for real IDE integration. Please, understand one of the main reasons of Apple creating Clang... (hint: because the GCC guys wouldn't take their patches to improve Objc-C & add facilities for IDE integration fast enough) Clang was easier to integrate with an IDE than GCC, and I strongly believe (after seeing what apple showed yesterday) that swift integration is even simpler. ( They must have made a new LLVM front-end to embrace IDEs equally or better than Clang ) So no, it's not silly to try to design better to have a better integration with an IDE that you control too. Cheers.
- joeevans1000 12y agoOh sweet! Another shrub in the walled garden!
- msie 12y agoNow I wish I knew of a tool to filter out HN comments older than x hours.
- SneakerXZ 12y agoWhy do we have to wait with submitting apps that uses Swift until fall when Swift works with iOS 6 and iOS 7?
- anigbrowl 12y agoIt seems perfectly serviceable, but I have to admit that my reflex response on opening the page was 'Oh god, another language?' I can't tell if Apple is proposing this as a great new language everyone should use, or whether it's only intended for developers using Apple hardware and so represents a sort of lock-in strategy. I don't have an opinion on the language itself - it seems to have several neat features that make it easier/safer than competing languages like js, but presumably there are a few shortcomings as well.
- mikenwani 12y agoNoob here. I don't understand... so what happens to Objective-C? Why would you code an iOS app with one language instead of the other? Why would you use both? That just sounds like a pain. Is Swift the evolution of Objective-C or something?
- codezero 12y agoA lot of commenters here are asking whether it will be open sourced, I'm curious, specific to those who think it should be open sourced: why? I'm not really curious about the philosophical reasons, but really the practical ones. How would Swift being open source help you as a developer? It's clearly targeted at iOS and Mac OS X, so does this mean you won't write Mac OS X or iOS apps if it's not open source, or did you hope that you could write Swift code on other platforms?
- ics 12y agoTwo big ones off the top of my head: - Porting to other platforms/community implementations (think Mono) - Developer input: being able to submit bugs, influence or even just *watch* the trajectory of the language, get a deeper understanding of how various components are really implemented
- roryokane 12y agoA reason in addition to ics’s two reasons: If Swift is open-sourced, it will be more popular, because it might be used by developers on other platforms too. Those extra developers would write more libraries and documentation that would improve the ecosystem of the language.
- sirdogealot 12y agoMe (running arch linux): Oooh! I'd love to learn a new language. And great, they have a free ebook it looks like to describe it! Apple: To download Apple Inc.’s 'The Swift Programming Language', you need to have iTunes. Me: What? Apple: Using a 64-bit edition of Windows? On a Mac? Me: No. That experience just killed a potential programmer for you right there, Apple. I had a few hours to kill, and was pumped to jump on the next apple cash cow and help us both, but you literally killed my ability to download the manual or learn anything more about it for a few days, by which time I'll probably be onto something else. They have this: https://developer.apple.com/library/prerelease/ios/referencelibrary/GettingStarted/LandingPage/index.html https://developer.apple.com/library/prerelease/ios/reference... But it doesn't look nearly as in depth as the ebook would be.
- zyx321 12y agoIf you're an Arch user, why would you learn a language that won't ever compile on anything other than OSX?
- sirdogealot 12y agoBecause money.
- anilmujagic 12y agohttp://book.swiftlang.eu http://book.swiftlang.eu
- sirdogealot 12y agoThat's a 474 page ebook that I can only load in a web browser... Not exactly easy reading. But thank you!
- jonhendry 12y agohttps://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5 https://developer.apple.com/library/prerelease/ios/documenta...
- deleted 12y ago[deleted]
- keithwarren 12y ago500+ comments and the term asynchronous does not appear once. It is a platform pain point, several languages have baked in support for async scenarios and Apple comes up with a whole new language, ignores it and a forum full of language geeks talks about it and no one points out it is missing.
- antonmaju 12y agoHaha, I was searching for "async" and "await" keyword and only your post mentioned it
- sredmond 12y agoAs someone coming from Python and Java but always dissuaded by Objective C's menacing syntax, I am 100% behind the new change.
- alex2014 12y agoDo we know if enums can be recursive? i.e. enum BinaryTree = { case Leaf(Int) case Node(BinaryTree, BinaryTree) }
- axman6 12y agoI saw somewhere else today that someone tried it and it crashed the compiler, so I guess not. The string "recur" doesn't even occure once in the iBook. It seem though that you might be able to use a combination of objects and enums to get that.
- tumdum_ 12y agoNo built in support for concurrency or parallelism :(
- eden-san 12y agoI am surprised noone mentioned Erlang! Tuples and pattern matching are the bread and butter in Erlang and deserve to be mentioned as one of the source of inspiration for the Swift language. The '_' character used to ignore some values in loops/patterns was also taken from Erlang (for _ in array { ... }).
- return0 12y agoObjC and its quirks was a major reason i never did Mac development. This sounds more interesting.
- pajju 12y agoThere is the official Swift Book: The Swift Programming Language by Apple Inc. Book Link: https://itunes.apple.com/us/book/the-swift-programming-language/id881256329?mt=11 https://itunes.apple.com/us/book/the-swift-programming-langu... Swift is a new programming language for creating iOS and OS X apps. Swift builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works. This book provides: - A tour of the language. - A detailed guide delving into each language feature. - A formal reference for the language. Hope it helps.
- blutoot 12y agoWhat is the advantage of "func funcName() -> returnType{ }" over "returnType funcName(){ }"?
- kaonashi 12y agoWhen your function returns a function, it's cleaner. func funcName() -> Int -> String { return { (i: Int) -> String in return i.toString() } }
- ashearer 12y agoSwift is designed to make many common C and Objective-C errors less likely, but at least one class of bugs could be ascendant: off-by-one errors in ranges. Swift's ".." and "..." range operators are reversed compared to Ruby and CoffeeScript. Swift's way is arguably more sensible: the longer operator makes a longer range. But switching the way two similar-looking operators work, as opposed to at least two other languages popular with the target audience, is bound to lead to errors as programmers switch contexts. Just the fact of having the two operators in the language together is dangerous, since they look similar and switching them will lead to weird bugs instead of immediate compile-time or runtime errors. Switching their meanings makes this more pernicious. Time to prime our eyeballs to look out for this one. [1] Swift book: “Use .. to make a range that omits its upper value, and use ... to make a range that includes both values.” Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l https://itun.es/us/jEUH0.l [2] Ruby: "Ranges constructed using .. run from the beginning to the end inclusively. Those created using ... exclude the end value." [http://www.ruby-doc.org/core-2.1.2/Range.html http://www.ruby-doc.org/core-2.1.2/Range.html] [3] CoffeeScript: "With two dots (3..6), the range is inclusive (3, 4, 5, 6); with three dots (3...6), the range excludes the end (3, 4, 5)".
- acjohnson55 12y agoIt's closest relative is Kotlin, as far as I can see. It shares a lot of the same functionality, from the null-checking to generics, etc.