Friday, November 20, 2009

iPhone Dev

Working on getting into iPhone dev. Started it a couple of months ago and got distracted. Now I am back. Working through, chapter by chapter, Dudney and Adamson. I like it so far.

It is a fairly neat development system (I have just been working with text editors up to now, so...) Essentially, you create a project, then define the interface headers, use interface builder to connect up GUI elements to code objects. Then write the code to do some action. It does not take much to get a functional app.

A little bit tricky to get the provisioning profiles and stuff. I had to get a private key from the old system (export from keychain), get the development certificate and install it, then each app, create an app id (or use a * for a suite of apps), then get provisioning profile, then load that, then compile it after telling the project what appid it is to use and provision profile. Then load it on to iPod. Soon I will be uploading an app to the store.

One key thing to be aware of is the memory management. Any item created with alloc or init must be released. There are also autorelease features, retain features.... Mastering this is important since doing it wrong will not be immediately apparent. Memory needs to be consumed because of the leaks before you will find out the problem. And even then, you need to know about it.

There are certificates that need to be installed into keychain along with a the private key. Development is for creating provisional, distribution is for adhoc and app store.

Sunday, November 15, 2009

E8 theory

Just came across http://arxiv.org/abs/0711.0770 a theory of everything in which all of the stuff is incorporated into a single connection over spacetime.

This looks very appealing to me. I think I will try to understand this in the context of Bohmian mechanics and my own work on differential geometry as part of quantum stuff. The following quote from the paper intrigues me greatly:

The Riemannian geometry of general relativity has been subsumed by principal bundle geometry — a significant mathematical unification. Devotees of geometry should not despair at this development, as principal bundle geometry is even more natural than Riemannian geometry. A principal bundle with connection can be described purely in terms of a mapping between tangent vector fields (diffeomorphisms) on a manifold, without the ab initio introduction of a metric.
I love Riemannian geometry, but...

See also http://deferentialgeometry.org/
http://en.wikipedia.org/wiki/Antony_Garrett_Lisi
http://www.ted.com/talks/view/id/371

Object.create

In order to create objects nicely in JavaScript, Crockford suggests:

if (typeof Object.create !== 'function') {
Object.create = function () { // create a method of the universal object
function F() {} //create an empty function
F.prototype = o; //load the function's prototype with the old object to inherit from
return new F(); //use that function to create a new object and return it.
};
}

This implements inheritance from an existing object when creating a new object.
Crockford says changing o later will change new object.

I also need to create a little javascript lab, a notebook to record code, and to look back on.

Wkipedia

So on Friday 13, 2009, I did a major rewrite of the Bohmian mechanics page on wikipedia. It has been needed for a long time and now it is there. Now others can go in and refine it as the base has been dealt with. It is exciting and something the Bohmian community has wanted for a long time.

I am now thinking about what else it needs for acceptance. The main thing is to say that it applies to all current physics.

To that end, I want to create an article or a page that delves into a full theory based on QFT and relativity. My collaborators have already done the hard work. I just need to put together all of their pieces, and in some of my own flair, and hopefully the result will be the ability to claim that the Bohmian point of view works for the Standard Model. Maybe that will give good support for tackling quantum gravity, once all the cards are laid out on the table. The most difficult problem to tackle is understanding what the physicists have been talking about, as it is so couched in the language of experiments, i.e. measuring operators instead of the evolution of the wavefunction (which is present).

It will be fun.

Thursday, November 12, 2009

More Crockford videos. I haven't laughed that good in a long time.

One bit that was amusing is the following:

return {
ok : false
};

This works well to return an object literal

return
{
ok: false
};
is a total failure. So go with the first form.

Why does it fail? Well, the language inserts semicolons and does not care about useless statements so it sees:
return ; \\returns undefined
{ \\naked block. useless since no scope, but who cares
ok: false \\label in a totally useless fashion. which is fine. It evaluates false even if it is useless
\\ no semi-colon? no problem, we have insertion
}; \\not a statement so no semi-colon needed. But empty statement okay so it evaluates ;
\\and does nothing.

So all in all, this is a classic case of trying to do the right thing screws you.

JavaScript is a language with lots of power, but it requires good discipline.

One key pattern is encapsulation using closures and functions as data. So

var example = (function () {
var constant = ['stuff', 'more'];
var state = 0;

return function (dig) {
state += 1;
if (constant[dig] !== undefined) {
return [constant[dig], state];
};
}) () );

example(0); //returns ['stuff', 1]
example(0); //returns ['stuff', 2]
example(1); //returns ['more', 3]

//end program

So in this one snippet we see how inner functions access outer functions either to save on initialization times (constants of the function) or to maintain state between calls. It can also be used to have generator functions that generate custom functions. Notice the outer parentheses in example--these are not needed by language, but human maintainers enjoy being told that this function is being evaluated, not assigned. It is the inner function (need not be a function) that is getting assigned as that is what is being returned.

Wednesday, November 11, 2009

Safari Library

I just signed up for the Safar Library online-8500 books plus videos for $40 a month.

I began watching Douglas Crockford's videos associated with his Good Parts of JavaScript. Fun stuff. I am really looking forward to going through all of his videos.

He said that in 2007 it was the most popular language anywhere. Amazing. It is a great language and a horrible language. But one can use it as a great language.

I am currently exploring the Flot library with jQuery. Awesome stuff.

Saturday, November 7, 2009

TextMate, flot

I have begun to learn TextMate. It is awesome. It allows the quick typing and expansion of snippets as well as more powerful command features. It has code folding and column editing. And a cool method for editing multiple lines from the end.

I am also getting into jQuery, its UI library, and flot--a graphical plotting program. My first task is designing a quick statistics lab. So far it is working very well. My first tests run not only on Firefox but IE as well without any tinkering! It works on Safari and even the iTouch seems to have some success (the UI isn't quite right, but that's a design issue).

Haven't done any videos yet except the one test. Maybe next week. Also I have begun working on the wiki page for Bohmian mechanics on Wikipedia. It is exciting and again TextMate is helping me out there too.