mikeash.com: just this guy, you know?

NSBlog
RSS feed (full text feed)

accessors advertisement advice(3) apple assembly atomic audio autorelease(2) blocks(7) bolo(3) bridging bug(3) c(8) c++(3) casestudy chemicalburn(4) clang(2) cocoa(20) codeinjection codesigning content-free(3) continuations coreaudio corefoundation dangerous dashboard debugging defensive encoding errorhandling eulogy evil(7) filemerge float fluid frameworks fridayqna(50) futures(2) games(3) garbagecollection gcd(8) generators(3) gpulife hack(4) heap html http humor(3) init initializer injection interview(3) ioccc(2) ipc(2) iphone(11) irc javascript jobs kvo(2) leopard(2) libraries link(13) linking lisp llvm(3) macro magic memory(2) meta(2) minions networking nib notifications nscell nsoperationqueue(5) numerical objective-c(15) objectivec(2) opencl opengl(2) opensource osbug(4) override parallelism performance(18) plugin pointless privateapi programming pyobjc python(4) rant(15) runloop security(2) shark simbl simulation singleton sourcecode(2) stack stl(2) strnstr(2) stupid subversion(2) super swizzling text threading(5) tiger trampoline unicode(3) university update utility valgrind vararg versioncontrol(2) web wwdc(3) xbolo xcode(2)

Welcome to another chewy edition of Friday Q&A. This week, Gwendal Roué has suggested talking about the techniques of subclassing class clusters.

Tags: fridayqna futures blocksWelcome 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.
(Read More) 0 comments

Friday Q&A 2010-02-26: Futures at 2010-02-26 18:19
Tags: fridayqna futures blocksWelcome 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.
(Read More) 9 comments

Friday Q&A 2010-02-19: Character Encodings at 2010-02-19 22:15
Tags: fridayqna unicode encoding textIt'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.
(Read More) 11 comments

Friday Q&A 2010-02-12: Trampolining Blocks with Mutable Code at 2010-02-12 18:20
Tags: fridayqna blocks trampoline assembly evilWelcome 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.

Tags: fridayqna blocks objectivec continuations errorhandlingThe 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.

Tags: fridayqna objectivec swizzling override evilIt'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.

Tags: fridayqna corefoundation bridgingIt'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.

Tags: fridayqna stack heap memoryWelcome 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.

Tags: fridayqna cocoa notificationsIt'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.

Tags: fridayqna cocoa runloopIt'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.

Tags: fridayqna pointlessIt'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.

Rogue Amoeba Is Hiring at 2009-12-18 06:54
Tags: jobs minions advertisementAs some of you already know, I work for Rogue Amoeba, and it just so happens that we're hiring.

Tags: fridayqna gcd http networking generatorsIt'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.

Tags: iphone web javascript htmlWelcome to another edition of Friday Q&A. This week I'm going to talk about building standalone iPhone web apps, web apps that have an icon on the home screen, and which start a separate program when tapped, just like native apps, a topic suggested by Mike Shields.

Tags: cocoa objective-c accessorsIt's Black Friday, and that means it's time for another Friday Q&A. Today I'm going to talk about the use of accessors in Objective-C init/dealloc methods, a topic suggested by Jon Trainer.

Tags: cocoa python pyobjc objective-c hackIt's another Friday and time for another Friday Q&A. This week, fellow Amoeba Jeff Johnson suggested talking about using Cocoa from the command line using Python and PyObjC.

Tags: apple iphone evil rant stupidIt's well known that every member of the official iPhone developer program is bound by Apple's iPhone SDK agreement. What seems to be much less well known is that the agreement also binds developers to follow Apple's "Copyright and Trademark Guidelines", which add a huge list of restrictions to what an iPhone developer can and cannot do.

Tags: cocoa threading dangerousIt's another Friday, and so time for another Friday Q&A. This week, Quentin Carnicelli (one of the guys who signs my paychecks) suggested that I talk about dangerous API calls in Cocoa.

