Jun 2007

Abject-Oriented Programming

Tired of the object-oriented approach and looking for something new? Try Abject-Oriented Programming:

Abject-oriented programming is a set of practices for encouraging code reuse and making sure programmers are producing code that can be used in production for a long time. The number of lines of code in the application is a common measure of the importance of the application, and the number of lines a programmer can produce in a day, week, or month is a useful metric for project planning and resource allocation. Abject-oriented programming is one of the best ways to get the most lines of code in the shortest time.

abject: utterly hopeless, miserable, humiliating, or wretched: abject poverty.

See the comments too. Lots of clueful input that adds to the effect and lots of clueless input that shows what is wrong with the state of computer science today.
|

Apple, Intel, And Customized CPUs

images
We know that the CPU inside the Apple TV is a slightly custom version of a standard Intel CPU, but why stop there? Why doesn't Intel make all manner of customizations to its processors for Apple? Or for other companies for that matter?

It would work like this. Apple analyses its code and identifies a small number of operations that, if they were faster, would have a significant effect on the speed (or the apparent speed) of their computers. Intel implements the changes, Apple used the chips, and everyone is happy. Nobody is unhappy because their code does not rely on that particular operation as much as Apple's does and there are no downsides to the change.

Or it could get more competitive. Apple has Intel add extra instructions that improve performance for selected, important code. If the CPU does not implement those instructions, then the Apple code just does it using generic code. In this way the new machines are faster, of course, but importantly, are faster than equivalent Windows machines because their software does not know about the new instructions. They could be fully documented and still not give anything away.

This would also mean that Apple code could know if it were running on a genuine Apple machine. It would deliver slower performance on clones than on Apple hardware because the Apple hardware would run the special CPUs.

There is no reason that this has not been done already. Apple makes iPods and iPhones too and they would benefit greatly from such a performance/battery efficiency boost. TenSilica does a nice business adding special instructions to CPUs for exactly this purpose.
|

Aperture Plugin: Integrating Localized Data Part 2

cocoasmall
Now the strings in my code and my image are localized into French as well and English, I can move on to the strings in the interface. So far the French nib is just a copy of The English nib, created when I made the French nib localization. I used nibtool to extract the strings before translation, and I use nibtool again to put the translated strings back.

To do this I fire up Terminal, cd to the French.lproj folder and use the following command line:

nibtool -w new.nib -d file.strings Random_Wok.nib

This creates a new nib file with the English strings replaced by French ones. I use the Finder to replace the old nib with the new one and I am done. Now my resources look like this:
rwok344
But if I run the plug-in in French, some of the strings no longer fit:
rwok345
This is unfortunately typical for English. With its huge vocabulary, English can take up as little as 50% of the space of other languages. So my nice tight interface needs adjusting.

And there is a problem with subversion. After checking all of this in I find that my repository does not contain the French files and the NoImage.tiff file is in both the localized and the main folder:
rwok346
To fix this I do two subversion things: svn delete the extra TIFF and svn add the folder and its contents. Svnx could do the delete, but not the add. After a fair amount of trying things that did not consistently work, I eventually went to the command line, did a svn add of the French.lproj folder, then quit and relaunched Xcode, then finally did a commit. That worked and now everything is synchronized.

I fix the layout with IB, but don't neaten it up yet. That's because I want to run it past my translator again to make sure nothing weird has happened that I won't spot. Once the translator has OKed it, I'll peek the pixels and straighten everything.

And then there is the "Images Selected" binding. I have this set up with two display patterns, one for the number of images and one for the pluralization string. For French I have to put the second string in twice since both words gain an "s" in the plural:
rwok347
When I come to add German, this will break. The German strings are "Bild ausgewählt" and "Bilder ausgewählt". There is an "er" added in the plural, not an "s". Japanese is easy: no plurals exist in the language. A better solution is to put both singular and plural strings in the strings file and do all of this in code.

The other parts of this series can be found via the Cocoa page.
|

O'Reilly Podcast On Export Plug-Ins

