Sunday, November 29, 2009

PHP Recursive Strings

I needed to construct a recursive string of regular expression patterns. Parts of a string may be built from another string which may also be built of other strings. If you're familiar, think of production rules in a context-free grammar. If you're not, then just take for granted this recursive string idea would be useful. I initially decided to build all my patterns into a single array, giving me a nice data collection to access them. I was also under the assumption that my recursive idea would work best with an array as the interpreter would have to account for all strings in the array at once. This would prevent order issues if one string relied on another but wasn't yet declared. Unfortunately, PHP simply doesn't seem to work as I had hoped.


Consider the following snippet of code:

[code lang="php"]<?php
$a = array(
0 => "test {$a[1]}",
1 => "blah {$a[2]}",
2 => "argh"
);
echo $a[0]."\n"; // outputs: test

$s2 = "argh";
$s1 = "blah {$s2}";
$s0 = "test {$s1}";

echo $s0."\n"; // outputs: test blah argh
?>[/code]

At first, we attempt to use an array to handle the string recursion, then we use string variables.We can see from the output that the array code simply doesn't work. It appears you can't access parts of the array from within itself. At the moment, it looks like I'm stuck avoiding arrays for this. If anyone out there knows a way around this, please let me know!

Sunday, July 12, 2009

Google Apps aren't ready for Chrome OS

Google recently announced their Google Chrome OS project that will see release some time in 2010. It certainly looks to be a promising idea, though I can't help but think that the project's success lies heavily on a very small window of implementation decisions. The slightest deviation from the "perfect" solution could make Chrome OS more a gimmick than anything. As the OS aims to be the most web-driven ever designed, it's clear Google will use their slew of online applications to support the OS. In their current state however, the use of Google Apps as a true replacement for desktop applications is laughable. The biggest flaw in the implementation of all Google's online applications is the necessity to sync the app before going offline. In their current state, if I were to go offline and maintain my current online experience, I would have to sync my Google reader feeds, my Gmail inbox, and my Google Docs files before going offline. How is Chrome OS going to be useful when it's applications are worthless during unexpected spurts of offline use?

You might assume that Google's offline technology, Google Gears, just isn't capable of seamless online/offline transitions, but a quick look through their developer tutorial proves otherwise.
In a "background sync", the application continuously synchronizes the data between the local data store and the server. This can be implemented by pinging the server every once in a while or better yet, letting the server push or stream data to the client (this is called Comet in the Ajax lingo).

The benefits of background synching are:
  • Data is ready at all times, whenever the user chooses to go offline, or is accidentally disconnected.
  • The performance is enhanced when using a slow Internet connection.
The downside is that the sync engine might consume resources or slow down the online experience with its background processing (if it's not using the WorkerPool). Using WorkerPool the cost of synching is minimized and no longer affects the user's experience.
This is exactly the type of synchronization feature that Google's apps need to make Chrome OS possible. Without it, Chrome OS will never succeed. Gears has been capable of background synchronization, yet each time Google adds offline capability to one of their apps they force you to manually sync your data before going offline. I've never understood this strategy and now it appears they must revise their offline strategy for the Chrome OS project. I'd imagine Google to think more ahead than this, but let's hope they catch on and we start seeing background sync rolled into their web apps as the Chrome OS launch nears.

Update (2009-12-23): It looks like Gmail has the most robust offline support of all the Google web apps now. Reader still forces you to manually sync, you can't create new documents in Docs if you're offline, and Calendar still only lets you look at your events without changing anything. This is promising though, as Gmail is now a suitable replacement for a desktop e-mail client. One step at a time.

Thursday, February 26, 2009

Microsoft wants its FAT back

Ars Technica reported on a recent lawsuit filed by Microsoft against the GPS maker, TomTom. What's interesting is the potential ground this lawsuit may cover, including Microsoft's FAT filesystem. FAT is well documented, runs on any version of Windows and almost universally on Linux and Apple operating systems. This universal OS support makes it an attractive candidate for mobile storage media such as digital camera memory cards, MP3 players, phones, GPS units, etc. Although Microsoft mostly disregarded FAT as a hard disk filesystem for it's desktop/server operating systems in favor of it's newer NTFS filesystem, FAT is still widely used today throughout the entire industry outside of Microsoft itself. A copyright lawsuit against TomTom for the use of FAT could create an enormous ripple in the computing industry that relies so heavily on it's use.

Though this has the potential to be a disaster, I can't help but to encourage Microsoft if it really plans to push this further. Alienating mobile device vendors that use FAT by forbidding the open use of the filesystem means a large majority of those vendors will pursue open royalty-free alternatives. FAT is antiquated and there are many other viable filesystems for the industry to adopt. This has the potential of becoming a very good technological push forward for the industry as a whole. There will be some pains for sure, but I can only encourage Microsoft in alienating itself from an industry that has become reliate on FAT and essentially forcing an upswing in filesystem adoption to more open platforms. If that's the case, then thank you Microsoft.