<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>More of a programming nerd than is strictly healthy. See also {nevyn.nu, thirdcog.eu, twitter}</description><title>Overooped</title><generator>Tumblr (3.0; @nevyn)</generator><link>http://overooped.com/</link><item><title>Fantastic and beautiful conclusion to Everything is a Remix, by...</title><description>&lt;iframe src="http://player.vimeo.com/video/36881035" width="400" height="225" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Fantastic and beautiful conclusion to Everything is a Remix, by Kirby Ferguson.&lt;/p&gt;</description><link>http://overooped.com/post/17896938775</link><guid>http://overooped.com/post/17896938775</guid><pubDate>Sun, 19 Feb 2012 20:28:13 +0100</pubDate></item><item><title>You can't discover anything if you can't see what you're doing.</title><description>&lt;iframe src="http://player.vimeo.com/video/36579366?byline=0" width="800" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;The above presentation by Bret Victor is amazing, and I couldn’t stop tweeting about it the other day. My mind was blown at:&lt;/p&gt;

&lt;p&gt;&lt;b style="font-size: 110%;"&gt;4:20&lt;/b&gt;. cool! I mean, I’ve seen live editors before, but I never thought of actually using sliders on numbers. Clever! I remember now though, that this has been done by &lt;a href="http://twolivesleft.com/Codea/"&gt;Codea&lt;/a&gt; (and probably others) before.&lt;/p&gt;

&lt;p&gt;&lt;b style="font-size: 150%;"&gt;5:25&lt;/b&gt;. What. That changes the way I think about programming visual things. I keep thinking of all the times I’ve tweaked an animation or gradient, recompiled, redeployed to device, and get to experience my change maybe a full minute later. How many solutions have I missed, had I just been able to drag a slider to try variations?

&lt;/p&gt;&lt;p&gt;I’ve tried to come up with solutions to this problem several times before. My first try was &lt;a href="https://github.com/nevyn/RemoteParameter"&gt;RemoteParameter&lt;/a&gt;. However, it is incredibly clumsy to integrate into the code being modified: modified variable must be KVO compliant, it only works for a single spot in the code (so it will fail if you’re e g modifying the background color for all cells in a list), and the editor UI is atrociously bad.&lt;/p&gt;

&lt;p&gt;My second try was with &lt;a href="https://github.com/nevyn/NuRemoting"&gt;NuRemoter&lt;/a&gt;. This tool I still actually use, and is somewhat useful in working with living code (sending calls in the middle of animations, debugging time sensitive operations, etc). However, it is not at all visual, and any code I improvise in the NuRemoter UI will be in Nu, which I can’t use as-is in my project without rewriting it into ObjC. I have a few thoughts here, though: first off, I should make it easier to hook Nu code into our code base, so that things that are naturally expressed in a script-y langage, can be. Secondly, the NuRemote protocol can be used as a payload delivery system for other tools. For example, if I ever write an animation construction kit, I could use NuRemoter to upload and inject animation descriptions into the app, and immediately try them out. (I’ve thought of integrating it into my Localizer localization app, too).&lt;/p&gt;

&lt;p&gt;Wait, animation construction kit? Well, Core Animation is incredibly powerful and easy to use, but expressing animations in code is both unintuitive and slow (see: write/compile/deploy/test cycle), and maybe &lt;a href="http://twitter.com/tobiasahlin"&gt;tobi&lt;/a&gt; is a better animator than me? I want something like the GLSL Shader editor: define input parameters (perhaps start and end locations, duration, intensity) and a sample image as a placeholder for the UIView being animated, and then define animations Keynote-style, possibly with values substituted for parameters. Output a json file, load it at runtime and use it instead of all the animation code. Shouldn’t be THAT hard to build?&lt;/p&gt;

&lt;p&gt;&lt;b style="font-size: 110%;"&gt;6:10&lt;/b&gt;. My jaw drops just a tiny bit further, but enough to mark the time. Well, typing autocompletions into the autopreviewing document so that they run automatically is pretty obvious, but I love the idea of &lt;em&gt;showing&lt;/em&gt; you what the thing does, rather than having you read documentation. Maybe the right sidebar in Xcode should have movies instead of help snippets?&lt;/p&gt;

&lt;p&gt;&lt;b style="font-size: 110%;"&gt;7:43&lt;/b&gt; and &lt;b style="font-size: 110%;"&gt;8:12&lt;/b&gt;. How the hell did he do that‽&lt;/p&gt;

&lt;p&gt;&lt;b style="font-size:130%;"&gt;11:30&lt;/b&gt;. Again, how did he do that‽ He’s obviously not re-evaluating the whole file on each change. Maybe he’s been careful when writing the file so that it can be re-evaluated in the context of the currently “running” web page/js-vm? It looks like an incredibly nice way to code games, though. A little bit like &lt;a href="http://unity3d.com/"&gt;Unity&lt;/a&gt; I guess; I remember having my mind blown the first time I saw that editor, too.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;13:00&lt;/b&gt; and &lt;b&gt;14:10&lt;/b&gt;. Now he’s just showing off. Surely this editor must be specifically written for this game engine he has constructed, and not something generic. Still want that code+editor, though!&lt;/p&gt;

&lt;p&gt;Around &lt;b&gt;16:00&lt;/b&gt; he re-iterates again how easy it is to be creative when you can visualize your results live, and how it doesn’t just apply to visuals or animations, but entire gameplay ideas. I’m so very sold on the idea.&lt;/p&gt;

&lt;p&gt;Around &lt;b&gt;20:00&lt;/b&gt;, I really love the idea of supplying sample input data and see how that affects the code you just wrote.&lt;/p&gt;