Tags: linking libraries frameworksIt's another Friday, and thus another Friday Q&A. I have recovered from the confusion of the Daylight Saving Time transition and am now ready to talk about Mac OS X linking, install names, @executable_path, and friends.

Tags: fridayqna generatorsIt'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.

Tags: fridayqna generatorsI'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.

Tags: fridayqna blocks evilIt'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.

XBolo is Out! at 2009-10-09 23:56
Tags: bolo xbolo gamesMy good friend Robert has been working on this for many years, and it's finally out for the public. For those of you who know what it is, XBolo is a fully Mac OS X native clone of the old Bolo game for the Mac, with live fullscreen graphics and much improved networking.

Tags: fridayqna defensiveIt's that time of the week again. This week I'm going to discuss defensive programming, a topic suggested by Ed Wynne.

Tags: fridayqna cocoa objective-c singletonIt'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.

Tags: fridayqna gcd performance sourcecodeWelcome 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.

Tags: fridayqna gcd performanceIt'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.

Tags: iphone rantA year ago today I posted The iPhone Development Story, detailing all of the insane and largely pointless steps required to build an iPhone application. The article was incredibly popular, seeing tens of thousands of hits that weekend and still generating fresh comments even to this day. Now, a year later, it's time to look back and see where we stand today.

Tags: gcd rantThere's a lot of discussion going around the internet lately about blocks and Grand Central Dispatch. They're both great new technologies that have seen the light of day with the 10.6 release, and they see a lot of use together. However, a lot of the people discussing blocks and GCD don't seem to understand that they are not, in fact, the same thing, and aren't even really related. I just wanted to make a quick note here to describe exactly what each one is, how they're different, and how they work together.

Tags: fridayqna gcd performanceWelcome 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.

Tags: fridayqna gcd performanceWelcome 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.

Tags: interview linkLast week I recorded an interview with Dan Grigsby of Mobile Orchard and today it showed up in his podcast. It's pretty much the same material as covered in my series on the Objective-C runtime but now in audio form, so if you like audio then get to the podcast here.

Tags: fridayqna gcd performanceWelcome 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.

Unicode Comments Support at 2009-08-22 20:55
Tags: meta unicode pythonAs some of you are aware, my comment system did not support non-ASCII characters. This is not because I am unaware that there exists a world outside of the United States. No, it's simply that I could never force the horrible combination of Python and MySQL to cooperate when it came to non-ASCII characters. I struggled with it for a long time, and finally gave up. Well, I'm happy to say that I have finally solved the problem and my blog now supports Unicode comments!

Tags: iphone linkI've just written a blog post for my evil taskmasters which I thought this audience would be interested in too. It's called Reading Between the Lines of Apple's FCC Reply and talks about Apple's response to the FCC's inquiry over the rejection of the Google Voice iPhone application. My favorite part is, "With 17,000 reviews per week and 45 reviewers, that means each reviewer performs 378 reviews per week. At 40 hours per week, this is 9.4 reviews per hour, or one review every 6.4 minutes." I encourage you to make your way over to Under the Microscope and read the whole thing.

Tags: fridayqna c vararg macroWelcome 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.

Tags: fridayqna blocksWelcome 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.

Tags: fridayqna cGreetings 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.

Tags: fridayqna cHere 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.

Tags: fridayqna cWelcome 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.

Tags: fridayqna cWelcome 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.

Tags: fridayqna memory performanceWelcome 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.

Tags: fridayqna valgrindWelcome 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.

Tags: fridayqna objective-cWelcome 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.

Use NSOperationQueue at 2009-05-12 21:18
Tags: nsoperationqueue osbugMac OS X 10.5.7 has shipped and includes a fix for the NSOperationQueue bug that I discovered late last year. I have run all of my old test cases against 10.5.7 and it appears to perform as advertised. As far as I can see, NSOperationQueue is now safe to use. I'm glad that my prediction of no fix until Snow Leopard turned out to be wrong. Enjoy!

