January 2012
2 posts
3 tags
Locked into choice
Yesterday you had many great ways to create and digitally distribute your content. First, you could make a website with gorgeous latest web-technologies which is perfectly accessible with every modern browser on all major computer platforms. Or create an ebook based on the open standard Epub, also supported by all major reading software and devices. Third option is to make a movie (encoded in a...
Jan 19th
1 note
4 tags
Fun with concurrency on a single core
I have a single-core chip on iPhone 4 and an app with OpenGL rendering controlled by touch events. This morning the app was rendering graphics on the main thread. 90% of CPU time was spent on graphics, 10% on gesture recognition and related computations. Overall CPU utilization was about 30%. These 30% were noticeable: touch events were processed with delays and frame rate was low and not very...
Jan 13th
December 2011
3 posts
2 tags
Block concatenation
This little function concatenates two blocks in a single one. Useful when you have a single async operation running while multiple callers wish to subscribe for its completion event with a single message like [self doSomethingWithBlock:^{ … }]. The first caller will start the operation, for all the others the block will be concatenated with the first...
Dec 29th
Managing default applications on a Mac
1. Download “Default Apps” Preference Pane: http://www.macupdate.com/app/mac/14618/rcdefaultapp 2. Select “URLs” 3. Select the URL schema. E.g. “github-mac”. 4. Change the app.
Dec 12th
3 tags
Gitbox is 1 year old: status report
★ Gitbox is on birthday sale: full version for only $9.99. In May, 2010 I started experimenting with a UI for staging and committing to Git repository because it’s not easy to “git rm” a bunch of files that are already moved to trash (tab does not help). Also, I was tired of typing “gs” (“git status”) all the time just to see that everything is the way I...
Dec 3rd
15 notes
November 2011
1 post
Monospaced font
Some people would love to use proportional fonts for the programming code, but blame languages and text editing software for not being ready for them yet. The problem is that most proportional fonts (e.g. Helvetica, Lucida Grande) make punctuation characters too narrow making many statements hard to read. Compare: Monospaced font: if ([link isKindOfClass:[NSURL class]]) Proportional font:...
Nov 11th
1 note
October 2011
1 post
3 tags
Obj-C snippet: jumping to background
When you need to do CPU-heavy work, there is a nice pattern using GCD: jump to a background queue to do the work, and then back to caller’s queue to report the results. Do not forget to retain the caller’s queue because it may be deallocated while doing background work. Although compiler inserts retains for the ObjC objects referenced within blocks, queues are declared as opaque C...
Oct 10th
7 notes
June 2011
2 posts
Ruby and Objective-C
Ruby is very similar to Objective-C because both have a lot of similarities with Smalltalk. However, Ruby is a messy language on many levels. Many consider it a mostly a feature, not a bug, but it indeed makes interoperability with Objective-C less nice. 1. Ruby has a messy syntax. It inherits several features from Perl, Bash, Python and C-like languages and mix them together without any clean...
Jun 8th
2 notes
MacRuby is irrelevant
Apple clearly puts a lot of effort into making LLVM infrastructure and Objective-C a powerful general-purpose toolkit for themselves. If they miss some feature, they are more likely to add it to LLVM and/or ObjC rather than spinning off additional separate projects. They already have WebKit and JS and that covers a lot of what they want to do. And they are bold enough and smart enough to improve...
Jun 8th
1 note
May 2011
1 post
3 tags
Objective-C @property attribute suggestion
I would love to have the following feature in Objective-C: @property(retain, auto) id something; Where “auto” attribute would mean: 1) automatic @synthesize (already present in modern Clang compiler) 2) “nonatomic” if not stated otherwise 3) automatic release (if “retain” or “copy” is used) and nullifying of instance variable on dealloc
May 9th
6 notes
March 2011
1 post
1 tag
Xcode 4: good parts and bad parts
Xcode 4 slowly replaces Xcode 3 for my projects. Benefits become more important than problems. So here is my list of things I like and dislike about Xcode 4: Like: 1. Tabs 2. “Open Quickly” with fuzzy search by filename (cmd+shift+O), like cmd+T in Textmate. 3. Jump bar 4. Smarter autocompletion Finally, the tabs and jump bar turned out to be the single reason to use Xcode 4...
Mar 24th
8 notes
February 2011
1 post
2 tags
On programming languages
When you develop some interesting software, you care to make architecture simple, boring and flexible as much as possible. When you think hard about user interaction or work around some weird system integration, the code should get out of the way . Whatever language you choose, you try to stick to some limited set of features and use them predictably and consistently. Ninja tricks are interesting...
Feb 15th
3 notes
January 2011
4 posts
Jan 28th
NFC and payments with a phone
Why are people so obsessed with the NFC buzzword? The only safe and understandable way to conduct the payment with a phone is with the protocol like this: 1. Shop sends a payment request to your bank (via shop’s bank or directly) 2. You bank pings your phone and waits for confirmation. 3. You take your phone out and confirm the payment. You can do this securely over Wi-Fi, 3G, EDGE,...
Jan 27th
1 note
3 tags
MacAppStore and external distribution
Gitbox started selling in November using old-school method: download a free version from gitboxapp.com, then upgrade to a paid version by buying a license. Today Gitbox is available on Mac App Store as well. What this means to you? If you have already purchased Gitbox, you don’t need to “connect” it to App Store. First, it is impossible to do for free: you’ll have to...
Jan 6th
1 note
1 tag
Adding custom views to NSCells
How do you add a view (spinner, text field, button etc.) into the cells of NSTableView or NSOutlineView? Simple: 1. Keep a reference to the view in your NSCell. 2. In drawInteriorWithFrame:inView: you should create the view if needed and add to the controlView if needed. controlView is provided as a second argument to this method. 3. Position the view according to the cellFrame (first...
Jan 5th
2 notes
November 2010
2 posts
1 tag
Gitbox 1.0 released
I’m happy to announce that Gitbox reached its first major milestone: a first commercial release. It is a great version control app for working with Git repositories. Instead of cutting down the powerful, but complicated concepts of Git, Gitbox embraces them with a truly elegant user interface. Many people start actually using branches in Git thanks to Gitbox. Download Gitbox 1.0 now. Use...
Nov 27th
2 notes
OOP and business
In a software business, the functionality is an asset, but code is a liability. The less code needs your attention, less costs and risks you have. OOP is all about making stuff work, packaging it into an object with as small interface as possible, and building other stuff around without going back and tinkering with that package. Note to Java people: it does _not_ mean the object should fit...
Nov 18th
3 notes
October 2010
6 posts
Splay tree
“All normal operations on a binary search tree are combined with one basic operation, called splaying. Splaying the tree for a certain element rearranges the tree so that the element is placed at the root of the tree. A top-down algorithm can combine the search and the tree reorganization into a single phase.” http://en.wikipedia.org/wiki/Splay_tree The splay tree modifies itself...
Oct 30th
3 notes
A copy-pastable code
Everyday as a software developer you have to invent some abstractions. Simply speaking, you have to decide where to put the new code. After you decide this, you write more code and repeat the process. Sometimes the earlier decisions need to be changed and you refactor the existing code. Now you decide where to put the old code. I really need a hint. The OOP folks teach us to model the real...
Oct 29th
5 notes
A history of concurrent software design
Early approaches to concurrency When machines were big and slow, there was no concurrency in software. Machines got faster and people figured out how to make multiple processes running together. Concurrent processes proved being extremely useful and the idea was brought further to the per-process threads. Concurrency was useful because it powered graphical interactive applications and networking...
Oct 28th
Two kinds of charts
There are two very different kinds of information visualizations. And I don’t have pies and bars in mind. The first kind is for presenting the knowledge. You have already discovered some interesting facts and now need to present them clearly to the reader. Your task is to design a most appropriate form for the data, that the knowledge will become obvious. (Of course, you should not be...
Oct 27th
Printed book idioms to be avoided on screen
1. Breaking an article into multiple pages. Page is a physical limitation of a paper medium. Sometimes the text does not fit and you have to drop the last paragraph on another page. On the screen you have plenty of vertical space and there is no excuse to cut the reader’s context. 2. A lot of iPad newspaper apps simulate multi-column layout. They shouldn’t. The purpose of a...
Oct 24th
3 notes
1 tag
Mac OS X Lion predictions
There are some predictions or wishlists floating in the tubes regarding an anticipated update to Mac OS X. Some of them are more probable, some less and some are just plain crazy. Let me give you my predictions and some commentary. 1. The next cat name is likely to be “Lion”. This is based entirely on a single picture from the invitation picture and also is the least interesting...
Oct 19th
2 notes
August 2010
1 post
2 tags
Don't mix concerns: objects and things
Don’t tie external resources lifetime to object lifetime (for instance, file descriptors). Never start any process in constructor/initializer. Have “start” and “stop” methods (or “open”/”close”) dedicated for managing the resource. Don’t mix data construction and performing a procedure. Whenever you have a method which takes 10...
Aug 26th
11 notes
June 2010
1 post
3 tags
Gitbox
Gitbox is a nice little interface for Git. I wrote it primarily for myself and my friends to optimize everyday operations. Go download the app from the website and come back here for details. Gitbox displays each repository in a little separate window. Each window has 3 parts: branches toolbar, the history and the stage. Toolbar makes branch operations a lot simpler. You always see which...
Jun 7th
6 notes
April 2010
4 posts
3 tags
Crash-Only Software →
“Crash-only programs crash safely and recover quickly. There is only one way to stop such software — by crashing it — and only one way to bring it up — by initiating recovery.” “It is impractical to build a system that is guaranteed to never crash, even in the case of carrier class phone switches or high end mainframe systems. Since crashes are unavoidable,...
Apr 14th
2 tags
Designing for iPad: Reality Check →
iA writes about over-realistic design of iPad apps. I guess, it’s only a beginning: a way to catch attention. As with Mac OS X, Apple and other developers will gradually remove unnecessary pieces as people get more familiar with the device.
Apr 12th
1 note
3 tags
Knight's Principles
Knight’s Principles — Never do any work that you can get someone else to do for you — Avoid responsibility — Postpone decisions — Managers don’t do any real work — Premature optimization leaves everyone unsatisfied — Try not to care — Just do it! — It’s not a good example if it doesn’t work — Steal everything you can from your parents — Cover your ass “Each object...
Apr 10th
2 tags
Is iPad an autonomous device?
When you buy one, the first thing you see is “Connect to iTunes” screen. You need some “big” computer to start using it. If I’d like to buy one to my grandma, who does not have and cannot use a modern desktop computer, I have no problem with initial setup using my macbook. The only way to back up your data is, again, to connect to iTunes. Most of the apps keep the...
Apr 4th
March 2010
4 posts
2 tags
Programming songs
Monzy — Kill dash nine Coder Girl IE is being mean to me Write in C Zed Show — Matz Can’t Patch (show text) I woke up this morning, to look around at the tubes. I saw neither was working, I got the Matz Can’t Patch blues Twitter’s down 37’s too. I got the fuckin’ Matz Can’t fuckin’ Patch fuckin’ motherfuckin’ blues ‘Cos Matz...
Mar 28th
4 tags
“I could hardly believe how beautiful and wonderful the idea of LISP was...”
– Alan Key, The Early History of Smalltalk (1969)
Mar 22nd
7 tags
Pitfalls of lack of encapsulation
Tony Albrecht, Technical Consultant at Sony, tells a story about memory performance and object-oriented programming style. If you read the story carefully, you will notice that the performance problem was actually solved by writing class-specific allocators (that keep each object of the same kind in a continuous array) + doing recursive algorithm in two passes. Tony knows very well what...
Mar 16th
1 note
5 tags
“[Computing] is just a fabulous place for that, because it’s a place where...”
– Alan Key, 1972 Rolling Stone article.
Mar 13th
3 notes
February 2010
3 posts
4 tags
“The only way to write complex software that won’t fall on its face is to...”
– The Art of Unix Programming
Feb 22nd
3 tags
“One important distinction is client vs. server. ‘Client’ translates as: being...”
– The Art of Unix Programming
Feb 22nd
2 notes
7 tags
Android vs. iPhone: the good, the bad and the ugly
In last two months I had an opportunity to build two versions of the same application: on iPhone and Android. Both applications are basically navigation/tableview-based browsers for existing French website. Absolutely nothing extraordinary about the whole thing, but it is interesting how similar features could be accomplished on competing platforms. The Good First of all, you don’t have...
Feb 3rd
2 notes
January 2010
5 posts
4 tags
Admin pages
The average web-based shop works like this: there’s a front and a back. The front is sexy, the back is not. One group of people goes to the front to buy stuff, other group goes to the back to manage that stuff. These groups of people intersect only when those who go to the back pretend they are buyers. But still, there’s a huge distinction. On the other hand, the real shop also has a...
Jan 30th
3 notes
7 tags
Idea: Web browser for work
I’m using Safari because it is fast, simple and not ugly. But it has several annoying issues: 1. It does not return allocated memory back to system (however, it recycles it internally and does not leak). I end up with Safari eating 1+ gigs and multiple windows with multiple tabs opened. And it is not easy to restart Safari due to a second issue: 2. It does not remember opened windows...
Jan 30th
2 notes
6 tags
Interfaces in dynamic object-oriented languages...
In the first part I suggested to use messages like to_my_interface or asMyInterface to ensure interface-compliance. This method just returns whatever object seems to be suitable for the interface, but does no actual checks. IDE like Xcode or Eclipse can do a static check for implemented methods and issue warning/error at compile time. Today I will show how to build the same feature in the dynamic...
Jan 8th
5 tags
"4 columns for soft news, 5 columns for hard news" →
Tages Anzeiger redesign suggestion.
Jan 1st
5 tags
Flatland →
Jan 1st
1 note
December 2009
2 posts
7 tags
What Colour are your bits? →
“Bits do not naturally have Colour. Colour, in this sense, is not part of the natural universe. Most importantly, you cannot look at bits and observe what Colour they are. I encountered an amusing example of bit Colour recently: one of my friends was talking about how he’d performed John Cage’s famous silent musical composition 4’33” for MP3. Okay, we said,...
Dec 29th
4 tags
“The original codename for Direct X was “the Manhattan Project,”...”
– Interview with Alex St John
Dec 17th
1 note
November 2009
4 posts
5 tags
Why you should avoid Out Of Memory checks →
“So in summary, OOM-safety is wrong: - Because it increases your code size by 30%-40% - You’re trying to be more catholic than the pope, since various systems services you build on and interface with aren’t OOM-safe anyway - You are trying to solve the wrong problem. Real OOM wil be signalled via SIGKILL, not malloc() returning NULL. - You are trying to solve the...
Nov 23rd
1 note
Nov 22nd
3 notes
6 tags
Start with algorithms
— I find OOP methodologically wrong. It starts with classes. It is as if mathematicians would start with axioms. You do not start with axioms - you start with proofs. Only when you have found a bunch of related proofs, can you come up with axioms. You end with axioms. The same thing is true in programming: you have to start with interesting algorithms. Only when you understand them well, can you...
Nov 15th
4 tags
Kaganov on security
Very good post (google translation) on airport security improvement and security strategies in general.
Nov 3rd
1 note
October 2009
15 posts
3 tags
object.or { default_value }
Little helper to deal with nils, empty strings and arrays. class ::Object def blank?; false end def or(default = nil) blank? ? (block_given? ? yield : default) : self end def and blank? ? nil : yield(self) end end class ::FalseClass def blank?; true end end class ::NilClass def blank?; true end end class ::Array def blank?; compact.empty? end end class ::String def...
Oct 29th
5 tags
Elastic tabstops suggestion by Nick Gravgaard... →
I would also suggest treating 2+ spaces as one or more tabs to avoid tab vs. spaces debates. See also my article on DSSV.
Oct 27th