To contribute to this issue, simply leave a comment here. Please also review our contributing guidelines.
The current draft for this issue in _drafts/. If you want to contribute directly, feel free to open a pull request.
Rearchitecting JSONEncoder to be much faster
Currently, JSONEncoder can spend a lot of time doing the following things:
- Creating intermediate Swift/ObjC data structures to pass to JSONSerialization
- Creating a new Swift String for each key conversion
Inside of JSONSerialization, using libc functions to convert numbers to stringsAll of these things can be resolved with a different architecture. There may be other good ones, and if so I'd love to hear about them, but here's what I'll pitch:
Whenever an encode method is called, write the JSON out directly, rather than storing anything in dictionaries or delegating any work to JSONSerialization. The one tricky bit is that it may be told to encode something that needs to come later after other, unseen, pieces of data are encoded. For example:
https://forums.swift.org/t/rearchitecting-jsonencoder-to-be-much-faster/28139
After a lot of fiddly work, the Swift runtime and standard library no longer depend on Foundation! (they’ll still use it for bridging if it’s present)
https://github.com/apple/swift/pull/26630
Next up: finding out where the last thing linking CoreFoundation is hiding and decoupling from that too
262 returned for review
https://forums.swift.org/t/returned-for-revision-se-0262-demangle-function/28186
Formally revoking SE-0042
SE-0042 was formally accepted more than three years ago. However, since the proposal was accepted before having a working implementation was a requirement, and the change would be source breaking, and also require massive rewrites of the compiler; it is now clear that this proposal will never actually be implemented. It has been obvious for a long time.
A new binary-search attempt
Continuing the discussion from An always-sorted set:
I just updated the gist to Revision 2, which updates the "BinarySearch.swift" file.
https://forums.swift.org/t/a-new-binary-search-attempt/28195
Confirming a sort or partition
Continuing the discussion from A new binary-search attempt:
I was thinking of some extension from the binary search on collections that can work for sequences. Then I came up with checking if a sequence matches a given partition (with a partitioning predicate) or sort (with a comparison predicate and monotonic flag). These match the std::is_partitioned, std::is_sorted, and std::is_sorted_until functions from C++.
https://forums.swift.org/t/confirming-a-sort-or-partition/28206
What is libswiftabi /
Following the returned for revision announcement for SE-0262, one of the bullet points to discuss was a new "Runtime" module in Swift, separate to the stdlib. I want to open discussion on what that might look like and what other features it might entail. The core team believes that a demangle function would make for a "natural candidate" for such module, but Joe also mentioned that other functionality from the Swift runtime could be used for things like reflection. Could this module be where full reflection support would be implemented, or just some of the building blocks? What other "low-level" features could this potentially offer?
Another important question to consider: what would be a good name for this module? Kidding aside, it seemed implied that we could name this Runtime, but considering potential other features, are there any other names that could fit the bill as well?
https://forums.swift.org/t/what-is-libswiftabi-swift-runtime-h/28201
Future of Diagnostics UX
Lately, I've been thinking about how the diagnostics user experience for Swift could be improved in the long term. I thought it would be valuable to start a conversation around what kind of improvements people would like to see and what we can learn from other compilers, maybe resulting in some kind of rough roadmap if there's enough interest.
https://twitter.com/jckarter/status/1166029901335412738
Another cool optimization from Erik to eliminate temporary copies during in-place updates of enum payloads like:
switch e {
case .A(var arr):
arr.append(x)
e = .A(arr)
https://twitter.com/Catfish_Man/status/1166786023667318784
Extremely cool proposal from @Ilseman for slicing and dicing collections ergonomically in Swift
https://forums.swift.org/t/pitch-offset-indexing-and-slicing/28333
Allowing explicit @escaping for optional closures in function parameters
I drafted a formal proposal to introduce explicit @escaping for optional closures in function parameters. Unfortunately, I don't have the necessary knowledge to build a working implementation for this proposal. I was hoping that someone could point me on the right direction or pair me in the process.
Adding a “does X conform to Y” request
https://forums.swift.org/t/adding-a-does-x-conform-to-y-request/28349
https://twitter.com/johannesweiss/status/1167538133401067520
Coincidentally @gottesmang just demonstrated how much a bug+benchmark can help:
The NIO ChannelPipeline benchmark runs in HALF the time. This improvement should make a real difference in NIO!
Michael, thanks so much, this is awesome.
https://github.com/apple/swift/pull/26956 https://twitter.com/johannesweiss/status/1167526400330539009
Starter bug https://bugs.swift.org/browse/SR-11397
https://twitter.com/swift_unwrapped/status/1168525041434333184
Episode 78: Binary Dependencies in Swift Package Manager https://spec.fm/podcasts/swift-unwrapped/307679
Pitch: Fully qualified name syntax
Swift's name lookup is…messy. Very messy. This causes a number of problems, and today I'd like to talk about a potential solution for one of them.
...
https://forums.swift.org/t/pitch-fully-qualified-name-syntax/28482
The August release is out: Swift 5.0.3 for Linux, here we go: https://forums.swift.org/t/swift-5-0-3-for-linux/28523 .
Thanks very much for the contributions! Docker images should be available soon too.
https://twitter.com/johannesweiss/status/1169284396718968833
Great article about sort in Swift https://swiftrocks.com/introsort-timsort-swifts-sorting-algorithm.html
263 in review
Thanks again for all the great help, @fassko — I wouldn't be able to compile the newsletter currently without you. 😊
@BasThomas no worries, if it's too much in your place I could take over some of the next issues.
It's OK — especially gathering the content helps. 😊
Most helpful comment
https://twitter.com/swift_unwrapped/status/1168525041434333184