Nanogolf at 2009-05-08 16:22
Tags: iphone linkI'm afraid I have to skip Friday Q&A one more week but I hope to be back up next week, because one of the things that's been keeping me busy has finally shipped! It's called Nanogolf, and it's a multiplayer mini golf game for the Mac and iPhone. My partner and I have been hard at work on this for a long time and it's nice to finally see it out in the wild. The Mac version is free, the iPhone version is cheap, and they can play against each other. Go forth and soothe your Q&A pangs with a nice round of miniature golf.

Tags: content-freeThe cyclic functions which underlie my life all seem to have come to a maximum recently. Friday Q&A being one that I can most easily control, I've decided to skip this week to concentrate on the rest. I hope to return next week, although as usual, no promises.

Tags: fridayqna llvmIt'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.

Tags: fridayqna llvmWelcome 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.

Tags: fridayqna chemicalburn performance threadingWelcome 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.

Tags: content-freeDue to personal reasons, Friday Q&A will not be published this week. While I make no promises, I expect to resume the regular schedule next week. I will be more likely to resume the regular schedule if I have some good ideas to work with, so send them in!

Tags: fridayqna objective-cWelcome 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.

Tags: fridayqna objective-cWelcome 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!

Tags: fridayqna objective-cWelcome 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.

Tags: fridayqna clangWelcome 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.

Tags: fridayqna rant performanceWelcome 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.

Tags: fridayqna performance cocoa ipcWelcome 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.

Tags: fridayqna performance nsoperationqueueWelcome 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.

Tags: interview nsoperationqueue linkI've done another appearance on Late Night Cocoa, this time discussing NSOperationQueue problems. Check it out over at The Mac Developer Network.

Tags: fridayqna shark performanceWelcome back to Friday Q&A.; This week I'm taking Jeff Johnson's idea to discuss optimization and profiling tools.

Tags: fridayqna codeinjection hack evilWelcome 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
Tags: fridayqna kvoWelcome 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
Tags: fridayqna ipcHappy 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
Tags: fridayqna threading cocoaGreetings 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
Tags: fridayqna privateapiIt'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
Tags: fridayqna blocksWelcome 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
Tags: fridayqna threading parallelism performanceGreat 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
Tags: fridayqnaIn 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.

Tags: nsoperationqueue link bugThe other day I posted about how NSOperationQueue is broken and can't be used. At Rogue Amoeba we liked the API so much we decided to create a non-broken version, so we've released RAOperationQueue. It's not a 100% replacement, as it has some significant limitations (and some benefits) compared to NSOperationQueue, but we've found it to be very useful. For more information, click the link above.

Don't Use NSOperationQueue at 2008-11-30 23:36
Tags: nsoperationqueue osbugI've been discussing this on cocoa-dev but wanted to make a separate post about it to get the word out further. NSOperationQueue is broken on Leopard and will cause crashes. Don't use it!

Tags: cocoa kvo sourcecodeCocoa's Key-Value Observing facilities are extremely powerful and useful. Unfortunately they have a really terrible API that's inherently broken in a couple of different ways. I want to discuss how it's broken, and a way to make it better.

Tags: cocoa objective-c super init initializerOne of the longest ongoing controversies in the Cocoa community is how to write your init methods. More specifically, how to properly call your superclass's initializer. In the hopes of putting this controversy to rest, I want to walk through the right way to write an initializer and exactly why this is the right way.

Tags: xcode rantThe title isn't wholly appropriate because I'm not going to blame my tools, per se, just complain about them a whole lot. It occurred to me that we as programmers really don't have any good tools, and this has been annoying me for some time.

Tags: iphone rantI just got my first application in the iTunes App Store, and I wanted to tell the story of what it's like to publish one, from start to finish. The app, NetAwake, is an independent project I wrote with my friend Joshua. It makes an interesting story, I think, because unlike the sordid tale of some people's struggle to get accepted into the iPhone developer program, my personal experience was perfectly normal. (As far as I know.)

