Friday, May 28, 2010

Firefox vs Chrome Performance: A language difference?

Like many folks, I've been pretty blown away by the speed of Chrome (especially with respect to running JavaScript intensive sites). Currently, I use both Firefox and Chrome (depending on what I'm doing), but primarily Firefox as there are still some addons I can't live without.

Though I am excited to see the Out Of Process (OOP) Electrolysis project (which is now in beta) and the upcoming J├ĄgerMonkey JavaScript engine, I've begun to wonder if some of the performance differences we're seeing are more deeply rooted. Now I do know there are things that are supposedly not possible with Chrome's extension support, and of course with greater functionality comes reduced performance. But I've lately been wondering if the differences are at the language level. Does the language each was written in greatly alter performance? Have a look at this graphic
Source: Ohloh

Just look at all that JavaScript! While some sources favor JavaScript as a "first-class language" (and maybe I'm misinterpreting their meaning here), I'm not convinced that makes sense for desktop applications. There are some advantages to having portions of Firefox be in a web language, it makes it easy for web developers to extend & theme. But I'm not sure it makes sense to use it as extensively as they appear to have done.

For example, it would seem that the addon manager (nsExtensionManager.js) and session storage (sessionStore.js) are both JavaScript. How do I know these are their names? I didn't look at the code, but apparently I was putting Firefox under a bit too much pressure and I got the message saying these scripts had stopped responding (not at the same time). (Though this does happen less often with my portable Firefox, so maybe I need to clear out the profile).

It will of course help when we have the content and the UI in separate processes, and maybe help some more when Firefox gets a faster JavaScript engine, but I wonder if you can ever get really good performance from a language like JavaScript. I'm not saying to write the thing in assembly, I'm just saying maybe it makes sense to write the lower level components in a lower level language. What do you think?

As two somewhat unrelated sidenotes: What do you think the impact on Firefox's future will be with the loss of their tech lead? And do you think Google will finance Mozilla now that they're in some competition with each other?

Friday, May 21, 2010

Syntax Highlighting in Blogger: Round 2

So I'm now able to use the popular SyntaxHighlighter that most blogs use. I don't know what was stopping me before: maybe I've gone up in intelligence or they've fixed some bug. There's excellent instructions here. I think I'm going to make the move to this, since it's easier to read, has more features, and is more standard that the Prettify script I was using before. And one additional nice feature is I don't have to manually set my style="overflow:auto;", instead I just do
<pre class="brush:xml; wrap-lines:false">
And there's no longer a need to do an onLoad in the body tag, and a Groovy brush!
I've gone back to old posts and switched the styles, let me know if I've missed any.

Edit: Actually I think maybe the reason was my own lack of attention. I think I forgot to add 'alexgorbatchev.com' to NoScript's whitelist, and that's the host the scripts are currently hosted on, and it magically started working for me because I was in Chrome instead of Firefox. Doh! ... Doh? Who knows for sure?

Edit: The instructions aren't really up to date anymore, as new brushes have been added. Here is an updated example (note this uses the default theme, but you can choose to use other themes):



This still goes inside the header area of the template, which means you'll still need to manually edit the HTML.

OK Maven, You Win

So, I've tried every combination of dependencySets, fileSets, and copyDependencies I could think of, nothing I did seems to work. All I wanted was to have a runnable jar with its dependencies in unexploded jars (something I've done before when making a jar by hand, although I used the default package in that case, not sure if that makes a difference). When I failed in this, I tried to have a runnable jar with its dependencies exploded into a lib directory. I failed in this as well. The only thing that seems to work is to have everything exploded into the same level. I tried this briefly with the shade plugin, but have mostly been trying with the assembly plugin. I give up, Maven. You win.
I've seen this mentioned fairly often on the web. If someone has a working example of a Groovy project compiled into a runnable uber-jar, I'd love to see it.