NSBlog
"A failure in the hot air department"
Showing entries tagged "fridayqna". Full blog index.
Friday Q&A 2018-06-29: Debugging with C-Reduce
at 2018-06-29 13:35
Debugging a complex problem is tough, and it can be especially difficult when it's not obvious which chunk of code is responsible. It's common to attempt to produce a reduced test case in order to narrow it down. It's tedious to do this manually, but it's also the sort of thing computers are really good at. C-Reduce is a program which automatically takes programs and pares them down to produce a reduced test case. Let's take a look at how to use it.
Friday Q&A 2018-04-27: Generating Text With Markov Chains in Swift
at 2018-04-28 01:27
Markov chains make for a simple way to generate realistic looking but nonsensical text. Today, I'm going to use that technique to build a text generator based on this blog's contents, an idea suggested/inspired by reader Jordan Pittman.
Friday Q&A 2017-12-08: Type Erasure in Swift
at 2017-12-15 14:09
You might have heard the term type erasure. You might have even used type-erased types in the standard library, such as
AnySequence
. But what exactly is type erasure and how do you do it yourself? In this article, I'll explore type erasure, why you'd want it, and how to make it happen, a topic suggested by Lorenzo Boaro.Friday Q&A 2017-11-10: Observing the A11's Heterogenous Cores
at 2017-11-10 12:41
Apple's newest mobile CPU, the A11, brings a new level of heterogeneous computing to iOS, with both high and low performance cores that are always on. With the release of the iPhone X, I set out to see if I could observe these heterogeneous cores in action.
Friday Q&A 2017-10-27: Locks, Thread Safety, and Swift: 2017 Edition
at 2017-10-27 11:28
Back in the dark ages of Swift 1, I wrote an article about locks and thread safety in Swift. The march of time has made it fairly obsolete, and reader Seth Willits suggested I update it for the modern age, so here it is!
Friday Q&A 2017-10-06: Type-Safe User Defaults
at 2017-10-06 12:55
It's fun to re-imagine traditional techniques with a Swift twist. I've implemented a type-safe layer on top of the venerable
NSUserDefaults
, and I'm going to discuss my little library today. Credit/blame for this idea goes to local reader José Vazquez, although he inspired it by accident while talking about something else.Friday Q&A 2017-09-22: Swift 4 Weak References
at 2017-09-23 00:57
Soon after Swift was initially open sourced, I wrote an article about how weak references are implemented. Time moves on and things change, and the implementation is different from what it once was. Today I'm going to talk about the current implementation and how it works compared to the old one, a topic suggested by Guillaume Lessard.
Friday Q&A 2017-08-25: Swift Error Handling Implementation
at 2017-08-25 13:13
Swift's error handling is a unique feature of the language. It looks a lot like exceptions in other languages, but the syntax is not quite the same, and it doesn't quite work the same either. Today I'm going to take a look at how Swift errors work on the inside.
Friday Q&A 2017-08-11: Swift.Unmanaged
at 2017-08-11 13:14
In order to work with C APIs, we sometimes need to convert Swift object references to and from raw pointers. Swift's
Unmanaged
struct
is the standard API for handling this. Today, I'd like to talk about what it does and how to use it.Friday Q&A 2017-07-28: A Binary Coder for Swift
at 2017-07-28 12:44
In my last article I discussed the basics of Swift's new
Codable
protocol, briefly discussed how to implement your own encoder and decoder, and promised another article about a custom binary coder I've been working on. Today, I'm going to present that binary coder.Friday Q&A 2017-07-14: Swift.Codable
at 2017-07-14 13:57
One of the interesting additions to Swift 4 is the
Codable
protocol and the machinery around it. This is a subject near and dear to my heart, and I want to discuss what it is and how it works today.Friday Q&A 2017-06-30: Dissecting objc_msgSend on ARM64
at 2017-07-01 04:23
We're back! During the week of WWDC, I spoke at CocoaConf Next Door, and one of my talks involved a dissection of
objc_msgSend
's ARM64 implementation. I thought that turning it into an article would make for a nice return to blogging for Friday Q&A.Friday Q&A 2016-04-15: Performance Comparisons of Common Operations, 2016 Edition
at 2016-04-15 13:20
Back in the mists of time, before Friday Q&A was a thing, I posted some articles running performance tests on common operations and discussing the results. The most recent one was from 2008, running on 10.5 and the original iPhone OS, and it's long past time to do an update.
Friday Q&A 2016-03-04: Swift Asserts
at 2016-03-04 14:30
Asserts are really useful for checking assumptions in code to ensure that errors are caught early and often. Today, I'm going to explore the assert calls available in Swift and how they're implemented, a topic suggested by reader Matthew Young.
Friday Q&A 2016-02-19: What Is the Secure Enclave?
at 2016-02-19 14:40
The big tech news this week is that the FBI is trying to force Apple to unlock a suspect's iPhone. One of the interesting points around this story is that the iPhone in question is an older one, an iPhone 5c. Newer phones have what Apple calls the Secure Enclave, which some say protects against requests of this nature; even if Apple wanted to break into your phone, they couldn't. Which then brings up an interesting question I've seen a lot of people asking: what exactly is the Secure Enclave, and what role does it play here?
Friday Q&A 2016-01-29: Swift Struct Storage
at 2016-01-29 14:57
Swift's
class
es tend to be straightforward for most people new to the language to understand. They work pretty much like classes in any other language. Whether you've come from Objective-C or Java or Ruby, you've worked with something similar. Swift's struct
s are another matter. They look sort of like class
es, but they're value types, and they don't do inheritance, and there's this copy-on-write thing I keep hearing about? Where do they live, anyway, and how do they work? Today, I'm going to take a close look at just how struct
s get stored and manipulated in memory.Friday Q&A 2015-12-25: Swifty Target/Action
at 2015-12-25 15:11
Cocoa's target/action system for responding to controls is a great system for Objective-C, but is a bit unnatural to use in Swift. Today, I'm going to explore building a wrapper that allows using a Swift function as the action.
Friday Q&A 2015-12-11: Swift Weak References
at 2015-12-11 14:16
In case you have been on Mars, in a cave, with your eyes shut and your fingers in your ears, Swift has been open sourced. This makes it convenient to explore one of the more interesting features of Swift's implementation: how weak references work.
Friday Q&A 2015-11-20: Covariance and Contravariance
at 2015-11-20 14:16
Subtypes and supertypes are a common part of modern programming. Covariance and contravariance tell us where subtypes are accepted and where supertypes are accepted in place of the original type. This shows up frequently in most of the programming most of us do, but many developers are unaware of the concepts beyond a loose instinctual sense. Today I'm going to discuss it in detail.
Friday Q&A 2015-11-06: Why is Swift's String API So Hard?
at 2015-11-06 14:00
Welcome to a very delayed edition of Friday Q&A. One of the biggest complaints I see from people using Swift is the
String
API. It's difficult and obtuse, and people often wish it were more like string APIs in other languages. Today, I'm going to explain just why Swift's String
API is designed the way it is (or at least, why I think it is) and why I ultimately think it's the best string API out there in terms of its fundamental design.Friday Q&A 2015-09-18: Building a Gear Warning System
at 2015-09-18 13:29
Today I'm going to go outside my usual set of topics and talk about a fun side project that might broaden your horizons. Or expose my ignorance. A couple of years ago I set out to build a gear warning system for my glider using an Arduino-type system, and I'm going to talk about how it works and what that code looks like.
Friday Q&A 2015-09-04: Let's Build dispatch_queue
at 2015-09-04 13:22
Grand Central Dispatch is one of the truly great APIs to come out of Apple in the past few years. In the latest installment of the Let's Build series, I'm going to explore a reimplementation of the most basic features of
dispatch_queue
, a topic suggested by Rob Rix.Friday Q&A 2015-08-14: An Xcode Plugin for Unsmoothed Text
at 2015-08-14 14:11
Getting Xcode to display unsmoothed text in its editor has been an ongoing battle which finally required me to write an Xcode plugin to impose my will. Several readers asked me to discuss how it works, which is what I'm going to do today.
Friday Q&A 2015-07-31: Tagged Pointer Strings
at 2015-07-31 14:10
Tagged pointers are an interesting technology used to increase performance and reduce memory usage. As of OS X 10.10,
NSString
got the tagged pointer treatment, and today I'm going to take a look at how it works, a topic suggested by Ken Ferry.Friday Q&A 2015-07-17: When to Use Swift Structs and Classes
at 2015-07-17 12:54
One of the persistent topics of discussion in the world of Swift has been the question of when to use
class
es and when to use struct
s. I thought I'd contribute my own version of things today.Friday Q&A 2015-07-03: Address Sanitizer
at 2015-07-03 13:52
Outside of Swift 2 news, one of the exciting announcements to come out of WWDC was that clang's Address Sanitizer is now available directly in Xcode 7. Today I'm going to discuss what it is, how it works, and how to use it, a topic suggested by Konstantin Gonikman.
Friday Q&A 2015-06-19: The Best of What's New in Swift
at 2015-06-19 13:12
Apple made a lot of interesting announcements at WWDC this year about the release of Swift 2 and the new features in it, in among various other announcements of little interest. In addition to the announcement that Swift will be made open source, which is a huge deal all by itself, Swift 2 contains a lot of great new features which significantly improve the language. Today I'm going to talk about the most important ones, what they are, and why they're useful.
Friday Q&A 2015-05-29: Concurrent Memory Deallocation in the Objective-C Runtime
at 2015-06-05 13:06
The Objective-C runtime is at the heart of much Mac and iOS code. At the heart of the runtime is the
objc_msgSend
function, and the heart of that is the method cache. Today I'm going to explore how Apple manages resizing and deallocating method cache memory in a thread safe manner without impacting performance, using a technique you probably won't find in textbooks discussing thread safety.Friday Q&A 2015-05-01: Fuzzing with afl-fuzz
at 2015-05-01 13:24
With computer security high on everyone's minds these days, tools that help assess and improve the security of our code are extremely useful. Today I'm going to talk about one such tool,
afl-fuzz
, which has seen a lot of attention lately and produces some interesting results. I'll discuss how it works and how to use it on your own code.Friday Q&A 2015-04-17: Let's Build Swift.Array
at 2015-04-17 13:42
Swift 1.2 is now available as part of Xcode 6.3, and one of the new APIs it includes allows us to build efficient data structures with value semantics, such as Swift's built-in
Array
type. Today, I'm going to reimplement the core functionality of Array
.Friday Q&A 2015-03-20: Preprocessor Abuse and Optional Parentheses
at 2015-03-20 14:23
The other day I ran into an interesting problem: how can you write a C preprocessor macro that removes parentheses surrounding its argument, but leaves the argument alone if no parentheses are present? For today's article, I'm going to share my solution.
Friday Q&A 2015-02-20: Let's Build @synchronized
at 2015-02-20 14:26
Continuing the theme of thread safety from the previous article, today I'm going to explore an implementation of Objective-C's
@synchronized
facility in the latest edition of Let's Build. I'm going to build it in Swift, although an equivalent Objective-C version would be much the same.Friday Q&A 2015-02-06: Locks, Thread Safety, and Swift
at 2015-02-06 14:23
An interesting aspect of Swift is that there's nothing in the language related to threading, and more specifically to mutexes/locks. Even Objective-C has
@synchronized
and atomic properties. Fortunately, most of the power is in the platform APIs which are easily used from Swift. Today I'm going to explore the use of those APIs and the transition from Objective-C, a topic suggested by Cameron Pulsford.Friday Q&A 2015-01-23: Let's Build Swift Notifications
at 2015-01-23 14:52
NSNotificationCenter
is a useful API that's pervasive in Apple's frameworks, and often sees a lot of use within our own code. I previously explored building NSNotificationCenter
in Objective-C. Today, I want to build it in Swift, but not just another reimplementation of the same idea. Instead, I'm going to take the API and make it faster, better, stronger, and take advantage of all the nice stuff Swift has to offer us.Friday Q&A 2014-11-07: Let's Build NSZombie
at 2014-11-07 16:04
Zombies are a valuable tool for debugging memory management problems. I previously discussed the implementation of zombies, and today I'm going to go one step further and build them from scratch, a topic suggested by Шпирко Алексей.
Friday Q&A 2014-08-15: Swift Name Mangling
at 2014-08-15 14:20
It's been a long time since I wrote a Friday Q&A, but I'm back, with a brand-new post about a brand-new topic: Swift. Over the last few posts, Mike's gone into some detail about what Swift's internal structures looked like, but he's only touched very lightly on what the linker sees when it looks at Swift-containing binaries: mangled symbol names.
Friday Q&A 2014-08-01: Exploring Swift Memory Layout, Part II
at 2014-08-01 14:22
Continuing the theme from the previous article, I'm going to continue exploring implementation details of Swift's memory layout. Today, I'm going to look at the memory layout of generics, optionals, and protocol objects.
Friday Q&A 2014-07-18: Exploring Swift Memory Layout
at 2014-07-18 13:57
Welcome back to another exploration of Swift. Today I'm going to dig into some implementation details and explore how Swift lays out objects and classes in memory.
Friday Q&A 2014-07-04: Secrets of Swift's Speed
at 2014-07-04 13:40
Since the introduction of Swift, speed has been a key selling point. Indeed, it's right in the name of the language. It's said to be faster than dynamic languages like Python or JavaScript, potentially faster than Objective-C, and even claimed to be faster than C for certain cases. But how exactly does it do it?
Friday Q&A 2014-06-20: Interesting Swift Features
at 2014-06-20 13:17
Roughly six hundred million people have asked me to write something about Swift. I'm hoping to write a series of articles about various aspects of it. For today, I want to start things off by exploring a few Swift features that are interesting and unusual from the perspective of Objective-C, and why I think they're going to be good to have.
Friday Q&A 2014-06-06: Secrets of dispatch_once
at 2014-06-06 13:27
Reader Paul Kim pointed out an entry on Michael Tsai's blog about making
dispatch_once
fast. While the comment in the dispatch_once
source code is fascinating and informative, it doesn't quite delve into the detail that some would like to see. Since this is one of my favorite hacks, for today's article I'm going to discuss exactly what's going on there and how it all works.Friday Q&A 2014-05-23: A Heartbleed-Inspired Paranoid Memory Allocator
at 2014-05-23 13:46
The Heartbleed vulnerability made a big splash a couple of months ago, and rightly so. It could be described as a "memory leak", but it's not the standard kind where a program fails to free allocated memory. Instead, it allowed an attacker to dump memory contents from a remote program nearly at will, potentially leaking private keys, passwords, source code, and other data intended to stay secret. This got me thinking about ways to protect sensitive data against similar attacks. The result is MAParanoidAllocator, and in this article I'll discuss the implementation.
Friday Q&A 2014-05-09: When an Autorelease Isn't
at 2014-05-09 13:59
Welcome back to another Friday Q&A. I apologize for the unannounced hiatus in posts. It's not due to anything interesting, just a shortage of time. Friday Q&A will continue, and I will continue to aim for my regular biweekly postings. For today's article, I have a little story about an
autorelease
call that didn't do what it was supposed to do.Friday Q&A 2014-03-14: Introduction to the Sockets API
at 2014-03-14 13:52
Network programming is everywhere these days. It's tough to find an iPhone app that doesn't use the network for something. We also spend a lot of our time abstracted away from the details of networking, using high-level APIs like
NSURLConnection
. Today I'm going to walk you through the lowest-level API you can find without diving into the kernel, the POSIX sockets API.Friday Q&A 2014-01-24: Introduction to libclang
at 2014-01-24 15:01
In addition to its many other fine attributes, the Clang compiler also provides a clean API that makes it easy to use its facilities as a library in your own code. Today, I'm going to give a basic introduction to this library and how to use it, a topic suggested by reader Jeffrey Macko.
Friday Q&A 2014-01-10: Let's Break Cocoa
at 2014-01-10 14:58
The Let's Build articles are my favorite on this blog. Sometimes, though, it's more fun to break things than to build them. Today, I'm going to explore some amusing and unusual ways to break Cocoa.
Friday Q&A 2013-12-06: Network Protocol Design
at 2013-12-06 13:29
In this age of REST and HTTP and massive inefficiency in internet communications, the need for custom network protocols is rare. However, it does happen sometimes, and when it does, I want to make sure it's done right. With that aim, I'm going to discuss some guidelines for designing network protocols, a topic suggested by Mike Shields.
Friday Q&A 2013-10-25: NSObject: the Class and the Protocol
at 2013-10-25 13:27
Reader Tomas Bouda asks: what's the deal with the
NSObject
protocol? There are two NSObjects
in Cocoa, a class and a protocol. Why both? What purpose do they serve? In today's article, I'll explore the answer to this question.Friday Q&A 2013-10-11: Why Registers Are Fast and RAM Is Slow
at 2013-10-11 14:14
In the previous article on ARM64, I mentioned that one advantage of the new architecture is the fact that it has twice as many registers, allowing code load data from RAM less often, which is much slower. Reader Daniel Hooper asks the natural question: just why is RAM so much slower than registers?
Friday Q&A 2013-09-27: ARM64 and You
at 2013-09-27 13:31
Ever since the iPhone 5S was announced a couple of weeks ago, the world of tech journalism has been filled with massive quantities of misinformation. Unfortunately, good information takes time, and the world of tech journalism is more about speed than accuracy. Today, as suggested by a variety of readers, I'm going to give the rundown of just what 64-bit ARM in the iPhone 5S means for you, in terms of performance, capabilities, and development.
Friday Q&A 2013-09-13: A Library for Easier Property List Type Checking and Error Reporting
at 2013-09-13 15:35
As I promised last time, today I'm going to discuss a library I've been working on that makes the task of type-checking property lists much less verbose and painful.
Friday Q&A 2013-08-30: Model Serialization With Property Lists
at 2013-08-30 13:35
Object serialization is a common requirement for saving files to disk, communicating over a network, or simply persisting settings. Today, I'm going to talk about the basics of using property lists for object serialization, a topic suggested by Nicolas Goles.
Friday Q&A 2013-08-16: Let's Build Dispatch Groups
at 2013-08-17 02:19
Dispatch groups are a handy facility for synchronizing multiple tasks, and an anonymous reader suggested them for the subject of today's Let's Build.
Friday Q&A 2013-08-02: Type-Safe Scalars with Single-Field Structs
at 2013-08-02 15:01
Welcome back, and apologies for going silent without warning. Something resembling normality has resumed, and so I hope to also resume something resembling my normal schedule. In any case, for today's article, local reader Michael Manesh suggested that I talk about how you can use (or abuse) C's type system to obtain stronger typing guarantees by creating
struct
s containing only a single field.Friday Q&A 2013-06-28: Anatomy of a Compiler Bug
at 2013-06-28 13:04
Some people have a favorite color or a favorite food. It may come as no surprise that I have a favorite compiler bug. Today, I'm going to demonstrate it and pick it apart, a topic suggested by reader Daniel Jalkut.
Friday Q&A 2013-06-14: Reachability
at 2013-06-14 13:49
Networking is playing an ever more important role in application development, and Apple's reachability API is a valuable tool in making network-centric apps play nicely with varying real-world conditions. Today I'm going to give an overview of the reachability API, what it does, and how to use it, a suggestion from reader Manuel Diaz.
Friday Q&A 2013-05-31: C Quiz
at 2013-05-31 13:46
I thought I'd mix things up a bit today and give my readers a quiz. The C language is perhaps the most popular computer language in existence, but it's also quite odd, and because of that often poorly understood. I'd like to give you a quiz to see how much you know about some of the odd but useful corners of the language.
Friday Q&A 2013-05-17: Let's Build stringWithFormat:
at 2013-05-17 14:40
Our long effort to rebuild Cocoa piece by piece continues. For today, reader Nate Heagy has suggested building
NSString
's stringWithFormat:
method.Friday Q&A 2013-05-03: Proper Use of Asserts
at 2013-05-03 13:03
Asserts are a powerful tool for building quality code, but they're often poorly understood. Today, I want to discuss the various options for writing asserts in Cocoa apps and the best ways to use them, a topic suggested by reader Ed Wynne.
Friday Q&A 2013-04-05: Windows and Window Controllers
at 2013-04-05 13:36
It's time to take a turn to some lighter fare, but to a subject that's near and dear to my heart. The fundamental UI component of a Cocoa app is the NSWindow, and there are many different ways to instantiate and manage them, but there is only one correct way: for each type of window, there should be a separate nib file, and a specialized
NSWindowController
subclass. I'll walk through what this means and how to do it, a topic suggested by reader Mike Shields.Friday Q&A 2013-03-22: Let's Build NSInvocation, Part II
at 2013-03-22 14:57
Last time on Friday Q&A, I began the reimplementation of parts of
NSInvocation
as MAInvocation
. In that article, I discussed the basic theory, the architecture calling conventions, and presented the assembly language glue code needed for the implementation. Today, I present the Objective-C part of MAInvocation
.Friday Q&A 2013-03-08: Let's Build NSInvocation, Part I
at 2013-03-08 14:33
It's time for another trip into the nether regions of the soul. Reader Robby Walker suggested an article about
NSInvocation
, and I have obliged, implementing it from scratch for your amusement. Today I'll start on a guided tour down the hall of horrors that is MAInvocation
, my reimplementation of the NSInvocation
API. It's a big project, so today I'm going to focus on the basic principles and the assembly language glue code, with the rest of the implementation to follow.Friday Q&A 2013-02-22: Let's Build UITableView
at 2013-02-22 15:35
Friday Q&A is driven by the readers, and that's especially true today. Reader Matthew Elton thought that "Let's Build UITableView" would make a good topic for Friday Q&A, but he decided he'd rather implement it himself and write it up rather than wait for me to do it (good move, Matthew). Without further ado, here is Matthew's article an building
UITableView
.Friday Q&A 2013-02-08: Let's Build Key-Value Coding
at 2013-02-08 14:17
Last time, I showed how to build the basic functionality of
NSObject
. I left out key-value coding, because the implementation of valueForKey:
and setValue:forKey:
is complex enough to need its own article. This is that article.Friday Q&A 2013-01-25: Let's Build NSObject
at 2013-01-25 15:32
The
NSObject
class lies at the root of (almost) all classes we build and use as part of Cocoa programming. What does it actually do, though, and how does it do it? Today, I'm going to rebuild NSObject
from scratch, as suggested by friend of the blog and occasional guest author Gwynne Raskind.Friday Q&A 2013-01-11: Mach Exception Handlers
at 2013-01-11 14:44
This is my first guest Friday Q&A article, dear readers, and I hope it will withstand your scrutiny. Today's topic is on Mach exception handlers, something I've recently spent some time exploring on Mac OS X and iOS for the purpose of crash reporting.
While there is surprisingly little documentation available about Mach exception handlers, and they're considered by some to be a mystical source of mystery and power, the fact is that they're actually pretty simple to understand at a high level - something I hope to elucidate here. Unfortunately, they're also partially private API on iOS, despite being used in a number of new crash reporting solutions - something I'll touch on in the conclusion.
Friday Q&A 2012-12-28: What Happens When You Load a Byte of Memory
at 2012-12-28 14:45
The hardware and software that our apps run on is almost frighteningly complicated, and there's no better place to see that than in the contortions that the system goes through when we load data from memory. What exactly happens when we load a byte of memory? Reader and friend of the blog Guy English suggested I dedicate an article to answering that question.
Friday Q&A 2012-12-14: Objective-C Pitfalls
at 2012-12-14 14:38
Objective-C is a powerful and extremely useful language, but it's also a bit dangerous. For today's article, my colleague Chris Denter suggested that I talk about pitfalls in Objective-C and Cocoa, inspired by Cay S. Horstmann's article on C++ pitfalls.
Friday Q&A 2012-11-30: Let's Build A Mach-O Executable
at 2012-11-30 17:59
This is something of a followup to my last article, dyld: Dynamic Linking On OS X, in which I explored how the dynamic linker
dyld
does its job. This week, I'm going to recreate the function of both the compiler and the static linker, building a Mach-O binary completely from scratch with only the help of the assembler.Friday Q&A 2012-11-16: Let's Build objc_msgSend
at 2012-11-16 14:27
The
objc_msgSend
function underlies everything we do in Objective-C. Gwynne Raskind, reader and occasional Friday Q&A guest contributor, suggested that I talk about how objc_msgSend
works on the inside. What better way to understand how something works than to build it from scratch? Let's build objc_msgSend
.Friday Q&A 2012-11-09: dyld: Dynamic Linking On OS X
at 2012-11-09 15:51
In the course of a recent job interview, I had an opportunity to study some of the internals of
dyld
, the OS X dynamic linker. I found this particular corner of the system interesting, and I see a lot of people having trouble with linking issues, so I decided to do an article about the basics of dynamic linking. Some of the deeper logic is new to me, so sorry in advance for any inaccuracies.Friday Q&A 2012-08-24: Things You Never Wanted To Know About C
at 2012-08-24 13:15
It's been a bit since I did an article, but I'm back again, with a somewhat off-the-cuff treatment of a very twisted set of code I use to pretend that C has exceptions. I delve into little-known extensions of C, Linux compatibility, and worst of all,
goto
, so be warned!Friday Q&A 2012-07-27: Let's Build Tagged Pointers
at 2012-07-27 13:35
Last time on Friday Q&A, I discussed a hypothetical implementation of the
NSNumber
class. Starting on Mac OS X 10.7 and iOS 5, NSNumber
uses a new runtime facility called tagged pointers to increase speed and reduce memory usage, the inner workings of which I want to examine today.Friday Q&A 2012-07-06: Let's Build NSNumber
at 2012-07-06 15:08
NSNumber
is a deceptively simple class with some interesting implementation details. In today's edition of Friday Q&A, I'll explore how to build a class that works like NSNumber
, a topic suggested by Jay Tamboli.Friday Q&A 2012-06-22: Objective-C Literals
at 2012-06-22 14:17
Welcome back! After a brief hiatus for WWDC, it's time for another wacky adventure. Today's topic is the new object literals syntax being introduced into Objective-C, which was suggested by reader Frank McAuley.
Friday Q&A 2012-06-01: A Tour of PLWeakCompatibility: Part II
at 2012-06-01 13:38
Last time, I discussed the basics of PLWeakCompatibility in terms of the motivation, the basic hooks used to get the compiler to call our code when handling
__weak
variables, and calling through to the original implementations where available. Today, I'm going to discuss the implementation of the zeroing weak reference facility that gets used when the runtime doesn't supply its own __weak
support.Friday Q&A 2012-05-18: A Tour of PLWeakCompatibility: Part I
at 2012-05-18 16:53
A few weeks ago, I introduced
PLWeakCompatibility
. This is a small library that can be dropped into an app to enable use of the __weak
qualifier on OSes that don't support it. ARC is officially supported on Mac OS X 10.6 and iOS 4, but __weak
is only available on 10.7 and iOS 5. PLWeakCompatibility
adds support for __weak
on those older OSes when using ARC. Today I'm going to discuss how PLWeakCompatibility
works on the inside.Friday Q&A 2012-05-04: PLCrashReporter and Unwinding the Stack With DWARF, Part 2
at 2012-05-04 18:44
Here I am, yet again! This week, I'm continuing where my last article left off, regarding PLCrashReporter and unwinding stack frames on x86_64. In particular, I go into how I got at and used all the various data I discussed in last week's article, and why some of the existing solutions in the wild weren't suited for our use.
Friday Q&A 2012-04-27: PLCrashReporter and Unwinding the Stack With DWARF
at 2012-04-27 14:11
I'm back once again for Friday Q&A. Today I'm going to talk about some work I recently did on PLCrashReporter, adding support for unwinding stack frames on x86_64. PLCrashReporter was originally targeted solely at iOS, where both ARM and x86-32 (the simulator) make crash reporting relatively straight-forward; we can simply walk the stack via the preserved frame pointer. On x86-64, matters are different, leading to the need to implement support for alternative methods for stack unwinding. This work was sponsored by HockeyApp, to support their upcoming release of Mac OS X sandbox-compatible crash reporting. I'll talk about DWARF debugging information, the compact unwind encoding, and stack scanners. I assume at least some knowledge of x86_64 architecture, for simplicity's sake.
Friday Q&A 2012-04-13: Nib Memory Management
at 2012-04-13 14:14
I'm back from my hiatus and ready with a fresh journey into the netherworld of Apple's platforms. Today's subject comes from several readers who suggested that I discuss the subtleties of dealing with memory management and nibs, and particularly the differences between the Mac and iOS.
Friday Q&A 2012-03-16: Let's Build NSMutableDictionary
at 2012-03-16 14:55
Last time on Friday Q&A, we discussed how to implement
NSMutableArray
. Today, I'll repeat the same exercise with NSMutableDictionary
and build an implementation of it from scratch.Friday Q&A 2012-03-09: Let's Build NSMutableArray
at 2012-03-09 13:44
Collection classes are ubiquitous in Cocoa apps, but also fairly opaque. Today, at the suggestion of Matthew Elton, I'm going to take a look at how
NSMutableArray
works behind the scenes by building a replacement for it from scratch.Friday Q&A 2012-02-17: Ring Buffers and Mirrored Memory: Part II
at 2012-02-17 12:50
Last time on Friday Q&A, I started talking about implementing a ring buffer using virtual memory tricks to mirror memory. The first article concentrated on those virtual memory tricks. Today, I'm going to fill out the second half of the puzzle and show how to implement the ring buffer on top of the mirrored memory allocator we developed. If you haven't read the previous article yet, I strongly recommend you so so, otherwise the memory mirroring is likely to be confusing.
Friday Q&A 2012-02-03: Ring Buffers and Mirrored Memory: Part I
at 2012-02-03 16:37
Playing with virtual memory is always fun, and one place where it can be put to good use is in building a ring buffer. A ring buffer is a way to implement a FIFO queue of data, and using virtual memory tricks to mirror multiple copies of the same data can make the implementation simpler and better by virtually concatenating noncontiguous data. Readers Jose Vazquez and Dylan Lukes suggested that I explore the building of such a construct. Today I will talk about how to implement the virtual memory tricks, and then in part II I will show how to implement the ring buffer on top of them.
Friday Q&A 2012-01-20: Fork Safety
at 2012-01-20 14:07
It's once again time to dive into bizarre programming arcana. In today's article, I want to look at the details of fork-safe code, why the restrictions are present, and why you might care, a topic suggested by Ben Mitchell.
Friday Q&A 2012-01-13: The Mac Toolbox
at 2012-01-13 19:28
Hi again, readers of NSBlog! This is my first guest post of 2012, and also my first one writing the introduction myself. I plan to do posts every two weeks, alternating with Mike's to bring back the once-a-week format. This week, at my own suggestion, I'm doing a historical piece on the original programming environment for Macs: The Mac Toolbox. Time for a trip down memory lane!
Friday Q&A 2012-01-06: The Hopper Disassembler
at 2012-01-06 15:48
We've spent the last few weeks talking about disassembling executables and how to read the result. Today, I want to wrap up that discussion with a look at a powerful third-party disassembly tool called Hopper.
Friday Q&A 2011-12-30: Disassembling the Assembly, Part 3: ARM edition
at 2011-12-30 21:44
Gwynne finishes off her series on analyzing assembly code with a look at ARM assembly, for all of your iOS needs. Gwynne will be contributing the occasional article in the future as well as a guest author, without my introductions. Watch the Author field at the top of the post to see who's writing what. Without further ado, let's take a look at ARM.
Friday Q&A 2011-12-23: Disassembling the Assembly, Part 2
at 2011-12-23 20:48
Today I have the pleasure to present the followup to last week's guest post. Gwynne Raskind returns to complete her in-depth analysis of the assembly code generated by a small sample program.
Friday Q&A 2011-12-16: Disassembling the Assembly, Part 1
at 2011-12-16 15:02
As a small change of pace, today's post is written by guest author Gwynne Raskind. My last post touched a bit on disassembling object files, and Gwynne wanted to dive deeply into just how to read the output in detail. Without further ado, I present her wonderful in-depth look at reading
x86_64
assembly.Friday Q&A 2011-12-02: Object File Inspection Tools
at 2011-12-02 14:45
Being able to see all stages of your work can be immensely helpful when debugging a problem. Although you can get a lot done only looking at the source code and the app's behavior, some problems benefit immensely from being able to inspect the preprocessed source code, the assembly output from the compiler, or the final binary. It can also be handy to inspect other people's binaries. Today, I want to talk about various tools you can use to inspect binaries, both your own and other people's, a topic suggested by Carlton Gibson.
Friday Q&A 2011-11-11: Building a Memoizing Block Proxy
at 2011-11-11 16:06
Last time, I talked about my crazy hack that misuses the Objective-C message forwarding machinery to do block proxying. This allows writing code that interposes in front of an arbitrary block to intercept its arguments, manipulate its return value, etc. Today, I want to present an exanmple of using this hack which almost verges on the practical. Specifically, I'm going to discuss how to use it to build a generalized block memoization facility.
Friday Q&A 2011-10-28: Generic Block Proxying
at 2011-10-28 13:57
Here at Friday Q&A, I pride myself on occasionally taking my readers to places where normal people dare not tread. Today is one of those days. This is not a reader suggested topic, but today I want to talk about a fun hack I came up with that allows proxying block invocations in much the way that one can proxy Objective-C messages.
Friday Q&A 2011-10-14: What's New in GCD
at 2011-10-14 12:01
Happy iPhone Day to all! For those of you stuck waiting in line or waiting for the delivery guy, never fear, for I have the solution to your pain. For today's topic, Jon Shier suggested that I talk about the new features in Grand Central Dispatch in Lion and iOS 5.
Friday Q&A 2011-09-30: Automatic Reference Counting
at 2011-09-30 15:02
Since the moment Apple announced it, readers have asked me to write about Automatic Reference Counting, or ARC. Today is the day. I'll talk about Apple's new memory management system, how it works, and how to get the most out of it.
Friday Q&A 2011-09-16: Let's Build Reference Counting
at 2011-09-16 14:00
Last time, I discussed how to build
NSAutoreleasePool
and how it works internally. Today, I'm going to carry that theme forward by building an implementation of Cocoa reference counting with retain
and release
, a topic suggested by David Dunham.Friday Q&A 2011-09-02: Let's Build NSAutoreleasePool
at 2011-09-02 16:30
It's that time again: time for more programming craziness. Dallas Brown suggested that I talk about how
NSAutoreleasePool
works behind the scenes. I decided that the best way to do that would be to simply reimplement it, and that is what I'll discuss today.Friday Q&A 2011-08-19: Namespaced Constants and Functions
at 2011-08-19 14:40
The inevitable rotation of the Earth means that it's once again time for another Friday Q&A. For today's edition, Jose Vazquez suggested that I discuss namespaced constants and functions in C.
Friday Q&A 2011-08-05: Method Signature Mismatches
at 2011-08-05 14:45
You're happily writing code one day, click Build, and suddenly the dreaded warning appears:
warning: no '-fooMessage' method found (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)
You double-check your code and your method name is correct, so you shrug and move on. A few hours later, your program starts misbehaving strangely. What's going on? Today, I'll explore the mysterious world of Objective-C method signature mismatches, a topic suggested by an anonymous reader.Friday Q&A 2011-07-22: Writing Unit Tests
at 2011-07-22 16:16
It is once again that Fridayest of all days, and time for another Friday Q&A. For today's fountain of technical goodness, reader Jay Tamboli has suggested that I discuss how to write unit tests.
Friday Q&A 2011-07-08: Let's Build NSNotificationCenter
at 2011-07-08 16:11
Notifications in Cocoa are extremely useful and are pervasive in Cocoa programming. Unfortunately, a lot of Cocoa programmers see the notification system as something of a black box: a notification is posted, Stuff Happens, and somehow the observer gets notified. Fortunately, the Stuff that Happens is actually pretty simple, and to explore it, I'm going to reimplement an
NSNotificationCenter
workalike from scratch to illustrate how it all works, a topic suggested by Dylan Copeland.Friday Q&A 2011-06-17: gdb Tips and Tricks
at 2011-06-17 19:49
It has been said that programming is simply the art of debugging an empty file. While this is a bit of a narrow minded view of things, the fact is that debugging is hugely important to any serious programming. There are a lot of different ways to debug programs, ranging from writing logs to blinking a light to simply inspecting the contents of memory on a crashed system. However, the debugger is one of the most powerful tools for debugging, as you might expect, since it allows deep inspection and modification of a running program without having to anticipate your debugging needs in advance. Although
lldb
, the new debugger from the LLVM project, is quickly gaining functionality, the gold standard for debugging Cocoa apps is still gdb
. Today I'm going to discuss how to use gdb
and various tips and tricks for getting the most out of it, a topic suggested by Luis de la Rosa.Friday Q&A 2011-06-03: Objective-C Blocks vs. C++0x Lambdas: Fight!
at 2011-06-03 15:11
Blocks are perhaps the most significant new language feature introduced by Apple in years, and I've written a lot about them before. The new C++ standard, C++0x, introduces lambdas, a similar feature. Today, I want to discuss the two features and how they are alike and how they differ, a topic suggested by David Dunham.
Friday Q&A 2011-05-20: The Inner Life of Zombies
at 2011-05-20 16:00
It's Friday again, that Fridayest of days, and this week that means it's time for another Friday Q&A. Samuel Goodwin suggested discussing how
NSZombie
works, and that's the topic I will discuss today.Friday Q&A 2011-05-06: A Tour of MABlockClosure
at 2011-05-06 17:34
It's a week late, but it's finally time for the latest edition of Friday Q&A. About a year ago, I wrote about converting blocks into function pointers by building code at runtime. This was an interesting exercise, but ultimately impractical due to various limitations. In the meantime, I wrote MABlockClosure, a more robust and usable way of doing the same thing, but I never posted about it. Landon Fuller suggest I discuss how it works, and so that is what I will talk about today.
Friday Q&A 2011-04-15: Compile-Time Tips and Tricks
at 2011-04-15 16:20
Greetings, salutations, and welcome to another edition of Friday Q&A, the Fridayest source of information on the internet. This week, friend of the blog Jose Vazquez had the idea of discussing miscellaneous compile-time tips and tricks in C/Objective-C, like useful preprocessor techniques and compile-time asserts.
Friday Q&A 2011-04-01: Signal Handling
at 2011-04-01 15:21
Happy April Fool's Day to all my readers, and welcome to one web site which won't irritate you all day with bizarre practical jokes. Instead, I bring you another edition of Friday Q&A. In this edition, I will discuss various ways of handling signals in Mac programs, a topic suggested by friend of the blog Landon Fuller.
Friday Q&A 2011-03-04: A Tour of OSAtomic
at 2011-03-04 18:24
It's time for another crazy edition of Friday Q&A. Today, Paul Kim has suggested that I give a tour of OSAtomic, OS X's built-in low-level functions for lockless thread-safe operations. Given the announcement Wednesday of the dual-core iPad 2, this was a particularly prescient suggestion on his part.
Friday Q&A 2011-02-18: Compound Literals
at 2011-02-18 16:20
We're back to our regular schedule at last. For today's edition, I'm taking a break from the usual reader-driven format to discuss a topic of my own choosing: compound literals in C99.
Friday Q&A 2011-01-04: Practical Floating Point
at 2011-01-14 16:33
Welcome to the first Friday Q&A of the new year. For the first post of
0x7DB
, I decided to write about practical floating point, a topic suggested by Phil Holland.Friday Q&A 2010-12-31: C Macro Tips and Tricks
at 2010-12-31 22:43
The year is almost over, but there's time for one last Friday Q&A before 2011 comes around. For today's post, fellow Amoeba Dan Wineman suggested that I discuss tricks for writing macros in C.
Friday Q&A 2010-12-17: Custom Object Allocators in Objective-C
at 2010-12-17 18:27
Merry holidays, happy winter, and a joyous Friday Q&A to you all. Camille Troillard suggested that I discuss how to create custom object memory allocators in Objective-C, and today I'm going to walk through how to accomplish this and why you might want to.
Friday Q&A 2010-12-03: Accessors, Memory Management, and Thread Safety
at 2010-12-03 16:53
It's once again time for a brand new edition of Friday Q&A. This week, I'm going to talk about accessors, and how to properly deal with memory management and thread safety when creating them, a topic suggested by Daniel Jalkut.
Friday Q&A 2010-11-6: Creating Classes at Runtime in Objective-C
at 2010-11-05 17:08
Friday Q&A is back! I had some very important slacking to take care of for the past couple of months, but now I'm ready to resume business as usual. For this return to Friday Q&A, I'm going to talk about how to create Objective-C classes at runtime, a topic suggested by Kevin Avila. This topic is meaty enough that this will be a two-parter; today's post will talk about the basics of how to create classes at runtime, and then the next one will discuss uses for such classes and how to take advantage of them.
Friday Q&A 2010-08-27: Defensive Programming in Cocoa
at 2010-08-27 15:19
Welcome back to another word-laden edition of Friday Q&A. About a year ago, I wrote a post on defensive programming. That post covered defensive programming in a general sense, and Scott Gould has requested that I write one specific to various standard Cocoa practices, which is what I will be talking about today.
Friday Q&A 2010-08-12: Implementing NSCoding
at 2010-08-13 16:35
Welcome back to another frightening edition of Friday Q&A. This time around, friend and local OS X coder Jose Vazquez has suggested that I discuss how to implement
NSCoding
in Objective-C classes.Friday Q&A 2010-07-30: Zeroing Weak References to CoreFoundation Objects
at 2010-07-30 19:01
It's time for another friendly edition of Friday Q&A. For my last Friday Q&A, I talked about
MAZeroingWeakRef
and how it's implemented for pure Objective-C objects. For this one, I'm going to discuss the crazy hacks I implemented to make it work with toll-free bridged CoreFoundation objects as well.Friday Q&A 2010-07-16: Zeroing Weak References in Objective-C
at 2010-07-16 20:18
It's that time of the biweek again. For this week's Friday Q&A, Mike Shields has suggested that I talk about weak references in Objective-C, and specifically zeroing weak references. I've gone a bit further and actually implemented a class that provides zeroing weak references in Objective-C using manual memory management.
Friday Q&A 2010-07-02: Background Timers
at 2010-07-02 16:45
Welcome back to another Friday Q&A. This week I'm departing from my usual user-driven format to present a class I've written for what I'm calling "background timers", and discuss potential uses for it.
Friday Q&A 2010-06-18: Implementing Equality and Hashing
at 2010-06-18 14:48
Welcome back to a late edition of Friday Q&A. WWDC pushed the schedule back one week, but it's finally time for another one. This week, I'm going to discuss the implementation of equality and hashing in Cocoa, a topic suggested by Steven Degutis.
Friday Q&A 2010-05-28: Leopard Collection Classes
at 2010-05-28 16:43
Welcome back to another edition of Friday Q&A. For this week's post, I'm going to talk about three somewhat obscure collections classes that were introduced to Cocoa in 10.5:
NSPointerArray
, NSHashTable
, and NSMapTable
, a topic suggested by Phil Holland.Friday Q&A 2010-05-14: What Every Apple Programmer Should Know
at 2010-05-14 15:36
Welcome back to another Friday Q&A. This week, Quentin Carnicelli (who is heavily involved in generating my paychecks) has suggested that I talk about things that every Apple programmer should know. In other words, common Cocoa design and implementation decisions that I'd prefer Apple not to make.
Friday Q&A 2010-04-30: Dealing with Retain Cycles
at 2010-04-30 15:29
Happy iPad 3G day to everyone. Whether you're waiting in line, waiting for the delivery guy, or just pining at home like I am, you can fill your idle moments with another edition of Friday Q&A. This week, Filip van der Meeren has suggested that I discuss retain cycles and how to deal with them.
Friday Q&A 2010-04-23: Implementing a Custom Slider
at 2010-04-23 16:01
Welcome to another chilling edition of Friday Q&A. While I hope to be soaring over the scenic Shenandoah Valley on this fine Friday, I have taken the precaution of preparing my post in advance, so that you may see it even while I am incommunicado. Such is the magic of the modern world. This week, Michael Crawford has suggested that I give in example of implementing a custom control in Cocoa.
Friday Q&A 2010-04-16: Implementing Fast Enumeration
at 2010-04-16 16:35
Last week I discussed the various options available in Objective-C for enumerating over a collection This week I'm going to finish up the discussion of enumeration with a guide on how to implement Fast Enumeration in your own program.
Friday Q&A 2010-04-09: Comparison of Objective-C Enumeration Techniques
at 2010-04-09 11:17
Welcome back to another edition of Friday Q&A. Preston Sumner has suggested that I talk about different ways of enumerating over collections in Cocoa, and how to implement Fast Enumeration. This will be a two part series: this week I will look at the different enumeration techniques and their pros and cons, and then next week I will take you through implementing Fast Enumeration on a custom object.
Friday Q&A 2010-04-02: OpenCL Basics
at 2010-04-02 11:28
I'm back in action at last, so it's time for another Friday Q&A. This week, both someone named "charles" and Brian Olsen have suggested that I talk about OpenCL, so I'm going to go through the basics of what OpenCL is and how to do some simple computation with it.
Friday Q&A 2010-03-05: Compound Futures
at 2010-03-05 13:53
Welcome back to another thrilling edition of Friday Q&A. This week I want to extend my discussion from last week about futures, and talk about compound futures, an extension to the basic futures system that I developed previously.
Friday Q&A 2010-02-26: Futures
at 2010-02-26 18:19
Welcome back to another shiny edition of Friday Q&A. Guy English suggested taking a look at implementing futures in Objective-C using blocks, and for this week's post I'm going to talk about the futures implementation that I built.
Friday Q&A 2010-02-19: Character Encodings
at 2010-02-19 22:15
It's another Friday and another Friday Q&A. For this week's post, Joshua Pokotilow has suggested that I talk about character encodings, so I want to give a basic tour of just what a character encoding is, how it works, and useful details about common encodings.
Friday Q&A 2010-02-12: Trampolining Blocks with Mutable Code
at 2010-02-12 18:20
Welcome to another edition of Friday Q&A, where deep technical talk and complete insanity combine! This week, I'm going to take a quick break from my usual reader-driven format and talk about a little toy I built earlier in the week, an adapter between blocks and more traditional function-pointer-based callback systems.
Friday Q&A 2010-02-05: Error Returns with Continuation Passing Style
at 2010-02-05 18:36
The Earth has moved 6.9 degrees around the Sun since my last post, which means it's time for another edition of Friday Q&A. This 6.9-degree segment, Guy English has suggested that I talk about the use of continuation passing style to simplify error returns in Objective-C code.
Friday Q&A 2010-01-29: Method Replacement for Fun and Profit
at 2010-01-29 19:00
It's that time of the week again. For this week's Friday Q&A Mike Shields has suggested that I talk about method replacement and method swizzling in Objective-C.
Friday Q&A 2010-01-22: Toll Free Bridging Internals
at 2010-01-22 16:57
It's been a week, and once again, it's time for a Friday Q&A. For this week's edition, I'm going to talk about how toll-free bridging works, a topic suggested by Jonathan Mitchell.
Friday Q&A 2010-01-15: Stack and Heap Objects in Objective-C
at 2010-01-15 21:58
Welcome to another Friday Q&A. I survived my travel and am (just barely) ready to write another exciting edition. This week's topic comes from Gwynne, who asked why Objective-C only uses heap objects, and no stack objects.
Friday Q&A 2010-01-08: NSNotificationQueue
at 2010-01-08 07:21
It's that time of the week again. No, it's not just time to go get drunk, but time for Friday Q&A! This week's topic, suggested by Christopher Lloyd of Cocotron (a really neat open source project that lets you write Objective-C/Cocoa code for non-Mac platforms like Windows), is
NSNotificationQueue
, a little-known, poorly-understood, but handy Foundation class.Friday Q&A 2010-01-01: NSRunLoop Internals
at 2010-01-01 10:43
It's the first Friday of the new year, and that means it's time for the first Friday Q&A of 2010. This week, I'm taking Dave DeLong's suggestion of talking about
NSRunLoop
internals.Friday Q&A 2009-12-18: Highlights From a Year of Friday Q&A
at 2009-12-18 11:18
It's hard to believe that it's been a full year (minus a day) since my first Friday Q&A. It's become more successful than I thought possible, and many kind and obviously deluded people have said great things about it to me. Since I'm feeling lazy this week, I thought I'd pull up some highlights from the past year rather than write anything new.
Friday Q&A 2009-12-11: A GCD Case Study: Building an HTTP Server
at 2009-12-11 23:58
It's time for another wintry edition of Friday Q&A. From the comfort of your toasty-warm homes, you can read about building an HTTP server using Grand Central Dispatch, a topic suggested by Steven Degutis.
Friday Q&A 2009-10-30: Generators in Objective-C
at 2009-10-30 16:59
It's Friday again and time for another Friday Q&A. This week I'm going to discuss a framework for creating generators in Objective-C. I'm indulging myself a bit with this, because nobody suggested it, but nothing in my suggestion bank inspired me this time around, so I decided to go with something of my own.
Friday Q&A 2009-10-23: A Preview of Coming Attractions
at 2009-10-23 15:45
I'm afraid that I ran out of time this week and wasn't able to put together a real Friday Q&A. However, as a preview of what I'll be talking about next week, check out the MAGenerator project in my public subversion repository.
Friday Q&A 2009-10-16: Creating a Blocks-Based Object System
at 2009-10-16 15:50
It's Friday again, and that means another Friday Q&A. This week, Guy English proposed talking about a blocks-based object system, and that is what I will do. The system I've developed is a rudimentary system for doing object-oriented programming in pure C (plus blocks), and I'll discuss how it works and how to use it.
Friday Q&A 2009-10-09: Defensive Programming
at 2009-10-09 16:03
It's that time of the week again. This week I'm going to discuss defensive programming, a topic suggested by Ed Wynne.
Friday Q&A 2009-10-02: Care and Feeding of Singletons
at 2009-10-02 15:59
It's time for another Friday Q&A. I hope everyone who had a chance to go to C4 had a good time and is back home safe and sound. This week I'm going to discuss singletons, both how to make them and when to use them, as suggested by Jon Trainer.
Friday Q&A 2009-09-25: GCD Practicum
at 2009-09-25 11:52
Welcome back to another Friday Q&A. I'm off to C4 today (hope to see you there!) but I've prepared this in advance so everyone stuck at home (or worse, work) can at least have something interesting to read. Over the past four weeks I've introduced Grand Central Dispatch and discussed the various facilities it provides. In Part I I talked about the basics of GCD and how to use dispatch queues. In Part II I discussed how to use GCD to extract more performance from multi-core machines. In Part III I discussed GCD's event dispatching mechanism, and in Part IV I took care of various odds and ends that I hadn't covered before. This week I'm going to examine a practical application of using GCD to speed up the production of thumbnails for a large quantity of images, a topic suggested by Willie Abrams.
Friday Q&A 2009-09-18: Intro to Grand Central Dispatch, Part IV: Odds and Ends
at 2009-09-18 17:23
It's that time of the week again. Over the past three weeks I've introduced you to the major pieces Grand Central Dispatch, an exciting new API for parallel processing and event handling in Snow Leopard. The first week I covered basic concepts and dispatch queues. The second week I discussed how to use dispatch queues for parallel processing on multi-core computers. The third week I covered GCD's event handling system. This week I'm going to cover various odds and ends which I didn't get to before: dispatch queue suspension and targeting, semaphores, and one-time initialization.
Friday Q&A 2009-09-11: Intro to Grand Central Dispatch, Part III: Dispatch Sources
at 2009-09-11 15:28
Welcome back to another Friday Q&A. This week I continue the discussion of Grand Central Dispatch from the past two weeks. In the last two weeks I mainly focused on dispatch queues. This week I'm going to examine dispatch sources, how they work, and how to use them.
Friday Q&A 2009-09-04: Intro to Grand Central Dispatch, Part II: Multi-Core Performance
at 2009-09-04 01:51
Welcome back to Friday Q&A. Last week I discussed the basics of Grand Central Dispatch, an exciting new technology in Snow Leopard. This week I'm going to dive deeper into GCD and look at how you can use GCD to take advantage of multi-core processors to speed up computation. This post assumes that you've read last week's edition, so be sure to do that if you haven't already.
Friday Q&A 2009-08-28: Intro to Grand Central Dispatch, Part I: Basics and Dispatch Queues
at 2009-08-28 14:16
Welcome back to Friday Q&A. This week's edition lines up with Apple's release of Snow Leopard, so I'm going to take this opportunity to open up the discussion on previously NDA'd technologies and talk about some of the cool stuff now available in Snow Leopard. For this week I'm going to start what I plan to be an ongoing series on Grand Central Dispatch, a topic suggested by Chris Liscio.
Friday Q&A 2009-08-21: Writing Vararg Macros and Functions
at 2009-08-21 15:15
Welcome to another Friday Q&A, where all references are strong and all values are above average. This week I'm going to talk about how to write macros and functions that take variable arguments in C, as suggested by Damien Sorresso.
Friday Q&A 2009-08-14: Practical Blocks
at 2009-08-14 20:06
Welcome back to another edition of Friday Q&A. I'm back from my break and ready to bring you more programming goodies. This week I want to take Landon Fuller's suggestion to write a followup to my original Friday Q&A on blocks now that the design is finalized and code available for them.
Friday Q&A 2009-07-17: Format Strings Tips and Tricks
at 2009-07-17 15:21
Greetings and welcome back to Friday Q&A. This week I'm going to discuss some tips and tricks for using
printf
-style format strings in C, as suggested by Kevin Avila.Friday Q&A 2009-07-10: Type Specifiers in C, Part 3
at 2009-07-10 13:00
Here at last is the conclusion to Friday Q&A's three-part series on C type specifiers. The first week I discussed
const
and restrict
. Last week I discussed the basics of volatile
and why it's not very useful. This week I'm going to finish up by discussing the use of volatile
in a multithreaded context.Friday Q&A 2009-07-03: Type Specifiers in C, Part 2
at 2009-07-03 13:20
Welcome to another edition of Friday Q&A. Last week I began to talk about type qualifiers in C, and discussed the meaning and use of the
const
and restrict
qualifiers. This week I will continue with a discussion of the third qualifier, volatile
.Friday Q&A 2009-06-26: Type Qualifiers in C, Part 1
at 2009-06-26 16:11
Welcome back to another warm and fuzzy edition of Friday Q&A. This week I'm going to discuss the use of type qualifiers in C, a subject suggested by Nate Vander Wilt.
Friday Q&A 2009-06-19: Mac OS X Process Memory Statistics
at 2009-06-19 13:48
Welcome back to another Friday Q&A. Now that WWDC is behind us, I'm back on track to bring you more juicy highly-technical goodness. Maybe I can even get back to doing one a week.... This week I'm going to take André Pang's suggestion of discussing process memory statistics (the stuff you see in Activity Monitor or
top
) in Mac OS X.Friday Q&A 2009-06-05: Introduction to Valgrind
at 2009-06-05 15:55
Welcome back to another late Friday Q&A. My apologies to all of my readers for missing last week's edition. Some family events beyond the scope of this blog prevented me from writing one. And I should probably point out right now that WWDC is almost certainly going to prevent me from writing one next week. This week, however, I do have a post, and I'm going to be talking about Valgrind as suggested by Landon Fuller.
Friday Q&A 2009-05-22: Objective-C Class Loading and Initialization
at 2009-05-23 00:37
Welcome back to another cromulent Friday Q&A. After taking a few weeks off I intend to resume the regular schedule. We'll see how far that intention takes me, but I'm hopeful. This week I'm going to take Daniel Jalkut's suggestion to discuss class loading and initialization in Objective-C.
Friday Q&A 2009-04-24: Code Generation with LLVM, Part 2: Fast Objective-C Forwarding
at 2009-04-24 01:35
It's Friday again, and that means another Friday Q&A. As promised, this week's edition will pick up where last week's left off. Last week I discussed the basics of generating code at runtime using LLVM. This week I'm going to build on that base and show how to use LLVM to perform fast forwarding in Objective-C.
Friday Q&A 2009-04-17: Code Generation with LLVM, Part 1: Basics
at 2009-04-17 11:07
Welcome back to another heart-pounding edition of Friday Q&A. Phil Holland and Ed Wynne both suggested that I do something with LLVM, and so I'm going to discuss how to generate and call code at runtime using LLVM. This week I'm going to talk about the basics needed to get up and running with code generation, and then next week in Part 2 I'm going to show how you can use this technique to build a fast Objective-C trampoline object.
Friday Q&A 2009-04-10: Multithreaded Optimization in ChemicalBurn
at 2009-04-10 17:22
Welcome to another Friday Q&A, where all the women are strong, all the men are good-looking, and all the programmers are above average. This week, Phil Holland has suggested that I dissect an interesting piece of code from one of my screensavers, so we're going to take a look at ChemicalBurn's multithreaded routing code.
Friday Q&A 2009-03-27: Objective-C Message Forwarding
at 2009-03-27 16:50
Welcome back to another exciting Friday Q&A. This week I'm going to continue the series on the Objective-C runtime. Yuji Tachikawa suggested talking about how
@dynamic
properties work in CoreData and I'm going to take that and expand it to talk about message forwarding in general.Friday Q&A 2009-03-20: Objective-C Messaging
at 2009-03-21 01:59
Welcome back to another Friday Q&A. This week I'd like to take Joshua Pennington's idea and elaborate on a particular facet last week's topic of the Objective-C runtime, namely messaging. How does messaging work, and what exactly does it do? Read on!
Friday Q&A 2009-03-13: Intro to the Objective-C Runtime
at 2009-03-13 14:13
Welcome back to another Friday Q&A, on another Friday the 13th. This week I'm going to take Oliver Mooney's suggestion and talk about the Objective-C runtime, how it works, and what it can do for you.
Friday Q&A 2009-03-06: Using the Clang Static Analyzer
at 2009-03-06 22:19
Welcome back to another exciting Friday Q&A. This week's topic, suggested by Ed Wynne, will be an overview of the Clang Static Analyzer and an example of how to use it.
Friday Q&A 2009-02-27: Holistic Optimization
at 2009-02-27 04:21
Welcome back to Friday Q&A, a bit early this week since I won't be around to post it at the usual time. This week I'm going to cheat a little bit and use a topic that I "suggested" myself. I'll be talking about what I like to call "holistic optimization", which is essentially how to look at optimization within the context of your entire project, rather than bit-swizzling, loop unrolling, and other micro-optimizations.
Friday Q&A 2009-02-20: The Good and Bad of Distributed Objects
at 2009-02-20 20:40
Welcome back to another Friday Q&A. This week I'm going to take Erik's (no last name given) suggestion from my interprocess communication post and expand a bit on Distributed Objects, what makes it so cool, and the problems that it has.
Friday Q&A 2009-02-13: Operations-Based Parallelization
at 2009-02-13 20:31
Welcome back to Friday Q&A, which this week is also Friday the Thirteenth! Be especially careful, as this is the first of two consecutive Friday the Thirteenths. For this first Friday the Thirteenth I'm going to talk about parallel software design using an "operations" approach (think NSOperation), as suggested by Nikita Zhuk way back when I first started this whole thing.
Friday Q&A 2009-02-06: Profiling With Shark
at 2009-02-06 17:30
Welcome back to Friday Q&A.; This week I'm taking Jeff Johnson's idea to discuss optimization and profiling tools.
Friday Q&A 2009-01-30: Code Injection
at 2009-01-30 18:34
Welcome back to another exciting Friday Q&A.; This week I'll be taking Jonathan Mitchell's suggestion to talk about code injection, the various ways to do it, why you'd want to, and why you wouldn't want to.
Friday Q&A 2009-01-23
at 2009-01-23 21:31
Welcome to the first Friday Q&A; of the new Presidential administration. Unlike Mr. Obama, I'm afraid of change and so this week's edition will be just like all the other ones. This week I'll be taking Jonathan Mitchell's suggestion to talk about how Key-Value Observing (KVO) is actually implemented at the runtime level.
Friday Q&A 2009-01-16
at 2009-01-16 22:35
Happy Friday to everyone, and welcome back to another Friday Q&A. This week I'll be taking Eren Halici's suggestion to discuss the various ways to do interprocess communication on OS X.
Friday Q&A 2009-01-09
at 2009-01-09 21:38
Greetings one and all. I caught my mistaken writing of "2008" in this blog post title almost instantly instead of only noticing after I'd already posted it like I did last week, so the year must be coming along. Welcome to the second Friday Q&A of 2009 (and only the fourth in all human history!) where I'll be taking Ed Wynne's suggestion and talking about the various meanings and implications of thread safety as they apply to Mac OS X system frameworks.
Friday Q&A 2009-01-02
at 2009-01-02 23:06
It's a new year, and that means a new Friday Q&A! This week I'm going to take Steven Degutis's suggestion and discuss the ups and downs of using private APIs.
Friday Q&A 2008-12-26
at 2008-12-26 17:19
Welcome to another Friday Q&A. This week I thought I would take fellow amoeboid Jeff Johnson's suggestion and talk about blocks in Objective-C.
Friday Q&A 2008-12-19
at 2008-12-20 01:28
Great response last week. This week I'm going to merge Sam McDonald's question about how I got into doing multithreaded programming and Phil Holland's idea of talking about the different sorts of parallelism available.
Friday Q&A
at 2008-12-13 05:00
In an effort to liven up the blog a bit, I thought I would start soliciting topics from the readership. Given the large number of comments on certain past posts and the couple hundred unique hits to my RSS feed URL every day, I'm hoping that this might just work out.