NetAwake at 2008-09-15 02:28
Tags: link iphoneI just wanted to make a quick post to note that I've released my first iPhone app, NetAwake. It's a Wake-on-LAN program with a fancy ZeroConf-based MAC grabber to make it accessible to people who think that MACs are the computers you buy from APPLE. Credit should also go to my partner Joshua, who did all of the work on the GUI.

Late Night Cocoa at 2008-09-05 23:31
Tags: interview link atomic threadingReaders of this blog may be interested in my recent appearance on Late Night Cocoa. I discussed the fundamental principles and basic concepts behind lockless thread-safe data structures. You can access the episode here.

Tags: iphone rantNote: this post is a long non-technical rant. Please skip it if you don't want to read that kind of thing. I promise that this will be a rare event.
My employer got me an iPod Touch shortly after Apple announced the official iPhone SDK, but it ended up not doing much for a while. Due to various things beyond the scope of this post, I didn't do any SDK work with it. And since I rarely listen to music outside of my office and my car (which has no iPod hookup), it didn't get used very much for anything.

WWDC 08 Followup at 2008-06-23 01:33
Tags: wwdc gcd opencl llvm clangAs you saw from my last post, I was sorely disappointed in this year's WWDC keynote. Fortunately the rest of the week didn't follow the same trend.

Worst. Keynote. Ever. at 2008-06-09 18:49
Tags: wwdcThat is all.

WWDC 2008 at 2008-06-04 14:00
Tags: wwdcAs some of you may be aware, WWDC 2008 is coming up soon, and I'm going to be there. If you see a tall guy in a shirt depicting a militaristic microbe, that's me.

Tags: update linkI don't know what it is about March, but it seems like I can't keep away from this blog. This is a bit less technical than I usually like to have here, but I think it's still interesting, and in any case it's a nifty place to be published. You can read Tales from the Sausage Factory: Why Those Big Downloads for Simple Updates? over at TidBITS.

Tags: iphone rantIn part two of my potentially ongoing series about the iPhone SDK, I want to discuss the platform's potential for malware.

Tags: performance cocoa objective-c iphoneI finally got a chance to run my performance comparison code on an iPhone, so we can see just how much horsepower this little device has. I still am not able to load my own code onto the device myself, so I want to thank an anonymous benefactor for adapting my code to the new environment and gathering the results for me.

Use strnstr at 2008-03-18 20:49
Tags: strnstr security tiger link osbugA few months ago I told everyone not to use strnstr. This bug was fixed in Leopard, but persisted in Tiger. Today, Apple finally fixed it in Tiger. Now you can safely use strnstr. I assume that this bug probably still exists on Panther and earlier, but as long as you're targeting Tiger and up (as every sane person ought to), you are now safe.

Tags: iphone rantThe recent release of the iPhone SDK has created a great deal of controversy in the Mac community. In typical fashion, two sides have formed, with each side thinking the other side is a bunch of fools. I'd like to explore one big point of controversy: Apple's prohibition against running applications in the background.

Code Signing and You at 2008-03-07 20:32
Tags: codesigning linkI just posted a long treatise on code signing over at my place of employment. I'm posting this for the few people who read my blog but not that one. Link after the fold because my RSS feed generator sucks.

Goodbye, Nibs at 2008-02-22 01:49
Tags: eulogyThis post is to say goodbye to nibs. Not the kind you create with Interface Builder.

Tags: python utility subversion versioncontrolIf you're like me, you sometimes have to edit rtfd files which are under version control, and it's painful. TextEdit and Xcode will blow away the version control directory (if you use the sort of version control which keeps directories in everything) and it's annoying to work around it. I finally got fed up enough to write a script which works around it for me.

Tags: performance cocoa objective-c leopardBy popular demand, I have re-run my Performance Comparisons of Common Operations on the same hardware but running Leopard.

