Live data from Hacker News

A Video Walkthrough of Swift Fundamentals

firebase.com

11–20 of 20 posts

Re: A Video Walkthrough of Swift Fundamentals

#11
post #8
post #7

Earlier quoted context omitted.

I agree! Eithers are cool, too. What I'm really excited about is that these sorts of concepts are starting to find their way into languages like Swift. Getting built-in support for Eithers would be super awesome. In the meantime, you can vaguely simulate it with named tuples. let response = (error: "Could not connect to server", success: false) It's not quite the same, but at least there's an easy way to bundle your…

Other approach: use enums as union types. From https://developer.apple.com/library/ios/documentation/Swift/... : enum Barcode { case UPCA(Int, Int, Int, Int) case QRCode(String) } This can be read as: “Define an enumeration type called Barcode, which can take either a value of UPCA with an associated value of type (Int, Int, Int, Int), or a value of QRCode with an associated value of type String.” So, you can do enum…

Enums and generics mix just fine in theory. Rust is a good example of this, with the `Result` type. But at the moment in Swift if you try this you get "error: unimplemented IR generation feature non-fixed multi-payload enum layout". Presumably this will be supported at some point.

Re: A Video Walkthrough of Swift Fundamentals

#12
post #2

This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…

>One of my favorite parts of Swift is the optional concept What if you need the fallback value to be an error possessing information about what went wrong? data Maybe a = Just a | Nothing data Either a b = Left a | Right b

Swift's Optional is just Maybe with some built-in sugar. Sum types are supported, with the caveat that the compiler is sort of broken when it comes to generics.

Personally, I just want higher-kinded types, and for the following code snippets to work as-is:

  enum Either {
    case Left(A)
    case Right(B)
  }

  enum Tree {
    case Leaf
    case Node(Tree, A, Tree)
  }
The first breaks because of the "Unimplemented non-fixed multi-payload enum layout" compiler error, and the second breaks because enums have value semantics. Both can be worked around in full generality by declaring a 'Box' generic wrapper class, but that workaround is inelegant and cumbersome.

Re: A Video Walkthrough of Swift Fundamentals

#13
post #2

This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…

>One of my favorite parts of Swift is the optional concept What if you need the fallback value to be an error possessing information about what went wrong? data Maybe a = Just a | Nothing data Either a b = Left a | Right b

Use Swift's nil coalescing operator: a ?? b

Re: A Video Walkthrough of Swift Fundamentals

#15
That was great. Didn't think that Id watch the whole thing, but now I want to see more. She put on an awesome presentation and the REPL worked really well in this format. Thank you for putting this together and please do more (if you have the time, of course).

Re: A Video Walkthrough of Swift Fundamentals

#16
post #2

This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…

Hello, While I do not have time to go over the whole video, surely you could have come up with much more serious reasons why Swift might be preferable to Objective C than "uhm, it has no namespaces and looks strange". Also, there were no reasons why "not to use Swift [yet]", making sure to mention the terrible state the developer tools are at this point, as well as many many missing language features and other quirks…

>making sure to mention the terrible state the developer tools are at this point

Terrible compared to something like a mature IDE like Visual Studio or Eclipse and/or an established toolchain.

Because compared to what most newcomer/not top-10 languages have (languages like D, Racket, Haskell and beyond) it's extremely impressive, especially considering the language is so young.

Re: A Video Walkthrough of Swift Fundamentals

#17
post #2

This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…

Well done!

Re: A Video Walkthrough of Swift Fundamentals

#19
post #16

Earlier quoted context omitted.

Hello, While I do not have time to go over the whole video, surely you could have come up with much more serious reasons why Swift might be preferable to Objective C than "uhm, it has no namespaces and looks strange". Also, there were no reasons why "not to use Swift [yet]", making sure to mention the terrible state the developer tools are at this point, as well as many many missing language features and other quirks…

> making sure to mention the terrible state the developer tools are at this point Terrible compared to something like a mature IDE like Visual Studio or Eclipse and/or an established toolchain. Because compared to what most newcomer/not top-10 languages have (languages like D, Racket, Haskell and beyond) it's extremely impressive, especially considering the language is so young.

No, I mean terrible compared to the Objective C/C/C++ Xcode toolchain, normally used where Swift may come in the picture. It needs at least one more year of development and design.

Re: A Video Walkthrough of Swift Fundamentals

#20
post #2

This is my first screencast! I had a lot of fun making it, and I hope you enjoy it. One of my favorite parts of Swift is the optional concept, which separates variables which are never null from variables that can sometimes be null. This helps prevent errors from trying to use objects that don't exist. The syntax involves `!` and `?` which can make your code seem excited and confused, but it's definitely a step towar…

You managed to cover a lot in those 40 minutes. Well done!
Post reply on HN