Stricter languages, like Java, make it dramatically harder to accomplish the same goals. This is intentional, because Java also allows sandboxing of untrusted code in the same code space (pretty much impossible in existing dynamic languages despite efforts).
But what do you do if there is a problem with the third-party code and you can’t change it? In Java, you may just be screwed. For example, the Apache River distributed computing SDK uses “throws java.rmi.RemoteException” as a hint about which server methods are allowed to be invoked from the client. But, oops, Android’s Dalvik VM omitted all of the java.rmi.* classes to save resources. So trying to load a class with that “throws” declaration causes a “NoClassDefFoundError”. Because there’s no way to inject a third-party class into the “java.*” packages space, and Android developers have not been willing to add this simple Exception to Dalvik, this effectively kills all reasonable hopes of using River on Android. The River folks even talked about extreme hacks of rewriting the classes on load, but that’s too impractical. The answer from Android fans in scenarios like this seems to be “Why do you want to use that library anyway?“
A dynamic language would have just created a stub for that exception if it didn’t exist. Is that better or worse?
The result is brilliant, but a little rough (ExtJS and EnvJS don’t play nice, for example). The documentation is currently insufficient, but just barely so. One or two examples of usage would be enough to reduce this to a half-hour learning curve.
I have no idea where the name comes from… Maybe it’s a pun in German or something? 🙂
Programmers often want to put behavior in programs that only happens for debug builds, like logging or other diagnostics.
A common convention in C is to surround your debug-only behavior with “#ifndef NDEBUG … #endif”. The double-negative is ugly, but it’s a widely used convention nonetheless.
Xcode doesn’t use this convention by default, so you need to add “-DNDEBUG” to your Release compiles to turn off the debugging behavior. To do this, Get Info on your project, go to the “Build” tab, select the “Release” target and edit the Preprocessor Macros line like in the following screenshot.
(Credit: Greg Parker)
A few times when I upgraded Skype on Windows, it went into a mode where the settings would not stick. I’d have to reset them (like preferring my headset over my speakers) each time I launched Skype. I’m not the only one who experienced this — apparently Skype has an intentional “memory-only” mode where it will not save settings to disk. I don’t know why upgrading triggered the misconfiguration, but here’s the workaround.
The fix is to change this registry setting from “1” to “0”:
FreeBSD (and thus Mac OS X) has a filesystem notification API called kqueues which allow you to autodetect changes in watched files/folders. Apple uses it behind the scenes for indexing (Spotlight). It’s really fast. If I modify a file in one window via “touch /tmp/foo.txt” then the watcher program prints a message in the other window before the touch command exits. I’m using the Obj-C UKKQueue wrapper to simplify access to the kqueue system call.
I’ve found a few cases where the watcher fails to trigger when I rapidly delete and recreate the file… I’m not sure if it’s a bug in the system or in my app (probably the latter, maybe I’m not processing the input fast enough).
[UPDATE: oh, I just learned that kqueue can only watch a file that exists. If I wanted to know when a file was created, I’d have to watch the parent directory and then start watching the file when/if it was created. So that explains my problem with recreates]
In OS X 10.5, Apple added a new FSEvents API which uses a daemon to do a system-wide kqueue for the whole filesystem and distributes the messages to listeners in user space. I expect this is probably to reduce the kernel load of a pile of apps each requesting notifications for the same files.
My current project is targetting 10.4, so I’m avoiding the 10.5-specific FSEvents API.