The Cults of Programming at 2007-12-31 05:51
Tags: programming rant humorIn my experience with various programmers over the years, I've realized that most of them fall into one of several cults which describe their behavior. I've compiled a list of cults and brief descriptions you can use to identify them. (Note: if you're easily offended and think you might fall into one of these categories, please forego reading the rest of the article.)

Leopard: First Impressions at 2007-11-30 23:12
Tags: leopard cocoa objective-c rantLeopard's been out for a while now and brings with it a lot of interesting new tools for the Mac programmer. I've had the chance to work with some of them and want to offer my opinion on how they've worked out.

Tags: performance c++ stl casestudyThose who know me from a programming standpoint know that I am a big opponent of needless optimization. But sometimes optimization is necessary, and when that comes I'm a big proponent of examining algorithms over twiddling low-level code. I recently had a good opportunity to perform algorithmic optimizations in a somewhat unconventional scenario, and this post will describe what I did.

Tags: cocoa garbagecollection performanceThe move to garbage collection in Cocoa has been interesting. People have said that it's impossible, or impractical, or a bad idea, or doomed to failure, and one of the most common things trotted out is that GC is inevitably slow. However, I think that enabling garbage collection in your Cocoa app could actually be a good way to increase performance under the right conditions.

IOCCC 2006 Winners at 2007-11-04 14:17
Tags: ioccc c evilThe winners of the 2006 IOCCC have been posted. Sadly I am not among the winners this year, but the winners all appear to be most deserving.

First Post at 2007-11-04 14:16
Tags: metaThis is my first post with my new blog system. Eventually I hope to get my old blog posts moved over, but for now you can access the old blog at its old address.

Don't use strnstr at 2007-09-26 00:00
Tags: osbug strnstr security The strnstr function is broken on Mac OS X 10.4 (and presumably earlier) and should be avoided.

Tags: performance objective-c cocoa We all know that premature optimization is the root of all evil. But a recent conversation brought to mind that we often don't really know the runtime costs of the code we write. While we should be writing foremost for correctness and clarity, having an idea of these speeds is good, especially when we get it into our heads that some operation is much more costly than it really is. With that in mind, I compiled a list of common Cocoa operations and how much time they require at runtime.

Subtle Bugs at 2007-07-10 00:00
Tags: chemicalburn debugging I've just released a new version of ChemicalBurn which fixes two nasty bugs which have been in there for quite some time. Today I'll tell you about them. (You can also follow along at home in the svn repository.)

Open Source at 2007-03-15 00:00
Tags: opensource gpulife chemicalburn I'm slowly coming to realize that there isn't always much point in releasing freeware but keeping the source closed. As part of this realization, I have created a publicly accessible Subversion repository and added the source of two of my screensavers, GPULife and ChemicalBurn. They're both MIT licensed and contributions are welcome, although not expected. Maybe one of you can figure out why ChemicalBurn very occasionally gets into a routing loop....

How To Shrink Your Source Code at 2007-03-07 00:00
Tags: link humor I've written a handy article which should be useful to anyone whose C source code is too large and needs to be reduced. It outlines ten easy techniques you can use to reduce the size of your code. For reasons unknown to me, my employers seem to actually like it when I enter contests which revolve around making horrible code, and so you can read the article over at Under the Microscope.

More Fun With Autorelease at 2007-02-08 00:00
Tags: autorelease bug cocoa objective-c I just hit a subtle but commonly known bug for the first time. I thought I'd share my fun with the world. Everybody reading this blog should know about autorelease pools and how they work in Cocoa. As everybody knows, every time you go through the event loop, Cocoa blows away the old pool and makes a new one for you, so that all of your autoreleased objects go away and your new ones go into a fresh pool. That way you never build up more objects than get produced during a single event loop cycle.

Why CoreAudio is Hard at 2006-10-19 00:00
Tags: audio coreaudio rant I wrote this post over in comp.sys.mac.programmer.help, then realized that it would make a pretty decent blog post as well. I have edited it slightly to work as a blog post rather than as a newsgroup post. If you've ever wondered why CoreAudio is so difficult to use and why it can't be simple and easy like CoreImage or CoreVideo, read on.

Hacking C++ From C at 2006-08-03 00:00
Tags: magic c c++ hack For a long time, LiveDictionary used deeply unwholesome methods to do its work. Version 1.2.5, just released, now uses nothing but public methods. This means vastly improved stability, but it also means that LiveDictionary's evil WebKit text grabber, once considered the app's crown jewels, is no longer useful. I'm going to use it as an object lesson on how to do evil things with C++ applications from pure C.

Lesson of the Day at 2006-07-27 00:00
Tags: advice opengl OpenGL contexts have maximum viewport sizes. If you attempt to exceed the maximum size by, say, calling glViewport() with a size greater than that, you'll get incomplete drawing and weird corruption. This is particularly bad if you're using OpenGL as an interface element in a resizable window. To fix it, call glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims) to get the max viewport size, then limit your window's size to make sure you never exceed it.