podcast_tile_170x115
O'Reilly Digital Media has a 21 minute podcast with Richard Kerris (Apple), Micah Walter (Aperture Plugged In), and David Schloss (Aperture Users Professional Network) talking about Aperture plug-ins. You can also subscribe to the Inside Aperture podcast.
|

Mac OS 10.4.10 Adds Camera RAW Support

From the notes for the Mac OS X 10.4.10 update posted today (Intel and PPC):

-Adds RAW image decoding support for the following cameras: Panasonic DMC-LX1, Panasonic DMC-LX2, Leica M8, Leica D-LUX 2, Leica D-LUX 3, Fuji S5 Pro, Nikon D40x, and Canon EOS 1D Mk III.

|

Cocoaheads WWDC 2007 Audio Is Now Available For Download

Brian Christensen of Alien Orb Software has kindly volunteered to host the audio files from the WWDC Cocoaheads meeting that was held last week at the Apple Store in San Francisco. You can get the two MP3 files totaling 132MB from his Going Indie page.
|

Versions: A New Mac Subversion Client On The Way

versions
Leaves as artwork clearly represent the current frontier of web design. Now we have Versions, available as a beta that promises to make subversion easy to use on the Mac. That would be very nice since I use an assortment of tools right now and it is not a very satisfactory arrangement.

Linus argues that none of this is worth anything (the video is long but worth the time -- much clearer than reading the text of the talk). The comments are all over the map. That's a good sign that he is right. If the experience of users is so scattered that no-one can even agree what the problem is, then something is seriously wrong. What exists today is barely usable. It just doesn't feel that way because having anything is so much better than having nothing at all.
|

And The OMGTWTF Winner Is...

100043
A calculator. In fact all the entries to the OMGTWTF contest were calculators -- amazing badly designed, badly implemented, unnecessarily convoluted, and obscurely coded calculators. That was the whole point. Where else but in critical working code would you find such gems as the MakeNegative function?
makenegative
The twelve finalists are as follows:

OMGWTF Finalist #01: The Buggy 4-Function Calculator
OMGWTF Finalist #02: The FileSystemHashMapNotepadCalculator
OMGWTF Finalist #03: The estimator
OMGWTF Finalist #04: TerseCalc
OMGWTF Finalist #05: WTF Web Calc
OMGWTF Finalist #06: OMG!OCRCAL
OMGWTF Finalist #07: Rube Goldberg's Calculator
OMGWTF Finalist #08: Universal Calculator
OMGWTF Finalist #09: Terry's Calculator
OMGWTF Finalist #10: FerronCalc
OMGWTF Finalist #11: VICE, Virtual Integrated Circuit Engine
OMGWTF Finalist #12: ExtensibleCalc
|

Tags And More Tags

tagspage
Once I added tags to my articles following the release of RapidWeaver 3.6.1, I found that I had so many that I could not fit them into the sidebar in any sensible way. Another big problem was that any new article uploaded 780 pages because all the sidebars on all the pages and sub-pages changed. So I created a separate page for them that I update manually once in a while. It's a good place to scan for topics and find some of the more obscure items on the site.
|

Übermind Aperture to Picasa Web Albums Beta

aperturetopicasa
Übermind has released a beta of the Aperture to Picasa Web Albums export plug-in. They now have several Aperture plug-ins and are looking for ideas for more.
|

Aperture Plugin: Integrating Localized Data Part 1

cocoasmall
Now my translators have sent back localized versions of Localizable.strings, file.strings, and images that I sent to them, I can integrate them into my project. Here is how my project is organized right now:
rwok330
To localize the NoImage.tiff image, I select NoImage.tiff and get Info, then click on Make File Localizable:
rwok335
This changes the image into a group and shows the targets that it is associated with:
rwok336
The Resources have been rearranged like this:
rwok337
Clicking on the General tab shows the languages that the image is localized for:
rwok338
I'm going to add French, so I click Add Localization and select French. The French image created by Xcode is just a copy of the English image at this stage:
rwok339
To get my French image in, I change its name from PasDimage.tiff to NoImage.tiff so that the code will be able to access it with the same file name and replace the current image in the French.lprog folder via the Finder. Xcode has a handy contextual menu item called Reveal File In Finder to help with this.

