Tags

Swift

  • Dec 15, 2017

    A view construction syntax

    In this article, I look at constructing Cocoa views in code using a unique syntax that offers dynamic and constant options with no syntactic overhead, support for parameters inherited through the class hierarchy, support for large numbers of optional parameters without needing to push unused parameters onto the stack, avoidance of parentheses, and avoiding the need to specify types – all while remaining completely typesafe.

    cocoaswiftviews

    Read article

  • Dec 27, 2016

    Reference counted releases in Swift

    A discussion about reference counted lifetimes in Swift; how the lifetime of scope variables differs from C++ and Objective-C, how releases are reordered by the Swift compiler and the conventional use of withExtendedLifetime versus my unconventional usage.

    swift

    Read article

  • Sep 22, 2016

    Optimizing a copy-on-write double-ended queue in Swift

    I present an implementation of a a double-ended queue type (deque) in Swift and look at what is required to implement copy-on-write in an optimized way so that this double-ended queue is faster than Array when used as a first-in-first-out (FIFO) queue.

    Swiftfundamentals

    Read article

  • Aug 23, 2016

    Values and errors, part 2: eight languages compared

    A concrete look at the languages studied by the Swift developers when designing Swift's approach to error handling. By comparing these to Swift, I'll try to better understand what balance the Swift developers sought on the topics of feature complexity, syntactic efficiency, abstraction, information signalling and safety.

    Swifterror handling

    Read article

  • Aug 21, 2016

    Values and errors, part 1: 'Result' in Swift

    In this article, I'll discuss the Result type in Swift as well as common variations in implementation and approach used for this data type. I'll also look at *why* the type was rejected for inclusion in the standard library and what effect that rejection is likely to have.

    Swiftfundamentalserror handling

    Read article

  • Jul 12, 2016

    Exponential time complexity in the Swift type checker

    One of the most annoying problems in Swift is when the compiler gives an 'Expression was too complex to be solved in a reasonable time' error. I look at why this error occurs, how to avoid it and talk about how this should be solved in a future compiler update.

    Swiftcompiler

    Read article

  • Jun 25, 2016

    Parsing whitespace in an Xcode extension

    Fun with a pushdown automaton (implemented as a single mighty switch statement) for parsing whitespace in Swift source files. The result is an Xcode 8 Source Editor Command extension for detecting and correcting whitespace issues in Swift files.

    SwiftparsingXcode

    Read article

  • Jun 2, 2016

    Mutexes and closure capture in Swift

    I'm going to talk about the absence of any threading or thread synchronization language features in Swift and the concurrency proposal for Swift's future. I'll also try to get a wrapper around different mutex machinery to perform optimally.

    Swiftasynchrony

    Read article

  • May 19, 2016

    Random number generators in Swift

    I present a few random number generators in Swift and investigate their quality versus performance. I also look at performance implementations and see if I can make a C algorithm run as fast as Swift.

    Swiftmathematics

    Read article

  • May 1, 2016

    Comparing Swift to C++ for parsing

    I present an implementation of Swift's Demangle.cpp, rewritten in Swift and use the two versions (the original C++ and my Swift version) to compare the C++ and Swift for writing parsers.

    Swiftparsing

    Read article

  • Mar 27, 2016

    Breaking Swift with reference counted structs

    Struct types are not usually heap allocated, reference counted or able to perform work on deallocation. You can coerce them into having these properties but careful if you do: it can be a source of memory leaks, errant behavior and compiler crashes.

    hacksSwift

    Read article

  • Feb 28, 2016

    Tracking tasks with stack traces in Swift

    In this tongue-twister titled article, I discuss capturing control flow information with stack traces during ongoing tasks to aid debugging. Also included: a reimplementation of NSThread.callStackReturnAddresses in Swift for faster and more flexible stack traces.

    Swiftdebug analysis

    Read article

  • Feb 16, 2016

    Use it or lose it: why safe C is sometimes unsafe Swift

    Swift and C have different memory layouts. This means that using Swift to call C functions in a manner that would be valid in C can cause memory safety problems. I'll show how this can occur with a subtle Release build bug inspired by issues that occurred while writing the previous article.

    Swift

    Read article