Getting Answers at 2006-07-18 00:00
Tags: irc advice rant This is probably not so useful to my audience directly, but maybe you can forward it on to people who would find it helpful. I've written my own version of How To Ask Questions, but without gravely insulting anybody who reads it. People who ask questions don't really care about fitting in or conforming or following the rules, they just want answers. This guide tells you how to get answers with a minimum of fuss. And so I present Getting Answers. Any comments you might have on it are most welcome.

Using Evil for Good at 2006-07-14 00:00
Tags: cocoa objective-c c++ stl chemicalburn People who know me as a programmer probably know that I am a great hater of C++. As someone who does a lot of Cocoa, this extends naturally into hating Objective-C++. But I made good use of Objective-C++ in ChemicalBurn and I thought I'd share.

Autorelease is Fast at 2006-06-07 00:00
Tags: autorelease performance cocoa objective-c If you've done much Cocoa programming, you've probably run into a situation where you needed to create a local autorelease pool because of some sort of loop. And you've probably run into advice telling you not to create and destroy the pool for every iteration, because that would be slow. I never believed that it could be significant, and I finally took the time to test it today. What's the verdict? Just as I thought, making autorelease pools is really fast.

Making Xcode Better at 2006-05-31 00:00
Tags: link xcode I don't normally post these kinds of articles that are just links, but I really like this link, and also I haven't posted in a long time and I don't want anybody to think I'm dead. So I present to you: King of the Xcode. On the unlikely chance that there are any Apple employees reading who have a say in this sort of thing, please please please take his advice. I hold no illusions about my readership, but I am nothing if not hopeful.

Custom NSCells Done Right at 2006-04-06 00:00
Tags: nscell nib hack Anyone who's done enough Cocoa has eventually run into the nightmare that is subclassing an NSCell. While it looks simple enough, actually getting an Interface Builder-generated control to use your NSCell subclass is effectively impossible. You either have to use CustomViews in IB, write an IBPalette, or do a whole lot of tedious and error-prone manual copying of attributes to get everything from the IB-provided cell into your own.

Cocoa SIMBL Plugins at 2006-03-25 00:00
Tags: cocoa simbl injection pluginThis post was contributed by guest poster Joshua Pokotilow.
Occasionally, we wish our favorite programs would sport a particular feature that just isn't there. Those of us who aren't developers need to fall back on lobbying for features, but those of us fortunate enough to be in the biz, churning out line after line of Objective-C well into the heart of the night, waking up the next day with bloodshot eyes and feeling not unlike the living dead, have other options. O, we lucky few.

Fluid Simulation for Dummies at 2006-03-13 00:00
Tags: fluid simulation In the spring and summer of 2005, I wrote my Master's thesis on high-performance real-time 3D fluid simulation and volumetric rendering. The basics of the fluid simulation that I used are straightforward, but I had a very difficult time understanding it. The available reference materials were all very good, but they were a bit too physics-y and math-y for me. Unable to find something geared towards somebody of my mindset, I'd like to write the page I wish I'd had a year ago. With that goal in mind, I'm going to show you how to do simple 3D fluid simulation, step-by-step, with as much emphasis on the actual programming as possible.

