2008-07-30

AppJet databases now faster and more powerful.

Good morning, everyone. You might like to know that AppJet, the cloud-based JavaScript framework that nobody knows about, just released an update, making it more efficient for the CPU and easier on the coder, a win-win. There are new methods that make it easy to filter and paginate and data sets. See the AppJet change log for specifics.I have prepared an example to show the new features in action.

Suppose you have a collection, storage.threads and each object has a property, text, that you want to display. But it would be unreasonable to display every single thread at once, so some sort of pagination is in order. SQL has a handy LIMIT command, and now AppJet has an equivalent, skip() and limit().
//Pagination variables
var start = parseInt(request.params.start) || 0
var items = parseInt(request.params.items) || 10
The first step is to figure out where we're starting and how far to go, using request parameters found at the end of the URL. If not specified, we fall back to the front page (0) showing 10 items.
storage.threads
.sortBy('-timestamp') //sort first so we skip the right ones
.skip(start)
.limit(items)
.forEach(function(thread){
printp(thread.text)
})
Then we make the database query and print the output in one shot. In order for this to work, each thread has to have been given a timestamp property when it was created. The obvious thing to use is a Date object, which is really convenient because it easily casts itself to an integer when needed. So sortBy() sorts things from least to greatest, and since time always increases, it would sort in chronological order. All it takes to reverse this is prepending a minus sign to the argument. Now we simply skip anything before we want to start printing and limit the query to a certain number of items. It reads a lot like English. Finally, at the end we loop through the results of the query and print paragraph tags with the text inside.

You can see a more advanced version of this example running live on http://post.appjet.net/, with the source code available. Next time I'll show you how to generate the links for pagination.

Please Solve Comment Fragmentation

Friendfeed is a leap in communication. Using RSS and proprietary activity stream APIs, you can track what people are doing across the web instead of just on one site. Facebook has some inklings of this as well. Whoisi adds wiki functionality which is parallel to imaginary friends on Friendfeed, where you can follow an activity stream of someone who didn't sign up or import a certain stream. XMPP will make the stream real-time and less intensive on networks.

This is all well and good, but there is still a problem. Comments. For one, Friendfeed doesn't thread the comments, which makes it too hard to have a conversation. But even worse is the fragmentation. Other sites, such as Reddit, will maintain a single page of comments for any particular URL. But Friendfeed can create several, and there is no way to find them all. There could be the original import of the item (maybe a blog post or image on Flickr) from the content creator, followed by any number of others' links to that item from Google Reader, Twitter, Digg, and the rest. And when those actions appear on Friendfeed, they all have the potential to create yet another silo of comments. You may see something interesting and be completely oblivious to a huge discussion happening around it. An app built on top of Friendfeed, Noiseriver, is trying to fix this. But Friendfeed is just a microcosm of a data siloing problem that the entire web faces. We're seeing a huge movement for something called "data portability", but this seems to have nothing to do with comments and everything to do with profile information and friends lists.

This is important too, but not the same goal. Sure, it's great to meet up with your friends on a completely different site, but does nothing for helping you connect with complete strangers. The real key to connecting people digitally is unifying the conversation. The argument against this is wanting to talk exclusively with one's friends, but this is unfounded since the program could easily bubble friends' comments to the top and only display other comments upon request. So I'm asking for a solution to comment fragmentation. We need an open API for posting threaded comments across the web. Any site choosing to accept open comments should accept a POST request stating,

"I am commenting on this URL in reply to that comment, and here is the text or URL of my comment".

And then of course you could GET for the current set of comments. Now anyone or any app involved in the discussion around a URL will be on equal footing and have access to all that is being said about it, because the silo now has a series of tubes running through it. Perhaps we can't realistically expect arbitrary sites to handle this kind of load, so some kind of glue, such as Gnip, may need to get involved. But this is the solution, and it will kick ass when it is created and people start using it. There is so much that the internet makes possible, so there is no reason to believe that what we have now is as good as it gets.

2008-07-29

Empire Maintenance

