Live data from Hacker News

Dictionary and Set Improvements in Swift 4.0

swift.org

31–40 of 71 posts

Re: Dictionary and Set Improvements in Swift 4.0

#31

I really wish Swift could find a way to be useful on platforms other than Apple. I'd be willing to commit more to it if I could write truly portable code in it. It's got a good start on Linux, but Windows and Android would be cool too. Though Kotlin won out over Swift for Android (very similar languages but I like Swift a bit better there).

It's probably going to end up similar to the equally hyped objectiveC where the core language was made portable but few of the tooling/API's used for real world OSX applications ended up supporting anything but OSX in any production ready capacity despite GNUSTEP actually shipping a ObjetiveC/OpenSTEP clone for Linux. For the time being swift on Linux is a case of a few PaaS vendors trying to product differentiate by…

One of the biggest causes of this for Objective-C was the lack of the Foundation framework (a higher-level interface to Core Foundation) - but this is being reimplemented in Swift. See https://github.com/apple/swift-corelibs-foundation

Of course UIKit will still be missing, but thats sort of expected.

Re: Dictionary and Set Improvements in Swift 4.0

#33
post #32
post #28

Some nice improvements but could have really used a syntax for anonymous functions that makes. Why did they choose this wierd { parameter in doSomething(parameter) } syntax?

You can also shorten it to: { doSomething($0) }

Or just

doSomething

Re: Dictionary and Set Improvements in Swift 4.0

#34

I really wish Swift could find a way to be useful on platforms other than Apple. I'd be willing to commit more to it if I could write truly portable code in it. It's got a good start on Linux, but Windows and Android would be cool too. Though Kotlin won out over Swift for Android (very similar languages but I like Swift a bit better there).

You can use Swift on Windows: https://github.com/apple/swift/blob/master/docs/Windows.md

https://github.com/apple/swift/blob/master/README.md:

”macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are the current supported host development operating systems”

Also, on the page you reference:

”Note that all compiled Swift binaries are only executable within Bash on Windows and are Ubuntu, not Windows, executables.”

Re: Dictionary and Set Improvements in Swift 4.0

#35

Earlier quoted context omitted.

Are you aware that Xcode 9 just shipped last week and is a major rewrite of much of the IDE? It's one of the largest updates in Xcode's history.

Xcode 9 has been a lot less stable for me compared to previous versions. It will lock-up multiple times per day during simple text editing tasks, with SourceKitService going bananas until I force quit it.

It boggles the mind that they just can’t seem to fix SourceKitService for three versions now, it’s such a massive part of making the Xcode experience suck.

It’s worse than no completion, you never know when it’s actually going to work.

I guess it does do something though, for eating up all those cycles.

Re: Dictionary and Set Improvements in Swift 4.0

#36
post #5

The language definitely feels like it has matured as the change from 3.0 to 4.0 was pretty much painless. The big issue with programming in Swift is no longer swift itself but the libraries around it. A lot of the API's you use in day to day Cocoa programming are based on Objective-C and often stringly typed and not very compile safe. For example NSNotificationCenter, setting attributed strings, core data or fetching…

Attributed Strings got better type information in Swift 4 (it got what Notification keys got in Swift 3), but like notifications it's an open-ended API so I don't know what else you can do... You can't use an enum for the keys because it supports custom attributes (at least you can't without exposing a `.custom(name: String)` case, which would defeat the purpose). And the values can be different types (enums for unde…

True, but that's exactly the kind of change to the API required to make it more compile-safe. I still managed to crash this API by not providing a .rawValue somewhere. I don't think applications need to crash on key-value errors.

An enum wouldn't be so bad if it also would use the associated value. Would make it impossible to set the wrong value at least.

Re: Dictionary and Set Improvements in Swift 4.0

#37
post #28

Some nice improvements but could have really used a syntax for anonymous functions that makes. Why did they choose this wierd { parameter in doSomething(parameter) } syntax?

Looks fine to me. What's wrong about that syntax?

Well, for starters, what does it mean? I haven’t seen that in any other language.

Re: Dictionary and Set Improvements in Swift 4.0

#39

Earlier quoted context omitted.

Are you aware that Xcode 9 just shipped last week and is a major rewrite of much of the IDE? It's one of the largest updates in Xcode's history.

XCode 9 is unsurprisingly terrible for me. Between it and the Swift tool chain, they use over 10 gbs of memory and constantly using 100% of my CPU. XCode 9 seems like an improvement over 8 in some cases, but its way less stable, uses an insane amount of resources, and crashes more often.

It’s been so bad that I actually installed Jetbrains AppCode. It’s working great . I finally just bought the entire subscription since I already use IntelliJ, datagrip, gogland, and webstorm

Re: Dictionary and Set Improvements in Swift 4.0

#40

Earlier quoted context omitted.

Looks fine to me. What's wrong about that syntax?

Well, for starters, what does it mean? I haven’t seen that in any other language.

It is similar to let var=..... in exp from ML languages.
Post reply on HN