NSOpenGLContext and one-shot at 2006-02-23 00:00
Tags: advice opengl cocoa If you've done any OpenGL work in Cocoa, you may have noticed that OpenGL surfaces behave badly when it comes to things like miniaturization and deminiaturization to the Dock. This recently caused some big problems for me, and I finally found out how to get rid of these problems altogether. It wasn't excruciatingly hard to find, but I wanted to make a post about it here so that it could be found with words like "deminiaturization".

Tags: link float numerical I have a short post for once! I happened to be talking about floating-point comparisons, and I trotted out my usual web page explaining all about floating-point calculation and error. And then I thought, this stuff is so essential, I ought to post it here as well. So without further ado: What Every Computer Scientist Should Know About Floating-Point Arithmetic. A bit heavy on the math, but if you've ever wondered why printing out 10.1 gives you 10.1000002, or why 1.0/10.0 * 5.0 != 1.0/2.0, this will explain it all.

Braaaaaaaains at 2006-02-20 00:00
Tags: bolo gamesA couple of articles back, I wrote an article about Bolo, and briefly mentioned an OS X version called nuBolo. Those of you who have tried it have no doubt noticed how authentic it is. You may also have noticed that it's lacking Bolo's Brains (AI plugins) support. I'm working on a module to add Brains support to nuBolo, and I've reached the stage where I thought I'd make a post about it.

Bug Reversal at 2006-02-06 00:00
Tags: unicode bug The most interesting bugs for me are the bugs which appear at the confluence of many different things. Module A has a small defect, which happens to expose a lack in module B, causing it to feed bad data to module C, which then behaves oddly. With a difference in any of those modules, the problem might never have appeared. I recently saw a non-bug which is a great example of this kind of interaction.

Bolo Ecology at 2006-01-01 00:00
Tags: bolo games Today I'm going to talk to you about the mechanics and social interactions in a little-known Mac tank game. Those of you who understood the title already know which one. For those of you who don't, the game is Bolo. For people suddenly hit with nostalgia, there's a Carbon port now available which is amazingly authentic.

Score! at 2005-11-09 00:00
Tags: ioccc evil c lisp The International Obfuscated C Code Contest is a contest with the goal of creating the most unreadable, difficult-to-understand C program possible. Aside from being difficult to understand, the judges tend to prefer programs which do clever or interesting things, or which do mundane things in clever, interesting, or weird ways.

Fun With Beowulf Clusters at 2005-07-13 00:00
Tags: university rant I've been working on my Master's thesis for the past four months or so, and having an interesting time of it. Today, I finally reached an important goal: running a fluid simulation split into separate simulation and visualization components, with different components running on different computers for speed. The bad news is that I'm not using a single bit of my university's clustering library which I'm supposed to be using.

Tags: filemerge subversion versioncontrol python I was introduced to subversion about a month and a half ago, and have generally found it to be wonderful, and a vast improvement over CVS. I won't get into the details, because I'll just sound like every other person out there who has switched to svn and then raved about it, so you can just look up somebody else's blog post on the subject. One thing I did miss, however, was the ability to open diffs in FileMerge.

Dashboard Rant at 2005-04-29 00:00
Tags: dashboard rant I've spent a good part of the last few days working on a Dashboard widget, trying to get it ready in time for the release. The good news is that I got it done and working. The bad news is that Dashboard seems like a horrible, badly-designed development environment. The main purpose of this post is to rant about that, but it'll also include the occasional tip for writing your own widget.

Name/comment conflict at 2005-01-24 00:00
Tags: humor content-free Going through some code, I came across a function called AtomicReplaceDirectory. The very first line of this function was a comment that said:

note, despite the name, this is *not* atomic.

Isn't it great when the name and the comments are at odds?