To Localize the strings I do the same sequence, this time putting my English Localizable.strings into the English localization as well as the French Localizable.strings file into the French localization.

I localize the nib file too, creating the localization, but just leaving it as a duplicate of the English for now. I want to see how Random Wok works in French with what I have to far. Only a few things will be French at this stage: the progress message and the missing thumbnail image will show me that things are working correctly. But how to run in French?

I go to the International preference pane and move French to the top:
rwok340
Now when I run Aperture it will be French.

But when I do, I find that the NoImage image is not there. And when I run it in English it is not there either. The problem is this code:
rwok341
I get the TIFF file using a path that does not take into account the localization folders (English, French). So the initWithContentsOfFile method fails and returns nil. The fix is to use -pathForResource:ofType:inDirectory with a nil directory name:
rwok342
And now the image shows up correctly when I run in French or English:
rwok343
Next is fixing the interface strings.

The other parts of this series can be found via the Cocoa page.
|

Aperture: Add Watermarks To Contact Sheets

Aperture can add watermarks to images as they are exported, but what do you do if you want to watermark contact sheets? It would seem that the only way would be to export each image with a watermark and then reimport them and print them as contacts. There is a better way, but it needs a reasonable amount of set-up. It involves using Automator to add a watermark to the contact print PDFs created by Aperture.

I create a contact print with Aperture by saving as a PDF and then import into an empty transparent Photoshop document as a raster image background:
contactwater1
On top of that I add white Bagelturf watermarks by making one and then option-dragging to add more. It turns out that the technique of positioning the watermarks so that they match the images is just too much trouble, so instead I recommend that the watermarks just be scattered randomly or kept very small and used in a fine grid so that each image has at least one readable one. There is probably a Photoshop feature for doing this that I don't know about or doesn't exist in my copy of Photoshop LE.

I delete the background layer and create a full-page watermark document that is all transparent except for the watermarking scattered all over the image. I save it as a PNG to preserve the transparency and to keep the file size small.

Next I launch Automator and create a new workflow. First I drag PDF:Watermark PDF on, followed by Preview: Print Image. I set up the watermark action by adding the watermark file that I created previously with the Add.. button and adjusting the settings so that the watermark image is positioned correctly. This takes experimentation since the example image is not very helpful. I set up the Print Images action so that the orientation and printer selection is what I want. I have seen comments that this technique only works with the default printer, so you may find yourself wrestling with that.
contactwater2
And ignore the red text that says that the PDF files from the Watermark PDF action will not flow into the Image Files input to the Print Images action.

If you want to change the useless example document used in the action, replace the file called Bears.pdf in System > Library > Automator > Watermark PDF.action. Open the action with a control click and select Show Package Contents. It's in the Resources > English.lproj folder on a system that is using English language settings. If you want to get really hacky, you can examine the python script that does the watermarking that lives in the Resources folder.

Next I save the workflow as as a plug-in for a print workflow and call it Watermark3x4:
contactwater3
As long as the watermark image is correctly positioned I am done. To use this workflow from Aperture, I select my images and go to File > Print. I change the contact print settings to get it the way I want it (on one or many pages), but I don't press Print. I press Preview instead.
contactwater4
When Preview comes up and shows the first contact print page it has no watermarks.
contactwater5
To add the watermarking, I click the Print icon and then select the PDF button. I click on Watermark3x4 on the drop-down menu that appears and the pages print immediately. I click Cancel to get out of Preview.
contactwater6
The workflow I created lives in the Library > PDF Services folder in my home folder. To get rid of it I just drag it to the trash.
|

Photos and Audio from Cocoaheads WWDC 2007

546981881_c003f56543

Wil Shipley, Brent Simmons, Gus Mueller, and Daniel Jalkut (left to right) answer questions about "going indie" at Cocoaheads held at the Apple store in San Francisco to coincide with WWDC 2007. It was packed. There were at least 200 people there. The speakers were great. Photo credits go to lukhnos.

I recorded the audio for the entire event and hope to have someone clean it up for me next week. I'll then be able to post an MP3 or AAC file for download.

[Update: The audio is available here.]
|

