Code

June 24, 2008

Symbian Goes Open Source

Symbian is going open source. This is a pretty interesting development, but I think it may be too little, too late, and it doesn't imply any major changes in the Symbian platform.

The real problem with Symbian isn't the fact that it's closed, it's the fact that it's Symbian. It's a difficult platform to develop for, its UI concepts are dated and accelerating towards antiquated, the "access point" scheme for managing IP connectivity is appallingly difficult for users, etc. Perhaps going open source will provide a catalyst for some serious changes and revolutions in the platform, that would be great. We'll see. Increasingly, the features of the Symbian platform that made it compelling are becoming unnecessary... the hardware platforms for mobile phones are no longer the exceedingly resource-constrained, battery-sipping environments they once were, and that will only become more true.

2010 is a long way off... the iPhone 3G ships in 3 weeks, Android phones this year. Developers finally get their hands on Symbian innards one year after that? I can't see that being very interesting to new developers.

It could be a huge boon for existing Symbian developers though, who've wished for access to deeper APIs, or even just to understand what is going on down deeper in the idiosyncratic Symbian brain. But again, in a year or two... it doesn't help now.

Interesting times!


Technorati Tags:
, ,


June 18, 2008

Great Talk on Bigtable

http://sites.google.com/site/io/under-the-covers-of-the-google-app-engine-datastore



Technorati Tags:
,


January 18, 2008

Things I Learned About Python

Sockets

Turns out socket.socket() is not directly implemented by Modules/socketmodule.c. So you can't pass a socket.socket() into C and expect a PySocketSockObject*. You need to pass ._sock ... that's a PySocketSockObject*, i.e. the socket implemented in Modules/socketmodule.c.

Asyncore

Messages on unix domain datagram sockets trigger handle_connect() and then handle_read(). I just pass on the connect.

Embedding

Pyrex doesn't work as advertised. Simple direct embedding, however, works fine... but only if you build the shared python library (at least, that's the only consistent difference between working and non-working that I've noticed so far).

Extending

Writing a module in C is very easy.


Technorati Tags:
,


December 06, 2007

Python Methods and getattr()

So I don't know why this didn't occur to me before:

   class foo(object):
       def x(self):
           return 1

f = foo()
getattr(f, 'x')()

Sweet.

On Languages

I've arrived at some rough analogies for programming languages.

C is like driving a Formula One race car. Most people just shouldn't. But if you're really good, you can meld man and machine in ways that just can't be done any other way, and you can build a truly fast, lean, and powerful system. But all kinds of things can go wrong, and usually badly.

C++ is like driving a Formula One race car towing an elephant. You have all of the risks of C with a whole bunch of weight making all the advantages of C moot. There are exceptions, but very few and far between.

Java is like dispensing with the car altogether and just driving the elephant. It's big, slow, and has a mind of its own.

Python and Ruby are different... they don't fit the car analogy so well, but instead fit into art forms. They just work differently. So I see Python as more like a musical composition. It has structure, and some rules, but at the same time has a free-flowing creativity and can have real elegance.

