Back late last week, I posted the same question to both the ExtJS forum and to Stack Overflow - basically an issue I was running into with layout of some components in IE 6. At the time I wondered if the Stack Overflow one would even get any attention at all - ExtJS is pretty obscure, the tag only having been used six times to date. You would imagine a question on specific forum would have a much better chance of being answered.
Three days later, the ExtJS Forum post has received no response at all where as there were two answers on Stack Overflow, one of which is reasonably helpful, and the other of which completely solved my problem. I guess it’s a testament to the power of offering people some sort of quantifiable ‘reputation’ points.
Will JavaScript replace Objective-C as the primary language of Cocoa?
Reading the announcement of SquirrelFish Extreme it crossed my mind that since Apple seems to be putting a lot of effort into JavaScript performance perhaps there’ s more to it than speeding up Safari. Maybe Apple want to make JavaScript fast enough that it could replace Objective-C in the the majority of desktop Cocoa applications.
I never used the ill fated Java version of Cocoa, but from the bit of exposure I’ve had, JavaScript seems like a much more suitable replacement for Objective-C than Java. In fact, I would say that JavaScript, being prototype based, is quite a bit more flexible than Objective-C (though whether that’s a good thing may be questionable). Presumably Java was originally chosen, despite its static typing, because of its popularity but these days is seems like JavaScript is getting more any more attention as a serious language. I suspect in a few years time, JavaScript will become the most common first programming language for engineers, much the way BASIC used to be, simply because it’s so widely deployed in the web browser platform.
Though Apple must be happy with the Objective-C ecosystem they’ve developed, no one else appears to be moving towards it as a language. When compared to C# as in .Net or the Java-ish platform Google is pushing for Android, Objective-C seems difficult to learn and quite low level, especially without garbage collection as on the iPhone. Fewer and fewer engineers even seem to learn C these days, which will no doubt make Objective-C appear more and more difficult to newcomers over time.
The obvious first objection to using JavaScript in the desktop application scenario would be performance, but with so much effort going into improving it, it seems like it won’t be long before it is at least on par with virtual machine languages like C# and Java. To add a bit more evidence to the pile, Apple is clearly somewhat taken with JavaScript if they’re talking about JavaScript frameworks like SproutCore (which I’m told is very Cocoa-like) at WWDC and there are already bindings available for Dashboard widget development.
Ruby and Python might also be viable options if Apple were to move away from Objective-C, but currently suffer the same performance difficulties, and don’t seem to be getting the same level of performance attention (at least from Apple). Time will no doubt tell, but thinking about it, I can’t see a language which would be more suitable as a replacement for Objective-C than JavaScript.
First page of users in StackOverflow
As of this evening, I’ve made it to the first page of users on StackOverflow (sorted by reputation scores). I’m fairly please with myself, considering I’ve been staying out of all the meta discussions and don’t really know much about C#/.Net (the most popular topics by far).
I suspect my moment of glory will be brief with StackOverflow opening to the whole wide world shortly, but I figured it was worth commemorating here (since there’s no badge for it).
I’ve been considering whether there’s some way I can easily cross post questions and answers I post to this blog, but haven’t come up with a good way to do it so far.
Returning from a java finally block
It had never even crossed my mind until today, but it turns out that a java finally clause is allowed to overwrite the return value. This example prints 0 rather than 1.
package com.kstruct;
public class Main {
public static void main(String[] args) {
System.out.println(test());
}
private static int test() {
try {
return 1;
} finally {
return 0;
}
}
}
That could get really confusing in a long / complex / poorly written function…
…and apparently things get worse and worse the more you look into them.
Annoyed by CSS’s lack of #define style constants, and looking for an excuse to try out with the Google App Engine, I started building with a simple app to provide a simple CSS constant expansion service a few weeks back. It’s now up and running at http://www.constantcss.com/ if anyone would like to try it out.
The service is only intended for use while tweaking your design. You’ve got to be logged in to the site to actually fetch the updated CSS file (to avoid allowing people to use the site to serve up their site’s CSS file), but it does provide a cute tweaking option by reading parameters out of the referrer URL, meaning you can tweak the CSS without changing the actual CSS source in the web page.
Here’s a very simple example of the constant syntax.
/* @cssconstants
@define NORMAL_SIZE 10pt
*/
p {
font-size: /*NORMAL_SIZE*/10pt/*NORMAL_SIZE*/;
}
It isn’t elegant, but is nice in that
- The values can be updated without ever losing the information about which constants occurred where, which makes the tweaking workflow a bit smoother.
- The file itself is still valid CSS, so you can serve it up with the constants still in there if you like.
- If I ever go away, you could pretty easily update it with just a text editor which can do simple regular expression replacements.
The source code is also available in a git repository at http://github.com/mattsheppard/constant-css/tree/master if anyone wants to run their own version or make improvements. This is my first time using Python and Git as well, so I imagine there are currently many things being done poorly, and any pointers are more than welcome.
I just put a python script up on google code which you can use to convert an allhomes.com.au page (like this one for all the property listings in Braddon). I’m using it with NetNewsWire’s script subscription feature, and it seems to have done exactly what I want for the last week or so.
http://code.google.com/p/allhomes-rss/
(I’m pretty new to python, so anyone who’d like to take the time to point out where I’m making life hard for myself in there is most welcome)
iPhone developer program international
Looks like the iPhone developer program has gone international - I’m in Australia and just got my approval. Looks like there are now 28 countries (or at least currencies) on the list. (Actually, now I think of it, lots of those countries are in the EU and using the Euro. Hmmmmm)
Time to start playing with that accelerometer…
Credit card expiration dates are inclusive
I tried to look this up a little while ago, but couldn’t find the info anywhere obvious. Anyway, since I recently got my new one, I can confirm that the expiration date on a credit card (or at least my MasterCard one) is inclusive (i.e. 03/08 means it expires at the end of march, not the beginning).
I’ve been spending quite a bit of my time lately learning my way around a big new code base. Being able to set random breakpoints and step through the code is a godsend, but quite often, it can be tricky to quickly narrow things down to the area you’re interested in. What I realised this afternoon is that my life would be much easier if I had a debugger combined with a free text search.
In the first instance, it would be enough to just search the source lines which are being executed (and maybe break whenever there’s a match). That would let me, for example, find exactly where that extra parameter is being added to my URL without having to step through everything or grep the source code for what turns out to be a very common string.
To take it a step further, it would be really handy if it searched values of variables along the way to catch the case where the parameter name was pulled out of a config file or database).
Of course, it would probably be very difficult to implement (at least in a compiled language) in a way that has reasonable performance, but even a very slow solution would work well from what I’m currently doing. Maybe the another way of looking at the problem is that I want to search through only the code which was actually executed during a particular invocation…
Anyway, it’s probably not something I’ll be heading off trying to implement (and I imagine at some point someone will tell me you can already do it in smalltalk), but it certainly would have been handy if it had been in eclipse today.