Meet and Greet In San Francisco

I plan on being at the AUPN meeting tonight in San Francisco, meeting some of my readers and catching up with the realities of professional photography.

On Wednesday I plan on attending the Cocoaheads meeting at the Apple Store in San Francisco (7pm). The topic is Going Indie. With WWDC happening this week, there will be a greater than average concentration of Famous Names.
|

Wii Is Creaming The Competition

vgchartz
With a competitor like WII, it's no big surprise that Microsoft is talking about changing its game. Those numbers from VGChartz represent cumulative sales, so the gradients are the rate of sale. Urlocker has more background and more links that show this was all predicted years ahead.

In less than two months there will be more Wii consoles than XBox360 consoles. If you go to the site and play with the graph controls you can see that things look dismal for Sony and Microsoft in Japan. Wii is outselling PS3 five to one.
|

Video Overview of RapidWeaver 3.6 Features

rw360
Screencasts Online have a nice overview of the new features available in RapidWeaver 3.6.
|

There's Never Been An Advertising Medium Like The iPhone

iphone
If you have a regular Mac, you can filter out the ads, either by using Firefox with AdBlock, or by using Safari and running a proxy such as privoxy. But how about the iPhone? It's closed, at least for now, and so there will be no way to filter content. Annoying Flash ads may be impossible to banish if it runs Flash. Even when it is more open there may be no relief.

This, combined with the possibly huge number of users, and the personal nature of the product makes it very attractive to advertisers. So maybe AT&T is going to be able to tap advertising revenue from this product? Apple provides the hardware and the appeal, Google provides the ad content and specificity, and AT&T the airtime.

... special deals, ads, and offers ... on your phone.
|

Aperture at WWDC

532173685_ec866721be_o
The Aperture Users Professional Network is having a get-together on Tuesday at WWDC. Click on the image to RSVP. I might be there.
|

Add Additional EXIF Data To Aperture Images

By gluing together exiftool, Applescript, Perl, and Aperture Allan Hise and Brett Gross have created a solution to the problem of missing EXIF data in Aperture by adding it automatically as part of the import.

I have this problem myself: the Canon S3 does not put useful ISO data in a standard place and so I have no ISO data for my images. Other people want to import GPS data, lens data, and other information that sits uselessly in their images, unavailable to Aperture.

To add data to images already in Aperture he has this tool.
|

Three Predictions for WWDC 2007

macworldpredictions
From my ignorant position as an outsider, I have three predictions for the super secret features that will be unveiled at WWDC 2007. Unfortunately one of them has just been stolen before I could make it. Sun's Jonathon Schwartz announced today that ZFS will be the default file system in Leopard. This is very good news. ZFS provides enormous advantages in flexibility, manageability and reliability over current file systems.

I better get the other two out before they get leaked as well:

OS-Level support for Windows NT applications
We already know that Apple is shying away from virtualization. But why is that? Because it still requires copies of Windows and all the problems that that entails. Much better is to run the applications directly, like WINE does. The implementation would include sandboxing so that Apple can provide a completely secure environment for running Windows apps. Apple could have been working secretly on this for many years and polishing it to perfection. It would provide the best upgrade path for companies who don't want Vista (almost all of them) and draw many more people from the Windows world.

A New Kernel
Mach has its problems and has needed a lot of work to make it granular enough to provide the performance needed by Mac OS X. So my third prediction is that Mach is out and something else is in. Be has shown us that a correctly-written kernel can provide excellent media, and real-time performance, so why would Apple not be doing this? It won't be Linux. My guess is that it will either be home-grown or something few people have heard of.

I am hoping that I will do better than my MacWorld 2007 predictions -- all wrong.

