Live data from Hacker News

WWDC 2018 What's New in Swift Recap

roadfiresoftware.com

11–20 of 45 posts

Re: WWDC 2018 What's New in Swift Recap

#11
post #2

has swift made the leap to server side yet? i keep hearing mumblings about that.

In addition to Vapor which other commenters have mentioned, Apple itself released Swift-NIO, a port of Netty to Swift that they’re actively developing - https://github.com/apple/swift-nio

It’s somewhat lower-level than web frameworks people may be used to coming from a Ruby/Node background, but it’s pretty powerful.

Re: WWDC 2018 What's New in Swift Recap

#13
>>New hashing algorithm

>>Hash values vary from run to run (so don’t depend on hash values or order)

I must be reading this wrong. One of the requirements for a good hash function is determinism - specifically that any given value in the input space maps to exactly one value in the output space.

Re: WWDC 2018 What's New in Swift Recap

#14

>>New hashing algorithm >>Hash values vary from run to run (so don’t depend on hash values or order) I must be reading this wrong. One of the requirements for a good hash function is determinism - specifically that any given value in the input space maps to exactly one value in the output space.

The hashing algorithm can be deterministic however hashing relies on a seed. In most cases you want that to be random to prevent certain side channel attacks. For swift, hashing will be deterministic for the lifetime of the program.

Re: WWDC 2018 What's New in Swift Recap

#15
post #6

Yessssss for the allCases property for enums!!! Enums are really the best feature of Swift. I enum all the things everywhere. This is kind of the finishing touch to it. Binary stability would be nice. I do care about the download sizes of my apps. What's really missing from the language is a way to add custom tags like @discardableResult @objc to define some kind of property. It's such a kludge to set up things like…

It isn't too hard to setup two-way binding with KVO if you wanted to.

You can have one way binding, you can have binding with a transformer function to go from a number to a string etc.

Here's a playground where I did this a while back. You get type safety and nice syntax too.

https://gist.github.com/desugaring/828e9880f747678ac5912a070...

Re: WWDC 2018 What's New in Swift Recap

#16
post #14

>>New hashing algorithm >>Hash values vary from run to run (so don’t depend on hash values or order) I must be reading this wrong. One of the requirements for a good hash function is determinism - specifically that any given value in the input space maps to exactly one value in the output space.

The hashing algorithm can be deterministic however hashing relies on a seed. In most cases you want that to be random to prevent certain side channel attacks. For swift, hashing will be deterministic for the lifetime of the program.

That makes sense. I was thinking in terms of global lookup keys, which would require hashes to persist across runs. When thinking in terms of object equality, the hashes need only live as long as the objects themselves. Namely, for the lifetime of the program.

Re: WWDC 2018 What's New in Swift Recap

#17
post #12

Is there a plan for c++ Interop in swift. Or have they decided that using the obj-c bridging layer is enough.

AFAIK it’s still in the cards but it’ll come after ABI stability. I have at least one project that’ll make use of this — can’t wait to drop the ObjC layer in it entirely.

Re: WWDC 2018 What's New in Swift Recap

#18
post #14

>>New hashing algorithm >>Hash values vary from run to run (so don’t depend on hash values or order) I must be reading this wrong. One of the requirements for a good hash function is determinism - specifically that any given value in the input space maps to exactly one value in the output space.

The hashing algorithm can be deterministic however hashing relies on a seed. In most cases you want that to be random to prevent certain side channel attacks. For swift, hashing will be deterministic for the lifetime of the program.

wait, hashing relies on a seed?! isn't that a salt/pepper?

to be "deterministic for the lifetime of the program" sounds like a pepper is being applied, not that the hash algorithm is different.

Re: WWDC 2018 What's New in Swift Recap

#19
post #8
post #7

Earlier quoted context omitted.

Still not as fast and probably Objective-C got a speed boost as well. Objective-C is a very simple language and types are quite explicit. In Swift you have implied types like: let result = jsonList.map { Class(from: $0) }.filter { $0.isSelected }.map { T(from: $0 } Or worse: let myDict = ["key": 1, "key2": 0.2, "key3": "something"] It has to figure out it's not an int, not a number but an Any dict. Complexity to figu…

Type inference, at least for variables doesn't really take that much time. In practice almost every language does it, they just don't expose it to the developer. For example you can do this in C: foo->bar()->baz() And the compiler has to get the type for the bar() result. That's one a small step from: let x = foo->bar() Also that dictionary is most likely parsed and assigned a type in the expression whether you speci…

That is way too oversimplified case of type inference. A huge lot of languages don't have this:

    let x = (f ? makeDerived1() : makeDerived2()); // no error, x is inferred to be Base

    let x = 1;
    x *= 2;
    x = sin(x) / x; // no error, x is inferred to be Float
The problem is not just that extra computation is needed, it's language design. For example, you probably do not expect a dictionary of Floats and a zero to be a dictionary of Any, but how are you going to implement that in the compiler?

Re: WWDC 2018 What's New in Swift Recap

#20
post #10

> Swift 5 (Early 2019): > binary compatibility with future Swift releases I bet this doesn't really happen, though it probably makes the day when it really happens closer. (I don't just mean they might miss the date, but that (1) they miss the date by a lot; and/or (2) they drop binary compatibility from Swift 5; and/or (3) they claim they've achieved binary compatibility but it doesn't out to be true for long, less…

It was already promised in Swift 4 and delayed to 5, you think it will continue to slip?
Post reply on HN