<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Invert Your Mind</title>
	<atom:link href="http://brian.pontarelli.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://brian.pontarelli.com</link>
	<description>Brian Pontarelli</description>
	<pubDate>Thu, 03 Dec 2009 16:57:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Hibernate/JPA with missing tables</title>
		<link>http://brian.pontarelli.com/2009/12/03/hibernatejpa-with-missing-tables/</link>
		<comments>http://brian.pontarelli.com/2009/12/03/hibernatejpa-with-missing-tables/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 16:56:33 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[Hibernate]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[jpa]]></category>

		<category><![CDATA[missing tables]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=297</guid>
		<description><![CDATA[For some of the Inversoft products I&#8217;ve been adding new tables for new features into our standard schema. The tricky part with updating the database is also giving customers all the update scripts that they need to run and instructions on how to run them correctly. 
I figured I&#8217;d see what happened if I added [...]]]></description>
			<content:encoded><![CDATA[<p>For some of the Inversoft products I&#8217;ve been adding new tables for new features into our standard schema. The tricky part with updating the database is also giving customers all the update scripts that they need to run and instructions on how to run them correctly. </p>
<p>I figured I&#8217;d see what happened if I added all the JPA Entity classes to the persistence.xml file and didn&#8217;t update the database. Since none of the existing JPA Entity classes was changed, the application appears to work fine without the tables in the database.</p>
<p>This is good news for me as it allows me to ship new versions of the application without any fear of breaking customers who don&#8217;t update their database. This is true only if that customer doesn&#8217;t use any of the new features that access the new tables.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/12/03/hibernatejpa-with-missing-tables/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fixing Java tools on Snow Leopard</title>
		<link>http://brian.pontarelli.com/2009/10/21/fixing-java-tools-on-snow-leopard/</link>
		<comments>http://brian.pontarelli.com/2009/10/21/fixing-java-tools-on-snow-leopard/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 15:28:27 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[OS X]]></category>

		<category><![CDATA[Testing]]></category>

		<category><![CDATA[jmap]]></category>

		<category><![CDATA[memory]]></category>

		<category><![CDATA[snow leopard]]></category>

		<category><![CDATA[tools]]></category>

		<category><![CDATA[visualvm]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=293</guid>
		<description><![CDATA[I was attempting to work with VisualVM and Tomcat over the past few days on Snow Leopard and it was constantly failing. I was getting errors like this:

    "attach: task_for_pid(59980) failed (5)"

I was also getting errors inside VisualVM and from the command like using jmap that went like this:

Attaching to process ID [...]]]></description>
			<content:encoded><![CDATA[<p>I was attempting to work with VisualVM and Tomcat over the past few days on Snow Leopard and it was constantly failing. I was getting errors like this:</p>
<pre>
    "attach: task_for_pid(59980) failed (5)"
</pre>
<p>I was also getting errors inside VisualVM and from the command like using jmap that went like this:</p>
<pre>
Attaching to process ID 61218, please wait...
sun.jvm.hotspot.debugger.NoSuchSymbolException: Could not find symbol "heapOopSize" in any of the known library names (-)
	at sun.jvm.hotspot.HotSpotTypeDataBase.lookupInProcess(HotSpotTypeDataBase.java:399)
	at sun.jvm.hotspot.HotSpotTypeDataBase.readVMIntConstants(HotSpotTypeDataBase.java:319)
	at sun.jvm.hotspot.HotSpotTypeDataBase.&lt;init>(HotSpotTypeDataBase.java:88)
	at sun.jvm.hotspot.MacOSXTypeDataBase.&lt;init>(MacOSXTypeDataBase.java:36)
	at sun.jvm.hotspot.bugspot.BugSpotAgent.setupVM(BugSpotAgent.java:578)
	at sun.jvm.hotspot.bugspot.BugSpotAgent.go(BugSpotAgent.java:499)
	at sun.jvm.hotspot.bugspot.BugSpotAgent.attach(BugSpotAgent.java:337)
	at sun.jvm.hotspot.tools.Tool.start(Tool.java:163)
	at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:77)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at sun.tools.jmap.JMap.runTool(JMap.java:179)
	at sun.tools.jmap.JMap.main(JMap.java:110)
Debugger attached successfully.
sun.jvm.hotspot.tools.HeapDumper requires a java VM process/core!
</pre>
<p>And I also got some other strange errors from jmap like this one:</p>
<pre>
61218: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
</pre>
<p>I opened an issue with the VisualVM team and they tested things out on Snow Leopard and said it all worked fine. I figured they were smokin&#8217; something and decided to try a Sun product and see if it worked. I fired up NetBeans and sure enough, VisualVM and jmap worked great. This indicated it was definitely a VM configuration issue. </p>
<p>Here&#8217;s the what you need to do to get your Java applications working with the VM tools on Snow Leopard. Add the following parameters to the java command and everything will start working fine:</p>
<pre>
java -Xverify:none -Xshare:off -Xcom.sun.management.jmxremote
</pre>
<p>The <strong>-Xverify:none</strong> is the setting that allows VisualVM and jmap to capture thread dumps. Without this setting, you&#8217;ll get strange errors like those above. The <strong>-Xshare:off</strong> gets VisualVM working without any startup errors or random failures. The last setting is really just for JConsole and other JMX tools.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/10/21/fixing-java-tools-on-snow-leopard/feed/</wfw:commentRss>
		</item>
		<item>
		<title>C++ references</title>
		<link>http://brian.pontarelli.com/2009/08/06/c-references/</link>
		<comments>http://brian.pontarelli.com/2009/08/06/c-references/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 19:29:04 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[C++]]></category>

		<category><![CDATA[references]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=291</guid>
		<description><![CDATA[Assigning reference return value to a variable
When assigning a reference return value to a variable, a copy is made. Here is an example:

class References {
private:
    std::string name;

public:
    References(const std::string&#038; name) : name(name) {
    };

    virtual ~References() {
    };

   [...]]]></description>
			<content:encoded><![CDATA[<h3>Assigning reference return value to a variable</h3>
<p>When assigning a reference return value to a variable, a copy is made. Here is an example:</p>
<pre>
class References {
private:
    std::string name;

public:
    References(const std::string&#038; name) : name(name) {
    };

    virtual ~References() {
    };

    const std::string&#038; getName() const {
        return name;
    };
};

References r("foo");
std::string n = r.getName();
</pre>
<p>This code makes a copy of the <code>name</code> member variable from the References class and puts the copy into the variable <code>n</code>.</p>
<h3>Assigning reference return value to a reference variable</h3>
<p>When assigning a reference return value to a reference variable, no copy is made. Here is an example:</p>
<pre>
class References {
private:
    std::string name;

public:
    References(const std::string&#038; name) : name(name) {
    };

    virtual ~References() {
    };

    const std::string&#038; getName() const {
        return name;
    };
};

References r("foo");
const std::string&#038; n = r.getName();
</pre>
<p>This code does not make a copy of the <code>name</code> member variable. Instead, the reference variable is now a reference directly to the member variable inside the class.</p>
<h3>Passing a reference return value to a method that takes a reference</h3>
<p>When you pass the return value from a method that returns a reference directly into a method that takes a reference, no copy is made. Here is an example:</p>
<pre>
class References {
private:
    std::string name;

public:
    References(const std::string&#038; name) : name(name) {
    };

    virtual ~References() {
    };

    const std::string&#038; getName() const {
        return name;
    };
};

void print(const std::string&#038; s) {
    ...;
}

References r("foo");
print(r.getName());
</pre>
<p>This passes the reference returned directly into the method as a reference. Therefore, no copy is made.</p>
<h3>Using a reference method in a comparison operator</h3>
<p>This is the same as the method invocation example above because all operators take references.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/08/06/c-references/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fixing macbook wake up problems</title>
		<link>http://brian.pontarelli.com/2009/03/24/fixing-macbook-wake-up-problems/</link>
		<comments>http://brian.pontarelli.com/2009/03/24/fixing-macbook-wake-up-problems/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 01:16:21 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[OS X]]></category>

		<category><![CDATA[sleep wake up mac macbook]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=277</guid>
		<description><![CDATA[One of the family Apple notebooks (a Macbook) was having some issues waking up from sleep periodically. It was also having issues when the lid was closed the fan would constantly spin as though the machine was overheating. I took the machine into the only Apple store I trust (the main tech there is pretty [...]]]></description>
			<content:encoded><![CDATA[<p>One of the family Apple notebooks (a Macbook) was having some issues waking up from sleep periodically. It was also having issues when the lid was closed the fan would constantly spin as though the machine was overheating. I took the machine into the only Apple store I trust (the main tech there is pretty solid, although he still doesn&#8217;t use Terminal). The fix was pretty simple:</p>
<ol>
<li>Open up Terminal (Google it if you&#8217;ve never done it)</li>
<li>Type in &#8216;cd /var/vm&#8217;</li>
<li>Type in &#8216;rm sleepimage&#8217;</li>
</ol>
<p>It looks like this:</p>
<pre>
$ cd /var/vm
$ rm sleepimage
</pre>
<p>This should fix any issues with sleeping and waking up. The root cause is that if you move the machine to fast, have any static electricity and shock the machine, or otherwise jostle it too much when it is going into sleep mode (just after you close the lid), the sleep image will become corrupt and you&#8217;ll start having issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/03/24/fixing-macbook-wake-up-problems/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Generic variable to the current type</title>
		<link>http://brian.pontarelli.com/2009/03/06/generic-variable-to-the-current-type/</link>
		<comments>http://brian.pontarelli.com/2009/03/06/generic-variable-to-the-current-type/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 19:42:51 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=275</guid>
		<description><![CDATA[I just noticed that I&#8217;ve been using the Builder pattern with method chaining a lot. Looks like this:

FooBuilder builder = new FooBuilder();
Foo foo = builder.add(...).divide(...).multiple(...).builder();

The issue that arises is that I want to store a bunch of methods in a base class that various builders can use. In order to do this correctly, I have [...]]]></description>
			<content:encoded><![CDATA[<p>I just noticed that I&#8217;ve been using the Builder pattern with method chaining a lot. Looks like this:</p>
<pre>
FooBuilder builder = new FooBuilder();
Foo foo = builder.add(...).divide(...).multiple(...).builder();
</pre>
<p>The issue that arises is that I want to store a bunch of methods in a base class that various builders can use. In order to do this correctly, I have to really hack up my classes with some strange generics and unchecked casts like this:</p>
<pre>
public class BaseBuilder&lt;T extends BaseBuilder> {
  public T add(...) {
    ...
    return (T) this;
  }
  public T divide(...) {
    ...
    return (T) this;
  }
  public T multiply(...) {
    ...
    return (T) this;
  }
}

public class FooBuilder extends BaseBuilder&lt;FooBuilder> {
  public Foo build() {
    ...
  }
}
</pre>
<p>This is really annoying. I think every class should have a generic type variable that references the current type and let the compiler figure it out. Just name the variable ME or something. It would make the code look like this instead:</p>
<pre>
public class BaseBuilder{
  public ME add(...) {
    ...
    return this;
  }
  public ME divide(...) {
    ...
    return this;
  }
  public ME multiply(...) {
    ...
    return this;
  }
}

public class FooBuilder extends BaseBuilder{
  public Foo build() {
    ...
  }
}
</pre>
<p>Now that&#8217;s much nicer looking.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/03/06/generic-variable-to-the-current-type/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Inferred typing</title>
		<link>http://brian.pontarelli.com/2009/03/06/inferred-typing/</link>
		<comments>http://brian.pontarelli.com/2009/03/06/inferred-typing/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 19:37:31 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[.Net]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=272</guid>
		<description><![CDATA[I know that .Net 4 is going to have some pretty cool features around dynamic typing and C++0x is also adding some auto typing features. I was thinking about all of this today and realized that what I really use most of the time is an inferred type. Essentially it would infer a new type [...]]]></description>
			<content:encoded><![CDATA[<p>I know that .Net 4 is going to have some pretty cool features around dynamic typing and C++0x is also adding some auto typing features. I was thinking about all of this today and realized that what I really use most of the time is an inferred type. Essentially it would infer a new type based on the method&#8217;s contents.</p>
<p>Let&#8217;s say we have this:</p>
<pre>
public void callSomeMethod(Object obj) {
  obj.methodCall();
}
</pre>
<p>In static languages this fails because Object doesn&#8217;t contain the method <strong>methodCall</strong>. However, what if we told the compiler to create a new interface based on the content of the method? This code would then look like this:</p>
<pre>
public void callSomeMethod(autotype obj) {
  obj.methodCall();
}
</pre>
<p>The autotype keyword would cause the compiler to actually create this code:</p>
<pre>
public interface MethodCallInterface {
  void methodCall();
}

public void callSomeMethod(MethodCallInterface obj) {
  obj.methodCall();
}
</pre>
<p>This would now compile. Next, a caller to this method could pass in any object whose type the compiler could add this interface to. If you called it like this:</p>
<pre>
public class MyClass {
  public void methodCall() {
    System.out.println("Here I am");
  }
}

// Some other code somewhere
MyClass mc = new MyClass();
callSomeMethod(mc);
</pre>
<p>The compiler could take the interface it created for this method call and then see if the type passed in could implement that interface. If MyClass has already been compiled, it could do one of two things:</p>
<ul>
<li>If MyClass is accesible as part of the current compilation unit, it could update the compiled Class to implement the interface</li>
<li>If it isn&#8217;t part of the current compilation unit and isn&#8217;t final, it could create a proxy for the call that implements the interface and delegates the call</li>
</ul>
<p>Not sure yet how #2 really works or if it even makes sense to do it that way, but it seems to be the only way to make it work if the Class is in a JAR or DLL or something like that. </p>
<p>The only issue would be reflection. How could you reflection on the method and then pass an Object to it so that it would not completely blow chunks at runtime? Perhaps the reflective method invocation could determine if the object being passed could be proxied to the dynamic interface and then create a proxy on the fly.</p>
<p>Anyways, just pondering type systems in general today&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/03/06/inferred-typing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>C++ sorting with the STL</title>
		<link>http://brian.pontarelli.com/2009/02/16/c-sorting-with-the-stl/</link>
		<comments>http://brian.pontarelli.com/2009/02/16/c-sorting-with-the-stl/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 20:29:14 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=269</guid>
		<description><![CDATA[Since I&#8217;m doing a lot of C++ these days and working a lot with the STL, I want to jot down some things I&#8217;ve had to painfully recall about sorting:

The std::sort function really only works with vector
If you want to sort a set of pointers, you&#8217;ll need to create a comparator function or object and [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m doing a lot of C++ these days and working a lot with the STL, I want to jot down some things I&#8217;ve had to painfully recall about sorting:</p>
<ol>
<li>The std::sort function really only works with vector</li>
<li>If you want to sort a set of pointers, you&#8217;ll need to create a comparator function or object and use it as a type parameter (uglier than hell)</li>
<li>If you want to sort a list, you MUST call the sort method on the list</li>
</ol>
<p>#2 looks like this and really sucks to look at:</p>
<pre>
set&lt;string*,StringPointerComparator> myset;
</pre>
<p>And if you want to pass that thing around, you have to either pass it like that (nasty) or typedef it. Since I hate all typedefs, macrodefs, etc, I generally pass that nasty full type around.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/02/16/c-sorting-with-the-stl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android review and iPhone comparison</title>
		<link>http://brian.pontarelli.com/2009/01/23/android-review-and-iphone-comparison/</link>
		<comments>http://brian.pontarelli.com/2009/01/23/android-review-and-iphone-comparison/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 19:18:16 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[Google]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[OS X]]></category>

		<category><![CDATA[Tech]]></category>

		<category><![CDATA[android]]></category>

		<category><![CDATA[apple]]></category>

		<category><![CDATA[gphone]]></category>

		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=259</guid>
		<description><![CDATA[Here&#8217;s a quick run-down and comparison between the G1 vs. iPhone and Andriod vs. OS X mobile. This is based on side-by-side evaluation with both phones.  
The phones
Keyboard
The winner: G1
The G1&#8217;s keyboard is awesome. I like it so much better than the iPhones mainly because I can see the whole screen while typing, but [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick run-down and comparison between the G1 vs. iPhone and Andriod vs. OS X mobile. This is based on side-by-side evaluation with both phones.  </p>
<h2>The phones</h2>
<h3>Keyboard</h3>
<p>The winner: <b style="color: green">G1</b></p>
<p>The G1&#8217;s keyboard is awesome. I like it so much better than the iPhones mainly because I can see the whole screen while typing, but also because it has numbers and I don&#8217;t have to hit something to switch between numbers and letters. I&#8217;m a keyboard freak, so hands down the G1 wins.</p>
<h3>Screen</h3>
<p>The winner: <b style="color: blue">iPhone</b></p>
<p>I think this is close to a tie, but the iPhone screen is bigger. The resolution is the same for both phones, which means that the G1 can display as much information as the iPhone, but it is smaller.</p>
<h3>Battery</h3>
<p>The winner: <b style="color: blue">iPhone</b></p>
<p>The iPhone&#8217;s battery is 2-3 times better than the G1&#8217;s. I&#8217;ve heard word of T-Mobile shipping out batteries that add 30% more life, but even still, I play around with my G1 very little and it still needs to be charged daily. My iPhone needs charging every 2-3 days with the same use.</p>
<h3>Form factor/Design</h3>
<p>The winner: <b style="color: blue">iPhone</b></p>
<p>This isn&#8217;t much of a battle. The iPhone is sleek, light and really nice to look at. The G1 is thicker, heavier and an eye-sore comparatively. However, I can understand the extra size given the full keyboard. One thing the G1 does nicely is it figured out the exact size required for anyone to hold it in one hand and use any feature of the phone. This is the only thing nice about the G1&#8217;s size and shape.</p>
<h3>Buttons</h3>
<p>The winner: <b style="color: green">G1</b></p>
<p>I like the buttons and track ball with the G1. The iPhone is sometimes a bit cumbersome to use given that everything is on the screen. Sometimes it is nice to just hit a button.</p>
<h3>Accelerometer</h3>
<p>The winner: <b style="color: blue">iPhone</b></p>
<p>The iPhone has a really good accelerometer that seems to be level and responsive. The G1&#8217;s is a little rough around the edges and you can&#8217;t calibrate it or tweak it at all.</p>
<h2>The operating systems and software</h2>
<h3>Structure</h3>
<p>The winner: <b style="color: green">Android</b></p>
<p>Android has a lot of advanced features that are pretty nice overall. Each application has a menu, which is great for adding loads of functionality. There are keyboard shortcuts in applications which makes using features fast. Android has intents which are nice. It also allows applications to leverage other applications and common libraries. By far, Android wins when it comes to a modern platform.</p>
<p>At the same time though, Android has many bugs and issues that also make it difficult to actually use.</p>
<h3>Homepage/Application Chooser</h3>
<p>The winner: <b style="color: red">Tie</b></p>
<p>The iPhone home page doesn&#8217;t have the cool backgrounds or the lame analog clock or the drag and drop application display, but it is simple, orderable (you can move apps around), and looks really nice. Androids has a cool homepage that allows ordering and an alphabetized app chooser. So, they are different, but equally as usable and cool.</p>
<p>Androids icons definitely have that Linux look, which I grew tired of a decade ago while iPhone&#8217;s icons are sleek and nice and I haven&#8217;t gotten tired of yet (only 1 year as a Mac user). It seems like Apple is more in tune with style and each OS release keeps things fresh. We&#8217;ll see how 10.6 goes. Linux on the other hand just plain sucks the life out of you.</p>
<h3>Voicemail</h3>
<p>The winner: <b style="color: blue">OS X</b></p>
<p>T-Mobile and Android&#8217;s voicemail integration is horrible. It is exactly the same as every other phone for T-Mobile because you have to dial into voicemail and manage it via T-Mobile&#8217;s phone system. There is an 3rd party application that adds visual voicemail to Android phones, but it is in beta and it is a hack that appears to actually dial up your voicemail and record the voicemails to an MP3. I&#8217;m not positive on that, but this is what it seems like. Regardless of how this application works, it is a 3rd party application and T-Mobile and Android should really be offering a tightly integrated feature of the phone.</p>
<p>The iPhone completely integrates with AT&#038;T&#8217;s voicemail such that you can view all your voicemails on the phone, listen to them on the phone, and even setup and switch your voicemail greeting on the phone.</p>
<h3>Calendar</h3>
<p>The winner: <b style="color: green">Android</b></p>
<p>The Android Google calendar integration is great. However, it doesn&#8217;t support multiple calendars very well (you can only view calendars in the associated GMail account and not other GMail accounts or an Exchange calendar) and that&#8217;s a real pain point for most. Since I use a single calendar for everything, I don&#8217;t mind too much. On the other hand, if you have a Mac and only use Calendar.app, integration with the iPhone is great. This combined with Mobile Me would be ideal for real-time updates and syncing. For now though, Android wins in this department.</p>
<p>I&#8217;d imagine that Google will soon offer syncing with the iPhone as it does with the BlackBerry. If not, NuevaSync will work once it is finished and out of Beta.</p>
<p>Likewise, I would put money that Android will start supporting multiple calendars shortly.</p>
<h3>Maps</h3>
<p>The winner: <b style="color: blue">OS X</b></p>
<p>Multi-touch, double-click and good integration/features wins this battle. Since you are already touching the screen to move around, multi-touch is nice. The G1&#8217;s map interface is nice and it does allow single handed use, but iPhone&#8217;s bigger screen and multi-touch prevail in this category.</p>
<h3>Email</h3>
<p>The winner: <b style="color: blue">OS X</b></p>
<p>First, the GMail application really should be combined with the Email application. The fact that they are separate is really painful and annoying. Email should just be email like the iPhone does. Second, Android&#8217;s email application is one of the worst applications ever written. Here are a few of the pain points:</p>
<ul>
<li>Can&#8217;t view first few lines of emails in the inbox view</li>
<li>The folder and email view are combined making for a very cluttered interface</li>
<li>Email fails regularly even when connected to a WiFi</li>
<li>Deleting emails does nothing for GMail accounts via IMAP.</li>
<li>Can&#8217;t setup what happens on delete for IMAP accounts. For example, with GMail IMAP it should move the message to [Gmail]/Trash</li>
</ul>
<p>The worst thing is probably that the Email application doesn&#8217;t instantly work with GMail IMAP accounts. This should just work considering that the entire platform and stock applications are written by Google. I mean come on guys, take a cue from Apple and just make stuff work, especially with your own systems. Plus, Email constantly crashes and has so many issues that it is rendered useless in most situations.</p>
<p>The iPhone email isn&#8217;t perfect, but it handles all of these things much better and also makes setting up GMail accounts a snap.</p>
<h3>Document Viewer</h3>
<p>The winner: <b style="color: blue">OS X</b></p>
<p>The iPhone has a built in PDF viewer that works really well. It also displays Word documents and other formats decently well. In gets a little bit freaked out by complex Word documents in the new DOCX format, but otherwise it is great. It also allows you to zoom in and out using multi-touch and double-click.</p>
<p>The G1 looks like it uses Google Docs online viewer or some type of hacky internal viewer. Not really sure about which one, but it does a very poor job of displaying documents and files, including PDF (I mean really? PDF? It should perfectly display all PDFs). Images are also displayed poorly and some don&#8217;t render correctly, such as JPGs. Plus, no zoom (ouch!).</p>
<h3>Apps</h3>
<p>The winner: <b style="color: blue">OS X</b></p>
<p>This is based purely on the most fundamental of all applications, solitaire. There are a number of choices on both phones, but overall the solitaire on the iPhone is much nicely in terms of design, features, etc.</p>
<h3>App stores</h3>
<p>The winner: <b style="color: blue">OS X</b></p>
<p>Apple&#8217;s store has a much cleaner interface and includes pictures, better details, better commenting system and more interactivity. The Android market looks pretty shabby comparatively. </p>
<h3>Accelerometer/Orientation</h3>
<p>The winner: <b style="color: blue">OS X</b></p>
<p>The iPhone uses the accelerometer all over the place and it does it really well. Orientation of the phone is really helpful in most applications as it makes the phone easy to use. </p>
<p>Android&#8217;s support for orientation and the G1&#8217;s accelerometer is just garbage. Even the browser requires 3-4 clicks before you can change the orientation without opening the keyboard. I mean come on guys, just use the tools you have and make people&#8217;s lives simple. Plus, HTC seems like they added a pretty low end accelerometer and it isn&#8217;t calibrated very well. Plus, you can&#8217;t really calibrate it.</p>
<h3>Development</h3>
<p>The winner: <b style="color: green">Android</b></p>
<p>I&#8217;ve talked at length about how I think Objective-C is really keeping Apple back, but here&#8217;s another way to look at it. If you take the years that technologies were introduced and line them up so that you have language, RAM, and CPU (based on speed), here are the results:</p>
<p>  iPhone: 1986 1989 2000<br />
  G1: 1995 1996 2000</p>
<p>I definitely like the G1 and Android numbers much better.</p>
<h2>The Final Score</h2>
<p>If we add all these up, it looks like this:</p>
<p><b style="color: green">G1/Android: 5</b></p>
<p><b style="color: blue">iPhone/OS X: 11</b></p>
<p>The final winner? <b style="color: blue">iPhone/OS X</b></p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/01/23/android-review-and-iphone-comparison/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting the current system time in milliseconds with C++</title>
		<link>http://brian.pontarelli.com/2009/01/05/getting-the-current-system-time-in-milliseconds-with-c/</link>
		<comments>http://brian.pontarelli.com/2009/01/05/getting-the-current-system-time-in-milliseconds-with-c/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 19:28:22 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[C++]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Microsoft]]></category>

		<category><![CDATA[OS X]]></category>

		<category><![CDATA[current time]]></category>

		<category><![CDATA[milliseconds]]></category>

		<category><![CDATA[osx]]></category>

		<category><![CDATA[system time]]></category>

		<category><![CDATA[time]]></category>

		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=257</guid>
		<description><![CDATA[After doing quite a bit of C++ recently, I thought I would post my method for getting the current system time in milliseconds in C++ for both Mac OS X and Windows. The Mac version might translate to other Unix platforms, but you&#8217;ll have to check the docs or man pages.
Mac OS X

#include &#60;sys/time.h>
timeval time;
gettimeofday(&#038;time, [...]]]></description>
			<content:encoded><![CDATA[<p>After doing quite a bit of C++ recently, I thought I would post my method for getting the current system time in milliseconds in C++ for both Mac OS X and Windows. The Mac version might translate to other Unix platforms, but you&#8217;ll have to check the docs or man pages.</p>
<p><b>Mac OS X</b></p>
<pre>
#include &lt;sys/time.h>
timeval time;
gettimeofday(&#038;time, NULL);
long millis = (time.tv_sec * 1000) + (time.tv_usec / 1000);
</pre>
<p>This actually returns a struct that has microsecond precision.</p>
<p><b>Windows</b></p>
<pre>
#include "windows.h"
SYSTEMTIME time;
GetSystemTime(&#038;time);
WORD millis = (time.wSeconds * 1000) + time.wMilliseconds;
</pre>
<p>This code gives the milliseconds within the last minute. If you want milliseconds since epoch or some other fixed point in time it will require a bit more math on the SYSTEMTIME struct.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2009/01/05/getting-the-current-system-time-in-milliseconds-with-c/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Writing a marker interface in C++</title>
		<link>http://brian.pontarelli.com/2008/12/09/writing-a-marker-interface-in-c/</link>
		<comments>http://brian.pontarelli.com/2008/12/09/writing-a-marker-interface-in-c/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 00:30:06 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
		
		<category><![CDATA[C++]]></category>

		<category><![CDATA[EXC_BAD_ACCESS]]></category>

		<category><![CDATA[interfaces]]></category>

		<category><![CDATA[marker]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=255</guid>
		<description><![CDATA[Just figured this out and it caused me about 3 hours of pain, so I figured I&#8217;d post it in case I need to do it again.

class Base {
public:
  virtual ~Base() {};
};

class Derived : public Base {
private:
  set someSet;
public:
  virtual ~Derived() {};
  set getSomeSet() { return someSet; };
};

You might find this [...]]]></description>
			<content:encoded><![CDATA[<p>Just figured this out and it caused me about 3 hours of pain, so I figured I&#8217;d post it in case I need to do it again.</p>
<pre>
class Base {
public:
  virtual ~Base() {};
};

class Derived : public Base {
private:
  set<string> someSet;
public:
  virtual ~Derived() {};
  set</string><string> getSomeSet() { return someSet; };
};
</string></pre>
<p>You might find this necessary if you have some code like this:</p>
<pre>
class Base {
};

class Derived : public Base {
private:
  set<string> someSet;
public:
  set</string><string> getSomeSet() { return someSet; };
}

void main() {
  map</string><string , Base> objects;
  Base base;
  if (objects.find("foo") != objects.end()) {
    base = objects.find("foo")->second; // This is actually a Derived
  }
}

void useBase(Base&#038; base) {
  Derived* derived = (Derived*) &base;
  set</string><string> someSet = derived->getSomeSet();
  ...
}
</string></pre>
<p>This code will toss strange errors such as EXC_BAD_ACCESS and other kernel alarms. I&#8217;m not certain way this happens, but I think it is because Derived in the second example isn&#8217;t actually an instance of Base since the compiler doesn&#8217;t understand that Base is polymorphic. If you try to apply a dynamic_cast operator rather than the pointer cast (as used in example #2) the compiler will complain. What is probably happening is that at runtime the memory for the Derived is not correct because it was cast to a Base, and the kernel freaks out when you attempt to access something in Derived.</p>
<p>Another classic example of C++&#8217;s power causing major issues at runtime. These types of problems are not only tricky to figure out, but really only make sense to the kernel and compiler and aren&#8217;t obvious from a OO perspective.</p>
<p>Most modern OO languages would have absolutely no issues with the above code, and all dynamic OO languages wouldn&#8217;t even need the casts at all and would duck type the invocations via dynamic method invocation.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2008/12/09/writing-a-marker-interface-in-c/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