[Update: All wrong again. But then we've not seen the whole of Leopard, so I still could be right]
|

A Guide To Objective-C for C++ Programmers

Pierre Chatelier has posted a PDF guide to Objective C for C++ programmers. It's very good and very complete. I recommend it for anyone who only knows straight C as well because it covers the lesser-know corners of the language that are easily forgotten.
|

Aperture Plugin: Instructions To Localizers

When I sent the materials to my localizers I included a lot of information and some detailed instructions. The idea was to preempt any questions, delays, and mistakes. I put all the localizable files into a folder and ZIPped it for sending. Included in that package were the localized string files from Aperture itself. In that way the translators could see how Apple had expressed the terminology and maintain consistency.

The first item in the instructions was a series of screen shots of the plug-in. Several were needed to show the basic interface plus the pop-up menus popped up. The screen shots give the strings context and make it possible for localizers to work with the plug-in even if they cannot run it.

Here are the instructions I provided:

Enclosures
Enclosed is a ZIP file with a 
Localizable.strings file that was created by the genstrings utility. It contains all the strings that are localized in the application code. Also included is a file.strings file that has all the strings from the nib (user interface) and a TIFF image.

There is a folder for each language enclosed that contains a copy of the strings file used by Aperture. You can use this as a reference to see how Apple has translated things like Version Name. This will help consistency. 


What To Do
You will need to use an editor that can handle UTF-16 encoding. TextWrangler can do this as can many others. Apple recommends this simple editor:

ftp://ftp.apple.com/developer/Tool_Chest/Localization_Tools/ADViewer_2.1.dmg

Edit the text in the strings files to make the second string the translation. For example if I were doing a British English translation:

/* NSMenuItem : (oid:278) */
"Period" = "
Period";

becomes:

/* NSMenuItem : (oid:278) */
"Period" = "
Full stop";

Do not alter the comments or the other strings in the files. Be aware of the semicolon at the end of each line.

The Localizable.strings file is a slightly different format with the comment and the first string telling you what the string is used for:

/* Continue renaming after failure */
"rename-error-continue" = "Continue";

This helps distinguish some subtle differences in meaning or tense that may not be conveyed by English.

The strings may include substitutions. These are identified by a leading %. For example:

"%@
のコピー %d";

The substitutions should be left alone and just the text translated. Notice that some strings have numbers prefixing the substituted arguments. The numbers define the order of the substitutions in the first string:

/* Message in alert dialog when something fails */
"%@ Error! %@ failed!" = "%2$@ blah blim, %1$@ bloo!";

The translated message above reverses the arguments, as may be needed in some languages.

You can enter characters directly into the second string and can use Unicode by prefixing with \U. For example \U0020 is a unicode space.

In addition translations are needed for:

"
No Image"
This appears in the table (as a graphic) when no thumbnail image is available for display. I will create a graphic for each language unless you want to do that. I have enclosed the graphic I currently use.

Please do translate "Random Wok". If you can!

One part of the interface has a plural that is used if more than one image is present: "3 images selected", but "1 image selected". Please provide both the singular and plural translations for this phrase. I handle the pluralizing in code, and depending on the language will have to change the way I do this.

What To Deliver
The files you deliver (Localizable.strings, file.strings, and a file containing the translation for No Image and the two forms of Images Selected) must be encoded
UTF-16. Please ZIP the files together so they don't get mangled by email systems.

For technical background information see Apple's documentation:
http://developer.apple.com/documentation/MacOSX/Conceptual/BPInternational/index.html

Specifically this page:
http://developer.apple.com/documentation/MacOSX/Conceptual/BPInternational/Articles/
NotesForLocalizers.html#//apple_ref/doc/uid/20000044


What Happens Next
I will take your strings files and put them into the project. For those that live in the nib, I duplicate the nib file and then will adjust the layout so that things fit. It is likely, English being such a terse language, that things will have to move somewhat. That is OK, but finding translations of similar size would be most helpful.

I will send you a beta of the plugin when it is ready so you can check that is still OK. Your comments on the beta as well as what I have done with your strings will be welcome.

There were actually some problems. I had mistakenly left a macro in my source files that contained strings that were nothing to do with my plug-in, so that was translated unnecessarily. Despite my efforts with the screen shots, not all of the meaning was clear and I had to answer some questions about some words. One of the ZIP files came back empty for unknown reasons. I also realized that the way I have implemented the pluralization of the number images selected -- providing a method to add the pluralising string "s" -- is unlikely to work in all languages. So I will need to change that.

The name itself, Random Wok turns out to be hard to translate. A Wok is literally a Chinese Pot in Japanese. So I opted for the more phonetic Randamu Wokku ランダム・ウオック. And the phrase No Image is seven characters that I am supposed to keep on one line inside a small button. So I had to request a different meaning for that.
|

iPhone: June 29th. Three Ads Now Playing

iphonead
Apple is now showing three short ads for the iPhone and announcing that it will be available June 29th. The pages with the ads are a little kooky, so here are direct links to Never Been An iPod, How To, and Calamari. I expect there to be lots more of these very effective nuggets of marketing.
|

The Success and Failure of The iPhone

iphone
Almost nobody has seen or used an iPhone, and so the press is having a very hard time covering it. What coverage there is comes from two forces camped on opposite sides of the only known geographical feature called One Percent Of The Mobile Market Hill. The Yes They Will camp says they will have 1% or more of the mobile market by the end of 2008 and so be Successful and the No They Won't camp says they will not and will have Failed. Roughly Drafted chimes in too.

I'm betting that they will. But I think the real surprise will be the number of people seen carrying an iPhone in countries in which it isn't sold and doesn't work.
|

Twenty Years of Multitouch

The Register talks to Bill Buxton (who has built several multitouch systems) about Microsoft's Surface:

In fact, according to Bill Buxton - ironically a Principal Researcher at Microsoft's own research centre - these kinds of multi-touch interfaces have been around for over twenty years. Perhaps the Surface Computing marketing guys at Microsoft should check out Bill's web site. Moreover, perhaps Microsoft and developers like Jeff Han at NYU, who are building these 'old-school' multi-touch interfaces out of cameras and projectors, should consider the fatal flaw in their 'innovations'. This being that all back-projection interfaces are enormous. Think about it - you've essentially got a small cinema in a box behind a screen. Forget mobility and portability. Is it even moveable?

I remember using The Wasp, a portable and very yellow synthesizer in the early 80s. The keyboard was touch-sensitive, not in the sensitive-to-velocity kind of way, but in the touch-a-picture-of-a-key-to-press-it kind of way. As the site says:

Its most distinguishing feature is the keyboard and its awful non-moving touch keys. That's right, the flat plastic keys are only sensitive to your touch and so they are difficult and unreliable to play.

Anything that uses a touch interface has this tactile/audio feedback problem. A touch-input display also has the problem of planarity: the display and the input are co-planar. There are very few interactive systems designed this way -- none that I can think of that are designed for more than infrequent, dedicated use. The bigger the device (and so at least on paper the more impressive the display) the worse the situation becomes. Go smaller and the interface becomes usable because the hands can be positioned independently of the surface. Go too small and the area becomes too small to be useful.

I am wondering if Apple actually designed the iPhone like this: starting by finding the most functional form factor, then getting the feel and weight right, then moving on to the display, functionality, and finally electronics.
|

Aperture: Use Undo/Redo To Compare A Set Of Adjustments

The undo/redo feature of Aperture can be used to quickly compare a set of different adjustments without creating new versions. I show it here using the crop tool, but it works with any of the adjustment tools.

Here is an image I selected and displayed in the viewer:
cropsundo1
I press C to bring up the crop tool and then make a crop, but I don't press A to end the crop yet:
cropsundo2
Now by making several alternate crops either with a new rectangle or by dragging the one that is already there:
cropsundo3
I get Aperture to remember this series of adjustments in its undo buffer.cropsundo4
Finally I press A to accept the last crop and show it:
cropsundo5
Now by pressing command Z to undo and shift command Z to redo I can go back and forth through the crops. This works best in full screen mode, and I can press F at any time to go into or out of full screen.
cropsundo6
When I find the one I like, I just stop and go do something else. The alternatives are forgotten automatically. If I don't like any of then, I press C again and adjust or replace the currently displayed crop.
|

My Apple Menu: Quick and Easy Mac News

myapplemenu
My Apple Menu is a simple site with a lot of timely Mac article links, many of which I don't see elsewhere. It is written by Heng-Cheong Leong in Singapore and has links to other news pages including Tomorrow, Reader, and Singapore.
|
The Bagelturf site welcomes Donations of any size