soeren says

.dat

December 2nd, 2007

Dear Software Developers,

please don’t ever assign .dat to your app. Given how many other apps there are with the same generic, non-descriptive file name extension, yours just doens’t and out enough that I’d possibly want it as the default.

In fact, don’t ever store your files as .dat at all. What kind of file isn’t “data”? Why don’t you just use .file while you’re at it? Or .content?

Going through FilExt’s list for applications that use the extension is cringe-worthy, but Microsoft has an answer that is far more to the point:

A wide range of applications create files with this file extension but with different file formats.

Don’t think .dat means “this file isn’t meant to be opened directly by users”, either. Microsoft’s uses suggest this; after all, you wouldn’t generally want to directly manipulate the innards Internet Explorer’s cache. But MPEG1 movies?

The very existence of extensions is a poor design choice already; let’s not make it even worse by using meaningless generic terms as “types”.

Posted in Chuckellania, Programming, Software

Share | No Comments

Is code bloat bad?

November 22nd, 2007

Ankur Kothari experimented with trying to optimize CTGradient to only cover his particular needs. As he discovered, CTGradient is a rather hefty class, weighing in at about 1300 lines of code.

He went on to try and eliminate all the pieces he won’t need. First down to 200 lines, then just “a little over 100″, “a lean 80″ and, finally, 30. Quite a change. Thus, his conclusion:

Please: When you use other people’s code, don’t put it in without a thought. Go through it, understand it, and optimize it for your specific need. For the better performance and reduced RAM usage, computers will thank you.

And yet, this wasn’t quite met with unanimous applause. To understand why the notion of cutting down a class like this can be misguided, let’s review why CTGradient was, at the time, created to begin with. It was first introduced in January ‘06, and the first three paragraphs lay out the rationale for the existence of this class:

While [Core Graphics] is a heck of a powerful library… It always seems to take an elaborate amount of code (as well as time, if your not yet acquainted with it) to do some of the simplest little things. [..] AppKit provides a pretty decent layer of abstraction, but I find that there are still a number of holes in its coverage. [..] One of those that AppKit doesn’t cover (that it really, really should [..]), are gradients.

So. CTGradient does not provide new functionality; rather, it exists expressly as a simple abstraction to existing functionality that Core Graphics already does expose. This is a crucial point: CTGradient is purely there to make life easier for developers. Similar classes exist for different purposes. A typical application easily ships with a dozen of third-party classes or entire dynamically linked frameworks, whether it’s custom user interface controls, a parser for a file format, or client functionality for a common network protocol. Why? To save the developer tons of work that someone else has already done.

And it is for that precise reason why Ankur’s postulation is so absurd: if developers were to spend the time he did cutting down classes like CTGradient to the extreme where they only have the code they need, they might as well just not use the class at all. That is, in this example, they could just have called CG* functions directly. That they didn’t do so doesn’t mean they screwed the user over; it means they focused on different aspects of their piece of software.

Does it ultimately cause bloat? Yes, in a sense. There is no denying that plenty of virtual memory could be saved through this process. It’s empirically measurable. But:

So is code bloat bad? Sure. Nobody benefits from that. However, there’s something even worse than abundance of code bloat: lack of pragmatism. I’d take an app that ships any day over one that is hung up in development hell due to developers who try too hard to make it perfect. I believe any self-respecting developer ought to normally do the same. ‘Normally’, because, there certainly are cases where these issues are more relevant – performance-critical apps in space shuttles, stability-critical ones in nuclear power plants, and so on. But none of that have anything to do with drawing a gradient.

It is even possible to compromise on the two: you could use a script (say, a Makefile) that generates a cut-down version of a class like CTGradient using given parameters – similarly to how ./configure does it for compiled code. For instance, a gradient class could have an –linear-only argument when you’re never going to work with other types of gradients, such as radial ones. But still, the question remains whether the benefit in resource usage outweighs the additional effort required to create, maintain, customize and use such a hypothetical script.

Now, nothing I’ve said above is any new revelation, and all of it could have been expressed in comments to Ankur’s post. Unfortunately, as Jonathan thoroughly discussed, Sir RixStep apparently preferred to turn the discussion into a venue for once again displaying his lacking people skills. It’s a shame, because I think Ankur’s post did make for an interesting read, regardless of whether I agree with is conclusion.

Posted in Chuckellania, Mac, Programming

Share | 4 Comments

Dalvik

November 14th, 2007

Hari asks:

Why Google is not following the open standards(Java is open source)?

Fabio answers:

The answer is pretty obvious: JME is lame and crippled. It is totally uncapable of bringing a level of user experience and quality like Objective C apps for the iPhones, for instance.

Nothing to add.

Posted in Chuckellania, Programming

Share | No Comments

The simpler the game, the higher the addictiveness

November 12th, 2007

There goes my productivity. (Via reddit.)

This was intended as a proof of concept on just how quickly you can develop a game from scratch using popular Javascript libraries (look ma, no Flash), but it also happens to be way too much fun.

Posted in Chuckellania, Games, Programming, Web

Share | No Comments

Leopard: Updating Dock icons of non-running apps

November 10th, 2007

Via Michael Tsai: Predictably, someone looked into how Leopard’s Dock manages to keep iCal’s icon up-to-date so that it always shows the current date – even when iCal itself is not running.

It turns out this is not an iCal-specific hack, but rather an undocumented (und thus potentially volatile; developers should not depend on it) new capability known as a DockExtra. An application simply specifies a path to a bundle in a key named DockExtra. The bundle, then, needs to implement certain functions to decide when to redraw the icon, and to actually handle the drawing. Finally, SystemUIServer loads the bundle and constantly keeps it in memory.

Perhaps Apple will one day make this a public API. CocoaDev wiki entry, anyone?

“DockExtras” were discussed all the way back in 2001, but those are probably Docklings instead, which haven’t been used much at all in half an eternity; pretty much ever since 10.1 introduced Menu Extras. (Does the current Dock even permit them any more?) Also of note: someone else figured all this out about a week earlier.

Posted in Chuckellania, Cocoa / Objective-C, Mac, Programming

Share | 1 Comment