6 ms·
Show HN: Learn Swift
- aidanf 11y agoI've been learning Swift in recent months, and as part of that process I wrote a short book about the language. It's aimed at developers (like me) who can already program in a language like Ruby or Python and are looking for a quick tour of Swift. It's available to read for free online at http://books.aidanf.net/learn-swift http://books.aidanf.net/learn-swift I'll be adding stuff about yesterdays announcements in the next couple of weeks.
- NicoJuicy 11y agoWith what did you create the ebook?
- aidanf 11y agoI used Softcover (https://www.softcover.io/ https://www.softcover.io/) to generate the ebooks.
- acoleman616 11y agoSoftcover is awesome. (It's a Michael Hartl creation.)
- lsjroberts 11y agoThanks for sharing it :) just fyi, the .fixed header overlaps the content making links unclickable if they are in the top part of the page
- aidanf 11y agoThanks for letting me know, I hadn't noticed that.
- CornishPasty 11y agoI believe you just need to remove 'margin-bottom: 2em;' from .top-bar in styles.css
- aidanf 11y agoThanks, I'll try that. Although I'm reluctant to clear the cache until it goes off the HN front page :)
- brador 11y agoThe ebook is great, but it's missing complete start to finish examples. Pad it out with them and you could double the price (and it would be massively more helpful!). Maybe a todo app, flappy bird clone, etc.
- aidanf 11y agoThanks for the suggestion. I think I'll add another chapter at the end that walks through a longer example start-to-finish.
- sswaner 11y agoNot sure if you have a better method for getting feedback. First sentence in 12.6 has a minor typo: "“Subscripts allow you *do define a way of allowing your class”
- geuis 11y agoWould you mind removing or moving all of the position:fixed stuff on the left? Makes it impossible to read the site on mobile.
- aidanf 11y agoWas it the share buttons? I tested these on iphone and they dropped to the bottom of the page. But it looks like they only do this for phones below a certain resolution. So I've removed them.
- geuis 11y agoYep yep. Just put em somewhere where they're static, or use a media query to position:static on < 768px. Excited to read the book now. =)
- tjl 11y agoIt looks like you're looking at an earlier version of Swift at least based on the fact that you're talking about Xcode 6.1 at the start. If you're covering 1.2, you probably should update that.
- aidanf 11y agoThanks. The code is 1.2, but the Xcode references are out of date. I'll update soon, I'm also going to update the whole thing to Swift 2 when it's released.
- BuckRogers 11y agoGreat timing on the post. I'm a Python(2) user who is always on the lookout for the next language to jump to since I'm never moving to Python3. With Swift on the server and iOS, and being a very pleasing language similar to Python, this will be what I study next as I look to migrate off Python2 as it dies (which itself may take a while). Thanks for posting this.
- Lofkin 11y agoTake a look at julia!
- FungalRaincloud 11y agoOut of curiosity, why are you avoiding Py3? I've not touched python in a couple years. I was thinking of taking it back up, just to be more familiar with it.
- x5n1 11y agothere is nothing wrong with py3. some people just want to be ornery.
- BuckRogers 11y agoAs the other guy who replied said, there's nothing explicitly wrong with it. But it's not to be ornery. I think it only appears that way to people who haven't thought it through. I don't owe GVR or the core dev team anything. Certainly not thousands of man-hours to make their new, unnecessarily breaking version of Python3 to be successful. It's that going from Python2, it's mere technical churn. Python3 has zero technical innovation. It's just a different way of doing certain things, nothing more. Unicode was supported in Python since 2.6. Print was a statement rather than a function. Std lib cleanups. So what? Bigger fish to fry in the world than that. All of the new features, can, and do work on Python2 in the form of backports. It breaks everything I've ever written, for no good reason. I also end up with a much smaller pool of libraries to choose from for new projects. It makes no sense. In a microcosm of the universe where Python was the only game in town, Python3 would have worked out. Instead of moving to 3 and losing many advantages for churn, I can just go spend time with something else. Swift is pretty what I'd design if I could pick and choose features, so it's perfect for me- excited I'll be able to use it serverside while simultaneously learning the language for iOS. Also, people frequently cite that moving from 2->3 is easy. It is. But they somehow forget that testing old, large projects is extremely labor intensive and always results in breakage. Unless you have 100% test coverage, which I know no one who does.
- rshaban 11y ago"For anyone who has been programming in a modern language such as Ruby [1995], Python [1991], Clojure [2007], Haskell [1990], etc, and who was put off developing iOS apps by Objective-C, Swift marks a new era." You say modern but I don't think it's really what you mean here. Your descriptions of Ruby vs Obj-C make it seem that really what you mean is high-level; that is, to a newer programmer, easier. These languages (Haskell excepted) make it very easy to do simple things. Describing them as "modern" in contrast with the implicitly antiquated Obj-C makes it a little hard to take your assertions seriously. Verbosity is a claim to make, age is not.
- antoaravinth 11y agoOnline version of reading has complete book?
- drussell 11y agoThis is very helpful. Thanks for sharing! Great that it's free too :)
- digital-rubber 11y agoThanks! probably coincidence, but seems a typical setup of keywords/chapters, the Tuts+ and some other tutorial have very similar layout.
- jezfromfuture 11y agoGreat another out of date book ,that will no doubt push swift 1.2 when swift 2.0 is out.
- coldtea 11y agoWell, at least it will be useful short term. Your comment doesn't even have that.
- blowski 11y agoJust because it will go out of date at some point, it doesn't mean it's not a useful resource today. I haven't read this particular book, so can't comment on whether or not it's any good, but in general whenever I want to learn a new language, I start by looking for a book.
- JustSomeNobody 11y agoNearly every technology book will be out of date shortly after it is written. You want people to just stop writing and sharing? What have you done that's so great that you can observe and criticize the lessers from your great pedestal?
- deleted 11y ago[deleted]
- npalli 11y agoSorry, but this guide is not as comprehensive or updated as the official documentation [1]. Just compare the generics or memory management sections to see why you would want to read the official documentation. Maybe a high level tour of swift but you certainly are not going to learn swift with this guide. [1] https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ https://developer.apple.com/library/ios/documentation/Swift/...
- aidanf 11y agoYou're right - it's not as comprehensive as the official documentation, nor is it meant to be. It's a quick tour of the main language features, with a particular emphasis on the parts that I (as a ruby, python, clojure dev) found interesting. For comparison, the Apple book "The Swift Programming Language" comes in at 334 pages. "Learn Swift" comes in at 128 pages.
- rashthedude 11y agoHi Aidan, your about Author section has a typo says'bulding' rather than building.
- aidanf 11y agoThanks, fixed.
- Tloewald 11y agoI like the style, brevity, and practicality of the book (at least the first few chapters; haven't read it all yet). Good stuff and good luck with it. I did find the first few examples with the REPL to be a bit confusing. Were you using a function before it was defined?
- aidanf 11y agoThanks :) The REPL example with the error has a deliberate typo (int instead of Int) to show how multi-line editing works in the REPL - is that the part you're asking about?
- Tloewald 11y agoI was referring to this: $ swift Welcome to Swift! Type :help for assistance. 1> 3.14 * 2.5 * 2.5 $R0: Double = 19.625 2> println("The area of the circle is \($R0)") The area of the circle is 19.625 3> 4> $R0 * 2 $R1: Double = 39.25 5> println("And double that is \($R1)") And double that is 39.25 6> What's Double? Trying to follow this (which didn't make sense to me because I didn't know the history stuff was there) simply caused error messages.
- _s 11y agoIsn't Double just a bigger floating point number?
- addandsubtract 11y agoRight. A double has twice the precision of a float (hence the name). It's also the default floating point data type in Swift.
- numbers 11y agoIn Chapter 4, you have a typo: "dynamicly" should be "dynamically"
- aidanf 11y agoThanks, fixed.
- Zaheer 11y agoShameless plug - I made a site that gathers resources for learning Swift. Will be adding this shortly :) http://www.LearnSwift.tips http://www.LearnSwift.tips
- bigtunacan 11y agoCool. Bookmarked.
- tjl 11y agoOoh. Thanks.
- christudor 11y agoHave just started learning Swift. Have favourited, and will be sure to give some feedback once I've made my way through the whole thing. Good luck with it!
- psophis 11y agoSlight tangent, but are there any recommended guides/books/videos for leaning the iOS frameworks with swift? I have recently started programming on iOS with swift. I got my head around the language just not any of the frameworks, specifically UIKit.
- tjl 11y agoI love the Lynda.com videos on Swift and iOS. The latest Stanford iOS course uses Swift and is excellent.
- ntpeters 11y agoI'll second the Stanford iOS course with Swift, here's a link to it on iTunesU: https://itunes.apple.com/us/course/developing-ios-8-apps-swift/id961180099 https://itunes.apple.com/us/course/developing-ios-8-apps-swi... Also, Udacity has some iOS courses using Swift now as well. Here is the intro one: https://www.udacity.com/course/intro-to-ios-app-development-with-swift--ud585 https://www.udacity.com/course/intro-to-ios-app-development-...
- mayrund 11y agoLooks awesome! Thanks for your time I will definitely look into it deeply soon!
- ashwinl 11y agoI'd highly recommend Functional Programming in Swift for more intermediate topics. By Eidhof, Kugler, and Swierstra http://www.objc.io/books/fpinswift/ http://www.objc.io/books/fpinswift/ No affiliation to the author/book.
- yla92 11y agoI love this. Btw, totally off topic : Is it possible to write iOS/OSX apps by learning Swift without the knowledge of ObjC ? My background : I know some Java/Ruby and do some Android apps.
- Cthulhu_ 11y agoIt is, but you'll still need to learn about the memory management in objective-C (retain / release and such, although that's been made a lot easier over the years, pushing it back to being background knowledge) and - perhaps more importantly than the actual language - the frameworks, environment and tooling (Foundation, UIKit, iOS application basics / lifecycle, view hierarchy, XCode, Interface Builder, and background knowledge like accessibility and such). But yeah, go with Swift, it's closer to Java than Objective-C is.
- davnicwil 11y agoThis is fantastic, just what I was looking for, a very quick intro to swift that assumes I'm already a programmer. The Apple docs, at least last time I tried reading through them, were like wading through treacle so this is a great alternative! I just read the first couple of chapters in 10 minutes and got all the key info I wanted with no fluff - great job! One edit suggestion - I've noticed a couple of times so far that "it's" is used incorrectly, for example in this sentence: > You can’t change the type of a variable once you’ve declared it. It’s type is fixed at the time it is declared. I assume you know the error here but on the off chance you don't: it's = it is (it's a Bool) / its = the possessive of it (Bool is its type) It's a little jarring so you might want to go through and fix these. Cheers for the book! :-)
- aidanf 11y agoThanks for that - I'll fix the errors you've listed. I know how to use its and it's, and I've proof-read the book several times, but there's still a good bit of stuff like this that I've missed. It turns out that it's really difficult to proof-read large blocks of text that you've written yourself :/ When your brain sees something it recognises it tends to speed up and skip over bits, seeing what it wants to see, thus missing stuff like this.
- davnicwil 11y agoNo probs, and great choice of model by the way, offering the web version for free. For learning a programming language I actually prefer the web format to the ebook. Now I've figured out how useful this book will be by reading a few chapters, I'll certainly purchase a copy anyway, $12 is more than reasonable for the value this provides!
- brisance 11y agoNice, I'm learning Swift from your site. The kerning for Chapter "10.4" is killing me though. Other than that I'm enjoying going through it. :D