&lt;p&gt;Around &lt;b&gt;26:00&lt;/b&gt;, I should’ve realized that this is the same guy as &lt;a href="http://overooped.com/post/5616388460/this-this-is-how-to-teach-math-the-contrast"&gt;the one who made That Math Video&lt;/a&gt; that blew my mind pretty thoroughly last year. I didn’t, until I checked &lt;a href="http://worrydream.com/"&gt;his web site&lt;/a&gt; in preparation for this blog entry. He has plenty of new interesting entries there, if you haven’t checked them out lately.&lt;/p&gt;

&lt;p&gt;However, out of all of these, the moment that perhaps isn’t the most interesting to me as a programmer, but never the less tipped me over from “yes, I am impressed” into a squealing, giggling pile of fanboyism, is &lt;b style="font-size:150%;"&gt;31:30&lt;/b&gt;. Probably the most amazing animation editor I’ve seen, and probably the most intuitive power user UI I’ve seen, and it’s just an experiment he made? &lt;b style="text-decoration: blink;"&gt;MIND BLOWN&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;I love how, instead of trying to solve the problem of tiny hit targets with giant thumbs, he has the user select the layer with her left hand, while manipulating it with her right. It’s a touch surface, and the user has two hands: why is nobody else using this fact‽ (my mind was similarly blown in ‘05 by the same multi-hand usage by &lt;a href="http://www.tactiva.com/"&gt;TactaPad&lt;/a&gt;, which sadly never became an actual product).&lt;/p&gt;

&lt;p&gt;Compositing all the different animations the user wants to get into the scene by just scrolling back time and immediately performing the next animation is equally genius (also seen, but not at all as well implemented, in Garageband.). Just look at the amazing speed at which he composes that scene!&lt;/p&gt;

&lt;p&gt;However, out of all the amazing things Bret is showing us, none are as inspiring as his outro. Ever since I started programming, I’ve felt an idea or principle just at the edge of my consciousness. I know it’s related to creating a user interaction paradigm that is more natural, but I can’t describe it more clearly than that. I just know, for example, that multitouch is a step in the right direction. I haven’t thought about it too much in the past two years as I’ve been busy at Spotify, and Bret’s note at the end that doing only one thing will not give you insights really hit home.&lt;/p&gt;

&lt;p&gt;Alright, enough gushing. I hope that after all that, you did actually watch the video, and that you found as much inspiration as I did. Right now, I just want to stop everything I’m doing and take a few months off life and make tools. I should probably &lt;a href="http://community.spotify.com/t5/Spotify-Ideas-and-Feedback/iPad-app/idi-p/265"&gt;finish a few projects&lt;/a&gt; first though…&lt;/p&gt;</description><link>http://overooped.com/post/17790355071</link><guid>http://overooped.com/post/17790355071</guid><pubDate>Sat, 18 Feb 2012 00:46:00 +0100</pubDate></item><item><title>Rapid network protocol prototyping with TCAsyncHashProtocol</title><description>&lt;p&gt;&lt;a href="https://github.com/nevyn/TCAsyncHashProtocol"&gt;github:TCAsyncHashProtocol&lt;/a&gt;. I like constructing simple network protocols from plist/json-safe dicts, and
transmit them over the wire as json. Easy to prototype with, easy to debug.
Give TCAHP an AsyncSocket, and this is what it’ll do for you, plus
support for request-response, and arbitrary NSData attachments.&lt;/p&gt;

