Monday, July 29, 2013

JavaScript syntax checking

I was working through the Crafty tutorial on the fourth part, "Adding a player-controlled avatar," when I get the blank screen below.



By now I know this means there's a typo in the code, specifically, components.js. I learn the PlayerCharacter component on the website does not have a comma, not like the Bush and Tree components:

Crafty.c('PlayerCharacter', {
  init: function() {
    this.requires('Actor, Fourway, Color')
      .fourway(4)
      .color('rgb(20, 75, 40)');
  }
});

So I put on in after the inner closing curly brace, }. Then the game runs fine.

I realized I'm up the creek, so to speak, if Chrome is this sensitive. There's a high chance I'm going to make this mistake, too.

I search around and find JSLint, JavaScript Lint, etc. I tested on JSLint and it gave so many goggledegook messages and not the one to catch the above problem. After checking stackoverflow, I come to the Google Closure Compiler. The interesting thing is it finds three errors related precisely to the commas--namely, the commas shouldn't be there!

After I remove the commas in Tree, Bush, and PlayerCharacter, GCC is happy. However, the GCC is designed for improving code performance by rewriting the code. What I would really like is for a tool to take an html file and follow the links, checking each file in turn for syntax and semantics.

But not today.

Tuesday, July 23, 2013

JavaScript of my summer

I won't say that I had dismissed JavaScript. I simply had no use for it. Yet need is a b----. I had been working on PHP development the first half of the summer and out of curiosity, looked into JQuery, the utility of which I could appreciate. It's connection to Ajax is especially interesting. Along came Crafty and I was sold. It was the answer to Android's complexity for time which I did not have and simplicity which I sought. But no, what put JavaScript over the top was Underscore. I was in NYC yesterday and we went to the MoMA. If those Picasso's, Braque's, and Matisse's weren't elegant and simple and profound then...what is? I'm not saying Underscore is a masterpiece. I still don't know enough about it. However, on the surface it looks like one of the most interesting tools I'm come across since Scala.

Wednesday, July 17, 2013

jQueryMobile first look

I was going down the path of full-blown Android app development, which was not appealing for a few reasons.

First, I need a tool quick.

Second, Android app development is full of so much complexity. It's overkill. Whatever happened to the sample days of J2ME?

Third, Android apps are only for, well, Android.

Finally, using an Android app assumes you have the app. I can't see that working for the lost-and-found application too well. I mean, L&F is more likely to be a one-off sort of thing, not something a user will return to time and again unless they lost something.

Thus, jQM caught my attention.

I don't yet know enough about jQueryMobile except that it appears to go further than jQuery adding UI components in a cross-platform manner. This has plenty of advantages. It's disadvantages, of course, are 1) the app needs the browser, 2) the app looks like a browser, and 3) getting access to the sensors, the camera, GPS, etc. is uncertain. I read online that jQM don't have documentation as much as examples. I wouldn't hold this against jQM for examples may be all one needs.

jQuery first thoughts

Thanks to this tutorial I was able to spin up fairly quickly on jQuery. So now that I have some idea what it is about, I can see why some programmers swear by it. As a design pattern, jQuery appears to do exactly what its name implies: "query" and update the DOM more efficiently in LOC than JavaScript alone. I think that's about the gist of it.

Going further, it's kind of like assembly language for the DOM. I say this because, as an outsider looking in, I don't find jQ the most readable language I've used. $ for the jQuery constructor? $("#divA") finds divA? What can I say? It works.


Saturday, July 13, 2013

Ajax -- a first look

Here is a technology I had heard much about for years, especially after it was first released in the late 90s. Having taken a closer look at it, I can see its promise but also it curse. It is now clear that popular travel website like Orbitz, Travelocity, etc. probably use some sort of Ajax while the server searches for booking information. This is good.

However, the 'A' stands for "asynchronous"  and from a programmer's perspective that does not spell relief but pain. Multi-threaded programming is by far the most difficult programming, fraught with all manner of hazards, and Ajax is apparently no different.

That aside, there's the complexity of set up / configuration. Then parsing the response. Then, deciding the basic question of when to call upon all of this complexity.

Users will wait, not forever, of course. However, personal experience suggests that only as a last resort, when all else fails, use asynchrony. Otherwise, avoid it. The system will be more stable and predictable.

Sunday, July 7, 2013

Android edvelopment and XML

The prevalence of XML in Android development is a mystery: strings.xml, styles.xml, AndroidManifest.xml, one XML file per activity. It all seems anachronistic, to say nothing of error-prone and unwieldy. Eclipse can automate this and perhaps it does. We'll have to see.

Thursday, July 4, 2013

Nexus 7

The device arrived on 21 June. It took me about a week to open it, which was just as since the cover arrived about that time.

My first impression is that the Nexus 7 is not an iPad mini. The 7 has a smaller screen and is not as thin. Even the rubber case is not as slick as the magnetic one that protect the mini.

My first goal was to boot it up. Android is rather colorful and I will admit, more so than iOS.

My second goal was to deploy an app, just plug and go, I had hoped. But not so fast on the Mac which did not recognize it. So I plugged the 7 into my Windows machine and the same thing.

Evidently, the 7 needs some special developer tricks (like tapping the screen 7 times) and drivers.

The latter took me on a world-wind tour that led to the Nexus Root Toolkit, uninstalling drivers, and installing drivers. I doubted it would work yet it did!

Furthermore, when I plugged the device into my Mac, that worked, too. The Mac needed not extra software so I can only assume the NRT must have been installed some drivers and reconfigured the 7, too.

Thus, I've successfully deployed two apps from Android/Eclipse to the 7.

In summary, from a hardware POV, the mini wins hands down. However, from a software development POV, being an iOS developer, I don't see how Apple can win this battle with Google.