Ruby is more like painting, very pure, each stroke combining with all the others to create a whole much greater than its parts, but lacking the rules and structure that Python has. Ruby lends itself to incredibly elegant solutions. Unfortunately it doesn't have the system or networking robustness of Python, so sometimes it's as practical as a career in painting (but other times, as in the case of Rails, it's just about as perfect as any language is likely to get).

Apologies if I stepped on your pet language. I've just been doing this a long time (almost 20 years) and have developed distinct opinions and impressions. I don't want to argue about it.


Technorati Tags:
, , ,


June 21, 2007

Ah, Language Wars...

...makes me pine for the heady days of emacs vs. vi.

Anyway, I've been tasked with trying to prove that development environment X is a better choice than development environment Y. Along the way, there will also be discussion about whether database system A is better than database system B, so forth, and so on. In the ensuing discussion, we will have to visit the topic of whether "XML databases" (whatever that means) and XSLT are good ideas.

In researching other people's opinions about XSLT, we came across some old blog posts here and here. The first makes the claim that XSLT is the spawn of Satan, with which I wholeheartedly agree. But more amusing to me are the comments, especially from XSLT proponents.

Why is it that XSLT proponents claim that one must "get the functional programming mindset" before one can get XSLT? I think this is a tool they use to postpone the inevitable. The inevitable being a realization that XSLT is actually just a PhD student's wet dream, and not a programming language. But it is used to deflect discussion until, presumably, the anti-XSLT party has come up to the intellectual level of the pro-XSLT party. Since so few programmers are prepared to discuss functional programming, the odds are that the real discussion is averted.

So I would like to say this: why would "getting the functional programming mindset" convince anyone that it's a good idea to write hundreds of lines of syntactically excruciating code to accomplish what one or two lines of Lisp or Haskell would accomplish?

The claim seems to be that in some parallel universe of which most programmers are unaware, this actually makes sense. I'm going to go out on a limb and say that no such universe exists. Could be just me.


Technorati Tags:
, ,


June 08, 2007

Ruby and Rails R-O-C-K

Check out my automatic breadcrumbs. This could be expanded on, no doubt, but this will work for any CRUD-based model and controller. This kind of dynamic programming is just sweetness. This code lives in the main layout.

I uploaded the code to Pastie: http://pastie.textmate.org/68999

June 05, 2007

Caching

This is a great model for caching in web apps (and elsewhere).

March 22, 2007

Greasemonkey 1, Xanga 0

I have conquered Xanga's oh-so-tricky ad header, muahahaha. Blocking the ad is trivial, but removing the header itself is another matter. I've long been annoyed at Firefox for displaying the empty space in which the ad should reside. Safari doesn't. But anyway... I'm Firefoxing more these days so I figured I better just fix it.

So enter Greasemonkey, a Firefox necessity which allows you to write javascript to alter other people's websites for your own enjoyment, sanity, etc. Greasemonkey does nothing on its own, it provides a facility for "user scripts" to run on a specific page or site.

So I looked for some Xanga-related user scripts and the available scripts do a fine job of hiding the <div> that should contain the header but they don't address killing the actual header, which it turns out is generated dynamically in javascript and given a random 8-character id. They don't want you to be able to do this, I see. Since the header is written out by javascript, hiding the <div> is not sufficient. You gotta remove the <div> by ID after it is filled.

So the right answer is to parse the page looking for the script that creates the header, snarf the ID, and make its parent send it to never-never land. I have the power! Anyway, here 'tis:

function xpath(query) {
    return document.evaluate(query, document, null,
             XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

}

function doedit() {
	var theDiv = xpath('//div[@style="height: 130px;"]').snapshotItem(0);

	theDiv.style.display = "none";	
	
	var divid = "";

	allscripts = document.getElementsByTagName("script")
	for (var i=0; i < allscripts.length; i++) {

		s = allscripts[i];
		if (s.innerHTML.length > 50) {

			continue;
		}
		if (s.innerHTML.match(/txtout/g)) {

			divids = s.innerHTML.match(/'[a-zA-Z0-9]*'/g);
			divid = divids[0].split("\'")[1];

		}
	}
	
	if(divid != "") {
		var adsbox = document.getElementById(divid);

		if (adsbox) {
		    adsbox.parentNode.removeChild(adsbox);
		}		
	}
}

doedit();

// Or use this if doedit() is getting called early... but the above works for me
// window.addEventListener('load', doedit, true);

Technorati Tags: , ,

October 10, 2006

Why Ruby Rocks

I love Ruby. Here's one of a thousand reasons why:

song.__send__ "#{msg}=", token

The value of msg is the name of an attribute, so this code sets that attribute (well, calls the method attribute= where attribute is the attribute name, where an attr_accessor or attr_writer exists) to the value of token.

That's equivalent to calling song.foo = token if msg has the value foo.

Technorati Tags: , ,

The Story of Stuff

Photoblog

Photography Site

Recent Images

  • www.flickr.com
    This is a Flickr badge showing public photos from jeremey. Make your own badge here.

Flickr

  • jeremey. Get yours at bighugelabs.com/flickr

Houston Photobloggers

Blog powered by TypePad