I finally got around to refreshing the layouts of my various web properties, namely my web site and this blogger template. Let me tell you, both were in bad shape. The banner now reads "vortices" whereas before it was "Vezquex's Vortices". The branding change doesn't really make sense. The domain is vezquex.com, after all. But it was the best logo I have at the moment. It looks pretty sweet over the fantasy space background; don't you think? I lifted it from a Russian guy, but let's keep that between you and me ;). The menu has some new items and should be easier to navigate.

The image used to make the menu bar is now monochrome and transparent so that it can be an arbitrary color using a background color, plus it looks cool over an image. I took out the Friendfeed widget from my home page and moved to the blog's side bar. I adopted their technique of many favicons linking to profiles. I still want to better integrate this blog into the site, but I haven't decided exactly how to approach that.

I've also been doing a lot over on AppJet. The concept of throway apps is great. I wrote a two libraries, lib-subdomain and lib-style, just for making my other libraries look nicer. I've bundled some pretty useful things into lib-general. But I haven't forgotten about the apps. One I recently made is an anonymous (for now) message board with support for external images and mp3s. I'm actually trying to write a user account library, but there are some bugs in it that I haven't quite solved, so it's not finished. There is of course an existing library that does the same thing, but I don't like its execution. (My main gripe is that it sends you to a separate page to log in.) On the lighter side of things, I have rewritten the PHP Novebruary script in JavaScript on AppJet, with added support for Septogust, so mark your calendars. I'll reimplement the widget too.

2008-07-25

Comments weren't working. Turns out they were turned off. But no longer!

I somehow got the idea that to use the Disqus commenting system comments had to be turned off on Blogger. That makes sense, because surely Blogger comments should be disabled so that they are not competing with Disqus. Maybe the way Disqus or Blogger works changed at some point because the commenting feature has been missing for a quite a while. And yet, it was working just fine on my other blog, so I investigated. I went to the comments section of Blogger settings for both blogs and looked for any differences. Oh! Comments were turned off for new posts on the Vezquex Blog. I toggled this setting and then went back through the old posts to make sure each one allowed comments. It would have been easier if Blogger had a toggle box for comments on the Manage Posts page so that you could handle it all at once. But I don't post that much, so it didn't take too long.

2008-07-24

U.S. Politics: Will things really be different when the Democrats control Congress and the Presidency?

We've seen how corrupt Republican control can be--spending out of control, perpetual wars, holding prisoners without fair trial and condoning torture. Even life long Republican voters are losing faith in their party. They are tired of war and scared of recession.

The probability of an electoral Republican win is low, and gaining net seats in either house of Congress is also highly improbable. Whatever the reasons, the support just isn't there this year, and it could take over a decade for the Republican Party to rebuild.

So let's assume a triple crown for the Democratic Party in the 2008 election: control of the Presidency, House, and Senate. I wonder how good Democratic control will be. Many of the Democrats in Congress vote for bills unpopular with Democratic voters, such as FISA, including Obama in this case [ www.senate.gov]. One problem is that there is simply too much to do. There is the of fixing and possibly nullifying poor legislation from years past (the Patriot Act comes to mind) and also new projects such as universal health care, which I don't even think they'll get to. Congress trails public opinion, therefore health care will come well after most people are clamoring for it, which they aren't yet.

One thing is certain: stuff will get done. Fast. There will still be enough Republicans around to filibuster, but that's only in the Senate. Now, more legislation typically means more unnecessary spending, but in this case that is not true. It is tempting for Congress to pass bills that sound good but are out of budget, and it is tempting for the President to sign them into law. Hell, the bill may be terrible in principle and cost. It's going to take some impassioned legislators to convince the others that the money simply isn't there, but it is not impossible. This is a tough issue because money seemingly grows on trees, but there is a reasonable limit to debt that the U.S. Treasury has surpassed. You can ignore it, but it's still there, devaluing the currency and siphoning tax dollars to pay interest. The flip side of this problem is that if Congress and the President were to cut spending and raise taxes and just pay off debt for years, they would look like they weren't even trying to do anything.

The prospect of Democratic control this term is quite appealing. America's economy, world image, and constitutional rights will all benefit from it. But the hole has been dug pretty deep, so don't be surprised if you get less change than you hoped for.