&lt;p&gt;It is an embarrassment and almost an insult that my example project is a massive
200 lines. I hope to be able to reduce the verbosity and boilerplate clutter of
using TCAHP without making it heavy-weight. At the very least, I recommend that you
use &lt;a href="https://github.com/nevyn/SPSuccinct/blob/master/SPSuccinct/SPLowVerbosity.h"&gt;SPLowVerbosity&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;An example of using TCAHP to send a request to update the server’s MOTD:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[_proto requestHash:$dict(
    @"command", @"setMessage", // the command is 'setMessage'
    @"contents", msg // Send 'msg' as the new message to set.
) response:^(NSDictionary *response) {
    // The server has replied.
    if([[response objectForKey:@"success"] boolValue])
        NSLog(@"Successfully updated message!");
    else
        NSLog(@"Couldn't set message, because %@", [response objectForKey:@"reason"]);
}];&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And on the receiving side:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;-(void)request:(TCAsyncHashProtocol*)proto setMessage:(NSDictionary*)hash responder:(TCAsyncHashProtocolResponseCallback)respond;
{
    NSString *newMessage = [hash objectForKey:@"contents"];
    if([newMessage rangeOfString:@"noob"].location != NSNotFound)
        respond($dict(
            @"success", (id)kCFBooleanFalse,
            @"reason", @"you should be kind!"
        ));
    else {
        _message = newMessage;
        respond($dict(
            @"success", (id)kCFBooleanTrue
        ));
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(Note the latest piece of magic that I added, where the selector of the delegate
method is created based on the value of the key ‘command’ in the message. I quite
like it.)&lt;/p&gt;

&lt;p&gt;As you can see, the resulting protocol is very weakly typed. In theory,
this means you will be making typos and not understanding why the hell
your network seems broken; in reality, I’ve never had that problem.&lt;/p&gt;</description><link>http://overooped.com/post/14937574206</link><guid>http://overooped.com/post/14937574206</guid><pubDate>Wed, 28 Dec 2011 23:12:00 +0100</pubDate><category>faves</category><category>flattr</category><category>networkdev</category><category>iosdev</category><category>programming</category></item><item><title>"If you are going to end up with a crappy to mediocre blender anyway, then why bother spending more..."</title><description>“If you are going to end up with a crappy to mediocre blender anyway, then why bother spending more or availing yourself of the advice and service of a specialty retailer? Reducing the overall quality of products thus destroys a key competitive advantage of Walmart’s smaller rivals.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;a href="http://www.grist.org/business-technology/2011-11-11-is-your-stuff-falling-apart-thank-walmart"&gt;Is your stuff falling apart? Thank Walmart (grist.org)&lt;/a&gt;. yay for progress?&lt;/em&gt;</description><link>http://overooped.com/post/13125745353</link><guid>http://overooped.com/post/13125745353</guid><pubDate>Mon, 21 Nov 2011 22:47:14 +0100</pubDate></item><item><title>"By categorizing our cognitive flaws, documenting not just our errors but also their embarrassing..."</title><description>“By categorizing our cognitive flaws, documenting not just our errors but also their embarrassing predictability, he has revealed the hollowness of a very ancient aspiration. Knowing thyself is not enough. Not even close.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;a href="http://www.newyorker.com/online/blogs/books/2011/10/is-self-knowledge-overrated.html"&gt;Is Self-Knowledge Overrated?&lt;/a&gt; at the new yorker. not very surprising, but sort of confirms that everyone’s an idiot, not just me :P&lt;/em&gt;</description><link>http://overooped.com/post/11961928627</link><guid>http://overooped.com/post/11961928627</guid><pubDate>Wed, 26 Oct 2011 23:13:55 +0200</pubDate></item><item><title>I’ve been trying to build a wearable computer since...</title><description>&lt;img src="http://30.media.tumblr.com/tumblr_ltc19pKLz71qz4vmko1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;I’ve been trying to build a wearable computer since forever, but I sort of got stuck because there aren’t (or I can’t find) any good HMDs (head-mounted displays) that don’t cover your entire field of vision (covering just one eye is fine, but being see-through would be the best, of course). I’ve had a Google Alert on the AirScouter for a year or so, and it seems they’re finally releasing them in some sort of product. I want one *so badly*, but they’re targeted at industrial application and priced thereafter, at $5200 :( I may be a huge frickin’ nerd, but I can’t really justify spending that kind of money on yet another hobby project…&lt;/p&gt;</description><link>http://overooped.com/post/11666364221</link><guid>http://overooped.com/post/11666364221</guid><pubDate>Wed, 19 Oct 2011 23:34:00 +0200</pubDate></item><item><title>Photo</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_lqhr46trpa1qz9917o1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;</description><link>http://overooped.com/post/11106349791</link><guid>http://overooped.com/post/11106349791</guid><pubDate>Thu, 06 Oct 2011 20:23:40 +0200</pubDate></item><item><title>"Your brain begins to know that you are “enjoying” yourself, even if you hate this insipid thing. In..."</title><description>“Your brain begins to know that you are “enjoying” yourself, even if you hate this insipid thing. In spite of a love-shaped hole in the center of your spirit re: this electronic monster, you will not turn away. […] What gruesome psychomathematiconomist devised this heart-labyrinth?”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;a href="http://insertcredit.com/2011/09/22/who-killed-videogames-a-ghost-story/"&gt;insertcredit (4 chapters)&lt;/a&gt; reminds me why I hate “social games” more than TV. Memetic T-Viruses, turning human beings into zombies.&lt;/em&gt;</description><link>http://overooped.com/post/10732726257</link><guid>http://overooped.com/post/10732726257</guid><pubDate>Tue, 27 Sep 2011 20:21:45 +0200</pubDate></item><item><title>How To Fix Xcode 4</title><description>&lt;p&gt;People are sort of tired of me complaining; I’ve been saying I hate Xcode 4 since the first time I used it. “You’ll get used to it!”, “Learn Behaviors and everything will be well”, “Embrace the new UI model”, they said. I’ve been using it exclusively for several months now, trying to explore and use every feature of it; make sure to try to find a way in which I can confidently work in it. I failed. Launching Xcode 3 is a fresh breeze every time.&lt;/p&gt;

&lt;p&gt;Just a note up front: I’m not saying Xcode 4 sucks. It is light-years ahead of Xcode 3 in many ways, particularly autocompletion and the IDEs idea of what the code contains (inline warnings and errors as you type is wonderful). This is just about the way it manages windows and tabs. And even then, maybe there is some mode or usage pattern that I don’t know about and would fit me better — if so, please shout in the comment or to my twitter!&lt;/p&gt;

&lt;h2&gt;Spatial Thinking&lt;/h2&gt;
&lt;p&gt;Xcode 4 works fantastically for a lot of people. How am I special? Why do I have to try to be so &lt;em&gt;different&lt;/em&gt; all the time? Apart from just generally being an annoying sod, I imagine myself being a spatial thinker; I like to think in terms of spatially organizing whatever concepts I’m working with. I loved Classic Mac OS’ spatial Finder, where windows always appeared at the same location were it did last time, and there was a one-to-one mapping between folder and window.&lt;/p&gt;

&lt;p&gt;The same goes for me and source code files. I used to work in Condensed Mode in XC 3; a single thin window with a project file listing, all source windows separate, and then dedicated slots for Build and Run windows on a separate screen (together with a terminal or two). I would work with a dozen source files at the same time, placing them around the screen. When I needed one I used recently, I would know where it would be spatially, and could just click a tiny corner or edge peeking out beneath whatever I was working on&lt;a href="#xc4-ref1" id="backref1"&gt;(1)&lt;/a&gt;. This way I could also layer other applications in between windows, and have a rather deep pile of things I’m working on. It’s the classic desktop metaphor, and the main argument against Multiple Document Interfaces (MDIs) that we Mac nerds would ridicule Windows users for having to use every day&lt;a href="#xc4-ref2" id="backref2"&gt;(2)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You might be able to imagine why XC4 would then be a problem for me, with everything in a single window, everything appearing in the exact same location on screen as you instead switch between modes of operation in one screen area, rather than switching between locations and zones on the screen. It was — and is — a complete disaster for my productivity. I spend so much time switching between contexts nowadays, trying to reorient myself. &lt;/p&gt;

&lt;h2&gt;Staying In the Past?&lt;/h2&gt;
&lt;p&gt;Trying to work in an Xcode 3 manner in Xcode 4 is worse than just trying to adapt.&lt;/p&gt;

&lt;p&gt;One of the best features of Xcode 3 is that it would remember all the open windows of a project when you closed it. In Xcode 4, closing a window is terminating it and its layout forever, and the last window you happen to close will become the main project window. Oh, you accidentally closed the window *you* consider the main window first, and then you had a reference header in a window configured for reading reference headers still open on another screen? Well, I guess that’s your main window now, and you’ll just need to reconfigure it as your main. (&lt;b&gt;Update&lt;/b&gt;: There is in fact “Close project” in File which will remember all the windows. This doesn’t help in the situation where you close one window forgetting that you had two open though, which is quite common.)&lt;/p&gt;

&lt;p&gt;Want a separate window for your build progress so you can keep track of what’s actually happening in your builds? That’s in a sidebar now, and if you actually want build details, you have to manually choose the latest build results in *another* sidebar, and then switch back to the first sidebar.&lt;/p&gt;

&lt;p&gt;Want a separate window for your console output? Hey, there’s this hack where you can name a tab “console”, bring up the debug lower-pane, set that pane to console output, make the pane fill the window, turn off the left-and-right sidebars, drag the tab out to its on window. Remember to put it back in its tab before closing the window though, or it’ll become your project!&lt;/p&gt;

&lt;p&gt;OK, this is not working.&lt;/p&gt;

&lt;h2&gt;Trying To Adapt&lt;/h2&gt;
&lt;p&gt;The way I work now is to have everything I used to have in separate windows, in separate tabs; and have Behaviors set to switch to them at appropriate times. I have one Build tab and one Debug tab, set up in a pretty nice way. I mean, this is okay, I can work this way. However, I do lose my focus a lot of the time, and I get lost trying to context switch between tabs. And I need to set this up for every project I start working on. And I can’t really use my secondary monitor for the things I like and used to do. And it’s just a pain.&lt;/p&gt;

&lt;h2&gt;Fixing Shit&lt;/h2&gt;
&lt;p&gt;Why alienate all spatial thinking developers from the Mac and iOS developer communies? I can absolutely imagine Condensed Mode working in Xcode 4. The concept of optional sidebars everywhere could still work. I’d just want to pull out the Project navigator sidebar into its own window which becomes the ‘project main’ (closing it closes all related windows); allow some of the more awkward sidebars like the Object Library to be a panel like in IB; have dedicated Build and Console windows; and have the IDE try to suggest the “one file per window” concept (but possibly allow browsing different files within one window is the user really wants to). I mocked up a horrible concept in Acorn, for your viewing pleasure:&lt;/p&gt;

&lt;a href="http://nevyn.nu/blog/images/xcode4-condensed.jpeg"&gt;&lt;img src="http://nevyn.nu/blog/images/xcode4-condensed.jpeg" width="100%"/&gt;&lt;/a&gt;


&lt;p&gt;This would make me very, very happy. Sure, it’d be half as “fast” as Xcode 3, it’d still forget how to autocomplete once a day, and crash pretty much every minute, but at least I could work with it.&lt;/p&gt;

&lt;p&gt;Thanks to Brent Simmons for writing “&lt;a href="http://inessential.com/2011/09/02/the_part_of_xcode_4_that_tires_me_out" title="inessential.com: weblog"&gt;The part of Xcode 4 that tires me out&lt;/a&gt;”, finally triggering me to write this post.&lt;/p&gt;

&lt;div class="footnodes" style="color:#444; font-size: 70%"&gt;
  &lt;p id="xc4-ref1"&gt;&lt;a href="#backref1"&gt;(1)&lt;/a&gt;: This is why I hate Exposé in 10.6 and 10.7. 10.5 and earlier would lay out Exposé windows with the same relative position of windows as they were when non-exposéd. 10.6 started organizing windows in a frickin’ grid, destroying important information about where a window came from and what role it had. (&lt;a href="rdar://7044208"&gt;rdar&lt;/a&gt;://&lt;a href="http://www.openradar.me/7044208"&gt;7044208&lt;/a&gt;)&lt;/p&gt;

  &lt;p id="xc4-ref2"&gt;&lt;a href="#backref2"&gt;(2)&lt;/a&gt;: It’s worth to note that the prevalence of MDI on Windows is a symptom of not having a real application metaphor, and thus having to group all windows in a meta-window in order to regain an actual application context. Mac OS never had this problem, as an application is the primary unit of operation and the main metaphor there, and not the window.&lt;/p&gt;
&lt;/div&gt;</description><link>http://overooped.com/post/9754992925</link><guid>http://overooped.com/post/9754992925</guid><pubDate>Sat, 03 Sep 2011 20:59:00 +0200</pubDate><category>cocoadev</category><category>macdev</category><category>iosdev</category><category>xcode</category><category>faves</category><category>flattr</category><category>xcode4</category><category>ui</category></item><item><title>"Software today is not engineering. Building the Empire State Building with three thousand people in..."</title><description>“Software today is not engineering. Building the Empire State Building with three thousand people in a year is engineering. Programming today is more like the Egyptians piling blocks on each other and hoping it doesn’t fall over.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;p&gt;Paraphrasing &lt;b&gt;Dr Alan Kay&lt;/b&gt; in &lt;a href="http://tele-task.de/archive/video/flash/14029/"&gt;his talk “Programming and Scaling”&lt;/a&gt;. I got the same sense of depression over the state of our industry when I read about &lt;a href="http://www.youtube.com/watch?v=X4kp9Ciy1nE"&gt;Doug Engelbart’s amazing NLS system from ‘68&lt;/a&gt; and the &lt;a href="http://en.wikipedia.org/wiki/Hypertext_Editing_System"&gt;Hypertext Editing System in ‘67&lt;/a&gt;. Yes, we have millions and millions times faster computers today, but what we’re doing today is not &lt;em&gt;news&lt;/em&gt;. They realized already in ‘68 that you want direct manipulation and collaborative computing. &lt;/p&gt;

&lt;p&gt;Every day, I spend so much time building almost trivial functionality in thousands of lines of code, with brittle APIs that hook into other people’s brittle APIs, because that’s the code base we have, and every other code base seems to be roughly looks like that, too. I spend my weekends learning about C and C-like systems because that’s what I know; I don’t go around learning about compiler-compilers, I’m stuck in what my brain already “knows” that programming is like. I didn’t know twenty minutes ago that you could write a complete compositing 2d graphics environment with 26 compositing method in under 400 lines of code.&lt;/p&gt;

&lt;p&gt;My very good friend &lt;a href="http://twitter.com/swedishnomad"&gt;Martin&lt;/a&gt; once told me how different it is to even think in Japanese and Chinese, how those thoughts can’t even be translated into English. Kay’s realization that the same holds true for programming is profound in a way I didn’t realize before.&lt;/p&gt;

&lt;p&gt;Back in uni I unwittingly participated in an experiment. One of the teachers arranged two lab sessions with the exact same content, and put Java programmers in one and C++ programmers in the other. We were given some UML and were asked to implement it. The real task had actually been to see how fast we could build it (but were of course not told in beforehand that we were being timed); and while I was fastest in my group and it felt like the C++ came out pretty naturally, the result showed that it took me twice as long to write the code than it took on average for the Java coders.&lt;/p&gt;

&lt;p&gt;Ever since then, I’ve been worried that even though I feel like I’m really fast with my tools, those very tools are holding me back, and I’m *really* just a tenth as fast as I could have been with another set of tools. I love ObjC, but it’s still C, it still got non-object types, there’s still manual memory management, everything is viciously verbose, and meta programming is still more limited than in some non-C languages.&lt;/p&gt;&lt;/em&gt;</description><link>http://overooped.com/post/8599617064</link><guid>http://overooped.com/post/8599617064</guid><pubDate>Sun, 07 Aug 2011 15:55:00 +0200</pubDate><category>faves</category><category>programming</category><category>coding</category></item><item><title>Bret Victor, beast of burden</title><description>&lt;a href="http://worrydream.com/"&gt;Bret Victor, beast of burden&lt;/a&gt;: &lt;p&gt;Remember that &lt;a href="http://overooped.com/post/5616388460/this-this-is-how-to-teach-math-the-contrast"&gt;amazing UI math video&lt;/a&gt; I posted a while back? He got a &lt;a href="http://www.fastcodesign.com/1664508/ex-apple-designer-creates-teaching-ui-that-kills-math-using-data-viz"&gt;nice interview and article in nicecodesign.com&lt;/a&gt;. Apparently it was made by &lt;a href="http://worrydream.com/"&gt;Bret Victor&lt;/a&gt;. I didn’t know who Bret Victor was until a few moments ago, but it seems he’s pretty much awesome. &lt;a href="http://worrydream.com/"&gt;His web site&lt;/a&gt; is rather amazing, and his portfolio page &lt;a href="http://worrydream.com/Apple/"&gt;about his work at Apple is very funny and very sad&lt;/a&gt; at the same time. He also worked at Push Pop Press; you know, that amazing publishing-revolutionizing company that got black-holed by Big Blue? No, not &lt;a href="http://www.ibm.com/"&gt;&lt;em&gt;that&lt;/em&gt; Big Blue&lt;/a&gt;, the &lt;a href="https://www.facebook.com/"&gt;&lt;em&gt;new&lt;/em&gt; Big Blue&lt;/a&gt;.&lt;/p&gt;</description><link>http://overooped.com/post/8596643873</link><guid>http://overooped.com/post/8596643873</guid><pubDate>Sun, 07 Aug 2011 12:54:00 +0200</pubDate></item><item><title>"Design patterns in general are a recipe for failure, as they are indicators of flaws in your..."</title><description>“Design patterns in general are a recipe for failure, as they are indicators of flaws in your language. A design pattern inherently violates DRY as it means that many people have written something very similar, but it has not been abstracted out.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;a href="https://plus.google.com/115847272457568211304/posts/1k4bJJbcjkz"&gt;Matthew Maurer&lt;/a&gt; in a thread by Andy Matuschak. Whole comment thread is interesting.&lt;/em&gt;</description><link>http://overooped.com/post/8270936783</link><guid>http://overooped.com/post/8270936783</guid><pubDate>Sat, 30 Jul 2011 23:38:00 +0200</pubDate></item><item><title>Low Verbosity KVO</title><description>&lt;h2&gt;DRY Cocoa: SPLowVerbosity&lt;/h2&gt;
&lt;p&gt;I love Objective-C. It’s a very explicit language: there is no magic in the language. If you want such magic as distributed objects, model classes generated at runtime, generic change notification, or heck, even referenced counted memory management, you can implement it yourself in a library. It’s also by convention a very verbose language. If the method name doesn’t say exactly what the method does, the author is doing it wrong.&lt;/p&gt;

&lt;p&gt;However, there are some things we type over and over again every day, whose verbosity does not make the code more readable but only serves to pad the code file with useless characters. These are in particular array and dictionary literals, and formatted strings.&lt;/p&gt;

&lt;p&gt;ObjC wizard &lt;a href="http://jens.mooseyard.com/"&gt;Jens Alfke&lt;/a&gt; wrote &lt;a href="https://bitbucket.org/snej/myutilities"&gt;MYUtilities&lt;/a&gt; quite a while ago, and in particular &lt;a href="https://bitbucket.org/snej/myutilities/src/5f25fbb44fa6/CollectionUtils.h"&gt;CollectionUtils&lt;/a&gt;. This header defines a few very handy macros such as &lt;code&gt;$array(...)&lt;/code&gt;, &lt;code&gt;$dict(...)&lt;/code&gt; and &lt;code&gt;$sprintf(...)&lt;/code&gt;. &lt;code&gt;$array&lt;/code&gt; is simply a shorthand for &lt;code&gt;[NSArray arrayWithObjects:..., nil]&lt;/code&gt; (note the extra &lt;code&gt;nil&lt;/code&gt;, freeing you from typing that yourself every time, and also avoiding a possible crash). &lt;code&gt;$dict&lt;/code&gt; is &lt;code&gt;NSDictionary&lt;/code&gt;’s constructor, with the arguments in the right order (key, value, key, value, …). &lt;code&gt;$sprintf&lt;/code&gt; is &lt;code&gt;[NSString stringWithFormat:]&lt;/code&gt;. It may seem trivial, but this simple header has saved me tons and tons of typing, and surely from some silly bugs as well.&lt;/p&gt;

&lt;p&gt;For more C++ friendliness, and to not have to depend on the rest of MYUtilities, &lt;a href="https://github.com/nevyn/SPSuccinct/blob/master/SPSuccinct/SPLowVerbosity.h"&gt;I wrote my own, called &lt;b&gt;SPLowVerbosity&lt;/b&gt;, with mostly the same things&lt;/a&gt;. The details are not interesting, so I won’t list the code; click through if you are curious.&lt;/p&gt;

&lt;p&gt;This is a hack, and while it is very convenient, it is not pretty. Objective-C needs in-language literals for arrays, sets, dictionaries and number objects.&lt;/p&gt;

&lt;p&gt;I do believe that such literals are now inevitable, though. With ARC, what I wrote in the first paragraph is no longer entirely true. Dealloc now magically calls super. Memory management is implicit and part of the language, not explicit and manual. The sanctity of Objective-C’s simplicity has been violated, parts of Cocoa has been moved into the language. Moving more parts of Cocoa into the language (e g exposing APIs saying ‘this is the class that should be instantiated when I use a dictionary literal’) no longer has a high religious price, and I bet we’ll see it at next year’s WWDC.&lt;/p&gt;

&lt;h2&gt;Object-Oriented KVO: SPKVONotificationCenter&lt;/h2&gt;
&lt;p&gt;During the past few years, my nose has started to really pick up on a code smell I didn’t feel before: unencapsulated concepts. What I mean by that is an API concept or contract that is only visible in comments and documentation, thus only &lt;u&gt;implicit&lt;/u&gt; by knowledge of that documentation when you read code using the API, instead of exposing the concept as a construct the language can help you manage.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Mutex locking as two separate functions that must always be paired. This is an easy to make mistake, and can be very difficult to fix in complexly branching code. Static analyzation can find such errors, but is in my opinion the wrong approach.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;UITableView&lt;/code&gt;’s &lt;code&gt;beginUpdates&lt;/code&gt;/&lt;code&gt;endUpdates&lt;/code&gt; must always be called in a pair, and all the updates you make in that pair must match the changes you are doing to the data source.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;NSNotificationCenter&lt;/code&gt; requires you to register for a notification with a {sender, receiver, name} triplet, and reuse that triplet to destroy the subscription. In practice what you have here is an implicit object that you must manage using an awkward object triplet, rather than an actual object.&lt;/li&gt;
&lt;li&gt;Key-Value Observing, with the same defect as with notifications, plus that callbacks are dispatched to the same instance method, forcing you to use the triplet plus a context pointer as the identifier again.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Instead of the above concepts being implicit and only visible in documentation, several of them can be represented as objects and closures, thus making it impossible to do wrong.&lt;/p&gt;

&lt;p&gt;The realization is not new, of course. It’s quite common to use &lt;a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization"&gt;RAII&lt;/a&gt; patterns in C++ to encapsulate concepts in code, giving them an explicit start point and a managed (and deterministic) end point.&lt;/p&gt;

&lt;p&gt;But this is Objective-C, not C++, so we don’t have RAII. We do have objects, however, and if we use them to actually represent our objects, we can clean up so much code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nevyn/SPSuccinct/blob/master/SPSuccinct/SPKVONotificationCenter.h"&gt;&lt;b&gt;&lt;code&gt;SPKVOObservation&lt;/code&gt;&lt;/b&gt;&lt;/a&gt; is an object that represents a KVO subscription. When this object is created, you know you have your subscription. When this object disappears, you know the subscription is gone. By managing instances of this class like I would any other instance variable, I know I’m following KVO’s subscribe/unsubscribe contract. (With ARC, I don’t even have to manage the ivar).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SPKVONotificationCenter&lt;/code&gt; also has dispatch to a given selector instead of the catch-all &lt;code&gt;-[NSObject observeValueForKeyPath:ofObject:change:context:]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;(As for solutions for the rest of the examples: a closure can be used for the mutex case if in the current scope, otherwise you might want RAII (which is possible with GNU extensions even in C). For the table view, I’d prefer bindings, but doing to-many KVO and bindings can be really hard, so I doubt we’ll be seeing it on iOS in the near future.)&lt;/p&gt;

&lt;h2&gt;DRY KVO: SPDepends&lt;/h2&gt;

&lt;p&gt;I love &lt;a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueObserving/"&gt;KVO&lt;/a&gt;. Basically every library I’ve ever used has their own implementation of notifications on attribute changes. Such an implementation is of course not difficult, but because there is no generic system for it in other languages/platforms, you can’t build a framework for working with change notifications generically. Recognizing that this is a generic concept, and then as good as building it into the language is genius, and has given us wonders such as bindings.&lt;/p&gt;

&lt;p&gt;Outside of their use in bindings where you have tool help, KVO’s API is pretty bad, and working with it is almost painfully verbose (made worse by the single callback point, spreading your code out all over the file). What I really wanted to do was to unify the two above sections for a very simple, non-verbose and object oriented approach to KVO. The result is &lt;a href="https://github.com/nevyn/SPSuccinct/blob/master/SPSuccinct/SPDepends.h"&gt;&lt;b&gt;&lt;code&gt;SPDepends&lt;/code&gt;&lt;/b&gt;&lt;/a&gt;. Magic is taken to the next level; we are approaching dark arts. Whether what I’m about to present is actually a good idea or not, I leave as an exercise for the reader. First, the header: &lt;!--Dashboard readers, this code is only visible on the blog entry. Head over to read it.--&gt;&lt;/p&gt;

&lt;script src="http://gist-it.appspot.com/github/nevyn/SPSuccinct/raw/master/SPSuccinct/SPDepends.h"&gt;&lt;/script&gt;&lt;p&gt;tl;dr: SPDepends lets you give it a list of {object, key path(s)} pairs that one of your properties depend on. When the value of any of the given key paths changes, a given closure is called, letting you recalculate the dependent property (or whatever you want to do). It’s about as far as you can go with KVO without actually building bindings.&lt;/p&gt;

&lt;p&gt;There is one additional piece of magic related to memory management (this was before ARC). By providing an owner and associationName, the dependency is assigned as an associatedObject, so that it will automatically be cleaned up when the owner object dies. Defining a dependency again with the same name will also throw away the old dependency. If this is not desired, you can just not provide the association name, and instead manage the returned &lt;code&gt;SPKVOObservation&lt;/code&gt; object on your own.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;
&lt;script src="http://gist-it.appspot.com/github/nevyn/SPSuccinct/raw/master/SPSuccinct/main.m"&gt;&lt;/script&gt;&lt;p&gt;Output:&lt;/p&gt;
&lt;script src="https://gist.github.com/1074637.js?file=output.txt"&gt;&lt;/script&gt;&lt;p&gt;Note how short the $depends macro makes all your KVO work. The macro also defines a block-safe &lt;code&gt;self&lt;/code&gt; variable &lt;code&gt;selff&lt;/code&gt; that won’t create a reference cycle.&lt;/p&gt;

&lt;p&gt;The equivalent classical KVO code would be many lines longer. However, this macro takes several steps away from how Cocoa code is normally written. Is the syntax too obscure? Is the code still readable for normal human beings?&lt;/p&gt;</description><link>http://overooped.com/post/7456709174</link><guid>http://overooped.com/post/7456709174</guid><pubDate>Sun, 10 Jul 2011 18:50:00 +0200</pubDate><category>cocoa</category><category>cocoadev</category><category>dev</category><category>ios</category><category>iosdev</category><category>kvo</category><category>mac</category><category>macdev</category><category>objc</category><category>faves</category><category>flattr</category></item><item><title>THIS. This is how to teach math. The contrast between the...</title><description>&lt;iframe src="http://player.vimeo.com/video/23839605" width="400" height="300" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;THIS. This is how to teach math. The contrast between the Wikipedia page and this application’s UI is striking.&lt;/p&gt;</description><link>http://overooped.com/post/5616388460</link><guid>http://overooped.com/post/5616388460</guid><pubDate>Wed, 18 May 2011 23:35:21 +0200</pubDate><category>math</category><category>ui</category><category>ipad</category><category>multitouch</category><category>intuitive</category><category>interactive</category></item><item><title>File format plugin API for Spotify?</title><description>&lt;p&gt;At Spotify, we have one and a half day of ‘hackday’ (‘code whatever you want’, the ‘20% time’ concept from Google) every sprint. Since the past few months have been a bit hectic finishing up &lt;a href="http://www.spotify.com/se/blog/archives/2011/05/04/spotify-says-hello-to-the-ipod/"&gt;the new 0.5.0 release&lt;/a&gt;, we haven’t really had time for that in a while, and thus compensated by having a whole week of crazy hacking this week. I managed to finish two features in that time; one in the iOS client (of which I will only say: Loren Brichter is my hero!), and one in the desktop client: file format plugins.&lt;/p&gt;

&lt;p&gt;Last year, one of my hackday projects was integrating &lt;a href="http://www.fly.net/~ant/"&gt;blargg&lt;/a&gt;’s &lt;a href="http://www.fly.net/~ant/libs/audio.html#Game_Music_Emu"&gt;Game Music Emu&lt;/a&gt; into Spotify, thus letting you play NES, GameBoy, SNES, Genesis, PC Engine and other console’s music files in Spotify. Just a few days of work, and suddenly I had the best console music player app in the world, with playqueue, playlists and whatnot. However, GME is LGPL and we statically link our dependencies, so there was no way I could release it :(&lt;/p&gt;

&lt;p&gt;Thus, I aimed to hit two birds with one stone: by adding a file format plugin API to Spotify, I could a) enable anyone to add support for their favorite file format in Spotify (flac, mikmod, sid, …) b) let me &lt;a href="https://github.com/nevyn/GMESPlugin"&gt;release the GME support as an open source plugin&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;However, I’ve never designed a plugin API in C before, and if we’re going to release it and support it for quite a while, it should be well designed, easy to use, and cover all the basic needs. It’s versioned, so it should be simple to add new things to the API, but changing the existing ones might be tricky. So, my question is: do you have any feedback for me on &lt;a href="https://github.com/nevyn/GMESPlugin/blob/master/local_file_plugin_api.h"&gt;this api&lt;/a&gt;? &lt;!--Dashboard readers: view this post on my blog to see the header embedded.--&gt;&lt;/p&gt;

&lt;p&gt;&lt;script src="https://gist.github.com/969905.js?file=local_file_plugin_api.h"&gt;&lt;/script&gt;&lt;/p&gt;</description><link>http://overooped.com/post/5505499488</link><guid>http://overooped.com/post/5505499488</guid><pubDate>Sun, 15 May 2011 11:20:00 +0200</pubDate><category>spotify</category><category>coding</category><category>dev</category><category>plugin</category></item><item><title>"When you hand a recursive mutex down from one routine to another, the callee cannot know the state..."</title><description>“When you hand a recursive mutex down from one routine to another, the callee cannot know the state of predicates in the caller. It has to assume there are some, because it cannot verify there aren’t; and if the caller had known that there were no broken predicates, it should have allowed concurrency by unlocking.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;p&gt;So, late night hacking trying to fix a stupid bug in Spotify. Find out that all mutexes in the Spotify codebase are recursive. Googleathon about recursive locks. Find interesting stackoverflow answers and blog posts and stuff. Some say recursive locks are Evil, but their arguments aren’t super-solid. &lt;a href="http://groups.google.com/group/comp.programming.threads/msg/d835f2f6ef8aed99?hl=en&amp;pli=1"&gt;Find the guy who wrote recursive locks in pthreads. He has good arguments.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basically: If you don’t know exactly the state of the stuff the lock is locking, how can you ever dare to call out to other code that would modify the stuff by taking the recursive lock? If you DO know exactly the state of the stuff the lock is locking, why are you holding the lock?! In other words, don’t use recursive locks.&lt;/p&gt;&lt;/em&gt;</description><link>http://overooped.com/post/4616155524</link><guid>http://overooped.com/post/4616155524</guid><pubDate>Fri, 15 Apr 2011 00:08:59 +0200</pubDate></item><item><title>"On the plus side, it’s now easier to add a new contact, and I can decide whether to call somebody or..."</title><description>“On the plus side, it’s now easier to add a new contact, and I can decide whether to call somebody or start a chat by hovering over a contact. On the minus side, everything else.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;a href="http://ignorethecode.net/blog/2011/03/30/skype_5/"&gt;ignorethecode on the atrocity that is Skype 5&lt;/a&gt;. It really is a bloated, ugly, misbehaving piece of crap software. It’s even worse than the original MSN Messenger for Mac OS, and that’s quite an achievement. (Bloated chat UIs are a pet peeve of mine; I had an argument with my friend Sterd about it back before I had successfully converted him to a Mac user (:P) &lt;a href="http://nevyn.nu/files/pics/msn-bloat.jpg"&gt;using this picture comparing the space efficiency of an MSN for Windows chat window with that of Adium&lt;/a&gt;, and not even using one of the minimalistic Adium themes.)&lt;/em&gt;</description><link>http://overooped.com/post/4214403011</link><guid>http://overooped.com/post/4214403011</guid><pubDate>Wed, 30 Mar 2011 21:58:23 +0200</pubDate></item><item><title>iOS 4.3: imp_implementationWithBlock()</title><description>&lt;a href="http://www.friday.com/bbum/2011/03/17/ios-4-3-imp_implementationwithblock/"&gt;iOS 4.3: imp_implementationWithBlock()&lt;/a&gt;: &lt;p&gt;iOS 4.3 has a new objc api: adding method implementations using blocks. &lt;a href="https://github.com/nevyn/NSObject-AddMethod/blob/master/NSObject%2BAddMethod.h"&gt;I tried to do the same once&lt;/a&gt; using libffi but never had the patience to finish it. This is a prettier solution anyway.&lt;/p&gt;</description><link>http://overooped.com/post/4180970102</link><guid>http://overooped.com/post/4180970102</guid><pubDate>Tue, 29 Mar 2011 10:32:36 +0200</pubDate></item><item><title>"Eskil Steenberg (creator of Indie MMO “Love” - which is also a Voxel world engine of sorts) has told..."</title><description>“Eskil Steenberg (creator of Indie MMO “Love” - which is also a Voxel world engine of sorts) has told me that he doesn’t bother with small chunks – he just has a single Vertex Array that represents an entire quadrant of his spherical world, and to get around the massive waste of space he actually has to _defrag_ his graphics memory using his own memory management functions running on his GPU, effectively pushing all the active visible triangles together, and leaving a single large clear area of graphics memory for future triangles to be placed. This is the kind of batshit crazy engine programming I’ve come to expect from Eskil, and is not for the faint of heart.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;a href="http://forums.introversion.co.uk/defcon/introversion/viewtopic.php?p=97890#97890"&gt;Defcon - Minecraft + Physics = Awesome&lt;/a&gt; (how can you &lt;em&gt;not&lt;/em&gt; read an article with that title?)&lt;/em&gt;</description><link>http://overooped.com/post/3937504165</link><guid>http://overooped.com/post/3937504165</guid><pubDate>Fri, 18 Mar 2011 10:27:48 +0100</pubDate></item><item><title>UIKit: Hide the keyboard without a reference to the currently focused text field</title><description>&lt;p&gt;Googling for answers to UIKit or iOS/iPhone programming problems today resembles googling for answers to JavaScript problems. There is so much horribly, horribly broken code out there, being promoted as the way to do things. 

Ranting aside, today’s problem is writing your own view controller container, and noticing that focused UI elements don’t dismiss their keyboard in response to viewWillDisappear: or similar. If this was MacOS, or AppStore approval didn’t exist, you’d just do [self.view.window.firstResponder resignFirstResponder]. You can’t do that though, firstResponder is private on window, don’t ask me why. &lt;a href="http://stackoverflow.com/questions/1823317/how-do-i-legally-get-the-current-first-responder-on-the-screen-on-an-iphone/2887690#2887690"&gt;cdyson37 on StackOverflow&lt;/a&gt; however, found the public API &lt;code&gt;-[UIView(UITextField) endEditing:]&lt;/code&gt; hidden in a category in UITextField.h, that supposedly looks recursively through the receiver’s children for the first responder, and if found, resigns it. Perfect! A copy-pasteable code snippet for lazy googlers:

&lt;pre&gt;&lt;code&gt;[self.view endEditing:YES]&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://overooped.com/post/3898655445</link><guid>http://overooped.com/post/3898655445</guid><pubDate>Wed, 16 Mar 2011 15:14:21 +0100</pubDate><category>iphone</category><category>iphonedev</category><category>cocoa</category><category>uikit</category><category>programming</category></item></channel></rss>

