05
May 10

JavaScriptTemplates (JST)

I started working with JavaScriptTemplates after finding that jtemplates really let me down on performance on a long template (it was taking about 2.5s to load, JST topped at 200ms).

Just to give you a flavor for how it works, I’ll outline how I used it. To start, I created a JSON data file – typically this would be fed by a web service, but for getting up and running, a file is easy.

userdata.json:
{ users : [
{ name: "John Doe", email: "
john.doe@nthread.com"},
{ name: "Jane Doe", email: "
jane.doe@nthread.com"}
] }

Then I created a really basic web page. The page had a div where the templated HTML would be placed:

<div id=’userlist’ ></div>

And imported the jQuery & JST scripts in the header:

<script src=”scripts/jquery.min.js” type=”text/javascript”></script>
<script src=”scripts/trimpath-template.js” type=”text/javascript”></script>

Next, I created the template, which needs to be placed in a textarea. All of the templating libraries I have seen use a textarea for this, probably because it is the only place on a web page where you can avoid the browser parsing the HTML into DOM elements (which leads to escaping):

<textarea id='userlist_template' style='display:none' >
 <ul>
 {for user in users}
 <li><a href='mailto:${user.email}' >${user.name}</a></li>
 {/for}
</ul>
</textarea>

Finally, a small piece of JST & jQuery is used to load the JSON file in process it through the template:

<script type="text/javascript" >
 $(document).ready(function() {
  var data = $.getJSON("users.json", null, showData);
 });
 function showData(data) {
     var userlistTemplate = TrimPath.parseDOMTemplate("userlist_template");
     $("#userlist").html(userlistTemplate.process(data));
 }
</script>

That’s really all there is to it. This prints out the fairly unexciting:

User List

It really is pretty cool though, try it out.


04
May 10

Django or Ruby on Rails?

I’ve been doing Java development for the better part of ten years now (the worse part was spent in .NET… no, just kidding, it was fine), and I’ve been thinking I definitely spend some time developing in Ruby or Django. So, my gut tells me that Django is coming in a little stronger than Ruby, and I like Django, but I thought I should probably research that a bit.

Documentation

Have to give the edge to Django on this one, the Django site is great – it shows how to do almost everything.  The Ruby site is not so bad, but it kind of seems like they moved on to trying to sell books or something.

Django+1

Functionality

  • DB Creation Yup, both offer db creation and migration.
  • OR Mapping This is pretty much the bread and butter of both framworks.
  • Easy HTML Page Development Pretty much a check mark for both here.
  • REST + JSON Web Services (AJAXy funcitonality) Again, in general, supported by both.  Documented much better in Django though.

I pretty much consider this a draw.

Usage

  • langpop.com does a pretty good job at weighing numbers from a bunch of spots, Ruby was beaten out everywhere except Craigslist jobs.  Seems somewhat relevant though.
  • Google Insight search with Django vs. Ruby on Rails.  I tried searching Ruby, but that was very popular in Uganda among other places, making me think that maybe actual rubies were being searched for too.  After the change, it looks like ruby dropped in popularity during 2007, but then I have concerns that maybe just the search term “Ruby on Rails” did.  Kind of hard to tell.

It’s pretty hard to find data on this, but I’m going to give the edge to Django.  Django+1.

So…

Pretty much as I started, I’m going with Django.  Didn’t find any data to sway me anyways.  I think both are showing promise, and really, I’ll just be spending all the time writing JavaScript anyways.


30
Apr 10

Joel on Software

While he doesn’t publish often, one of the blogs that has influenced me the most in my career both as a developer and as a manager of developers is the Joel on Software blog.  Some of my favorite reads are:

More recently, Joel, in addition to Jeff Atwood of Coding Horror started stackoverflow, a great site for asking tech questions and answering them if you’re into that.  I am to some degree, I’m this guy on there.


29
Apr 10

Day 2

Just getting into using Wordpress again – hello appearance editor.

Kind of dig the way that the logo turned out, even if it’s a little bit lame… hey, I’m a developer, not a graphics type.  The font is FFF Tusj which I found in the article “20 High Quality Free Fonts” on smashingmagazine.com.  If you don’t know about that site, you should definitely check it out.  Speaking of which, it’s going in the blog roll.  –>


27
Apr 10

Hello Relaunched World

I’m restarting my blog as an online journal of me learning things, and roughly speaking, I am going to be spending time on some code, math, building, design maybe.  I don’t know, I’m just going to spend some time every day and write about it just a bit.

Today, I finished setting up wordpress after moving my hosting from slicehost to linode.

Hello again world.