Saturday, September 14, 2013

Apple - ahead of the competition, again


5 days have passed since Apple presented the best iPhone yet - iPhone 5s. The only great feature I see there is the 64-bit processor inside. Let me tell you why I believe this is a brilliant move and why I do think Apple's users will not be the first to take advantage of this.

Why is it brilliant move?


Apple is a great vertically integrated company. They make both hardware and software, then pack it into great products. While they do not make all the hardware, they control the most important parts of it and work on helper chips like M7 to add additional functionality to their devices. All this makes possible for innovation to happen quicker compared to other vendors. On 10th of September they prove it once again by showing the first 64-bit smartphone. This makes them way ahead of the competition on that field.

What will it cost to the rest of the smartphone industry to match that?


Several companies need to work together, or in turns, to make the same thing happen.
  • ARM should produce a final specification of the instruction set (this is probably done or almost done)
  • ARM certified companies should create 64-bit processors working with the new instruction set. I can only hope this is in the works too.
  • Whoever makes the C/C++ compiler (gcc, arm, microsoft) should add support for that new 64-bit instruction set. I guess that someone is working on that. This will produce all the needed tools (compilers, linkers, other developer stuff called "toolchain"), which will make the next step possible
  • Google and Microsoft should port Android and Windows Phone/RT/etc. to be built with the new 64-bit toolchain. They should also provide support for the new 64-bit versions to run old 32-bit programs.
  • With all previous steps done - Samsung, HTC, Nokia and others can build the new generation of devices.
As you can see this is a big set of complex tasks. Though some of them can be done in parallel, others have dependencies and cannot. It will take time for the rest of the smartphone industry to catch up!

Why I do believe, Apple users won't be the first to take real advantage of this 64-bit thing?


Apple made a great marketing message out of it. They reminded the world they have not lost their innovation edge and I really love that! But what does 64-bit really means to the end users? Well - it does lead to minor performance boost in some specific tasks involving 64 bit integer calculations. Probably memory transfers will be faster too. It will also lead to bigger code size (that's more data to transfer when you download apps). The most important gain from 64-bit transition is support for more than 4GB of RAM inside your device. To be honest, if it wasn't for that last advantage, I don't think switching is needed at all, but it is there and the smartphone future is 64-bit for sure. To me unless you put more than 4GB of RAM inside that device, 64-bit architecture is just a nice marketing message, another line in specification wars, showing a potential - but nothing substantial.

Having all that said and taking into account current specifications history, I expect Samsung, Sony or HTC to be the first to release a smartphone with more than 4GB of RAM, not Apple. That's how it might be Android, not iOS users be the first to enjoy the true 64-bit advantages.

Sunday, September 1, 2013

Apple "cable" adventures

Several weeks ago I found out I need a long lightning cable. Since Apple provides only 1 meter cables for $19 I decided to buy a 2 meters cable from eBay for $3 (delivery included) instead. Today it arrived from China and this is the welcoming message to see when I plugged it in. (<= look at the picture now!) ... 

"It's a bloody cable" I yelled at the screen, but Siri remained silent.

Of course I know this is not a cable. Cables are used to transfer electricity only. Apple call it a cable, it looks like cable to the users, but it a contains electronics, which makes it a convertor. Convertors are more complex and tend to break more often. In general using convertors for cables is bad for users. Here are several examples when those convertors got me in trouble:

The last two devices we bough for development used a lightning cable. We used cables that came with them for development and one of those cables just stopped working about 1 week later. Looking from outside it was a perfectly new cable. Just electronics inside were broken. We put it in the trash and bought two new cables from Apple. You know ... just in case ...

The second story is older and is about the older 30 pin Apple "cables". Since the principle is the same I guess same things can happen with the new cables.

I bought my iPad 3 and found out that not only the cables are the same, but chargers also look exactly the same as those of my old iPhone 3GS. I got worried because the new charger had 2.1A output, while iPhone's charger was 1A output. If I put 2.1A into iPhone it could fry it. If I put 1.0A into iPad it will charge it more than twice slower! It turned out the "cables" take care of this. They know they are connected to iPhone and they make it charge with the proper power. However my original iPhone 3GS cable knew nothing about iPad 3 and even with iPad's charger it charged it at iPhone's rate! Now I have two "cables" which look exactly the same and both work on iPhone, but only one of them charges properly my iPad. It SHOULD be a bloody cable, NOT a converter! Electronics should be inside the devices not inside the cables!

Sunday, August 18, 2013

Why I decided NOT to buy Windows Phone


Recently my old HD2 (running Android) died and I decided to go for a Windows Phone 8 device. I thought it would be a nice change. Since I like experimenting and love having as much control over my own device as possible, I went to http://forum.xda-developers.com/. I always do so in order to check out, how my device of choice handle custom ROMs and other updates. To my surprise it turned out, the device does not support custom ROMs. At this point no Windows Phone 8 device does! So the decision was obvious and now I'm a proud owner of Samsung Galaxy S4, rooted and tuned to my liking in its first 24 hours.

I don't understand Microsoft's logic here. Here are the facts as I see them, both good and bad:

  • Windows Phone as an OS is good. Lags about an year behind iOS and Android but is catching up.
  • Devices are good. Again lag about an year, year and a half behind. Kind of catching up at least with Apple in terms of some hardware. At this point only one device (Nokia Lumia 1020) with its 41MP camera has competitive edge in hardware.
  • Visual Studio IDE, the tool for building apps is on par with Xcode and Eclipse ADT. (I also tried Android Studio. It's too early to mention it here)
  • Windows Phone and its devices are not a market leader. In fact they are not even close to being such.
  • The above results in many developer not considering Windows Phone as a primary target. This leads to chicken and egg problems. Not enough apps, because there are not enough users, because there are not enough apps.

What does all this have to do with no custom ROM support? Everything! Yes, I know. People like me willing to play with their phones, build and try custom ROMs and other great stuff are minority. We are not marketing target and should not be. However we are the ones who show how cool a phone can be. People like me inspire others to use this or that product. We explore and find new ways to show the real potential behind a device.


Dear Microsoft,

Why would you lock your devices when all you need at this point are early adopters to help you Crossing the Chasm? If you don't believe me look at the Xbox ONE DRM reactions. Please fix this! It would be nice to have another good mobile OS to play around for the years to come.

Best Regards,
demosten

Thursday, September 15, 2011

Compiling Your Own Version of SQLite for iOS and applying some fixes

Adding your own version of sqlite for iOS is fairly easy task.
  1. Go to http://www.sqlite.org/ and download the latest sqlite amalgamation archive
  2. Extract it somewhere and add it to your Xcode project. You have several options here. You could copy it to your project folder, or link to it. You could also decide, to put it as a static library target and link it to your main target. It's up to you. You will need only sqlite.c and sqlite.h files.
  3. Apply some #defines you might need. For example:
#define SQLITE_ENABLE_FTS3
#define SQLITE_DISABLE_LFS
#define SQLITE_THREADSAFE 0
Then you can compile!

If you need more detail about this part of the process, you can find more detailed description here and here.

And then I hit a problem. I was testing on different simulator versions and found out that for some reason SQLite functions returned strange errors ( SQLITE_CORRUPT with number code 11 ) with some versions of the simulator, while with others, everything worked perfectly fine. After hours of debugging, I've found that the problem is in wrong file size, returned by a function called unixFileSize. Here is how it looks in my sqlite version:
/*
** Determine the current size of a file in bytes
*/
static int unixFileSize(sqlite3_file *id, i64 *pSize){
  int rc;
  struct stat buf;
  assert( id );
  rc = osFstat(((unixFile*)id)->h, &buf);
  SimulateIOError( rc=1 );
  if( rc!=0 ){
    ((unixFile*)id)->lastErrno = errno;
    return SQLITE_IOERR_FSTAT;
  }
  *pSize = buf.st_size;

  /* When opening a zero-size database, the findInodeInfo() procedure
  ** writes a single byte into that file in order to work around a bug
  ** in the OS-X msdos filesystem.  In order to avoid problems with upper
  ** layers, we need to report this file size as zero even though it is
  ** really 1.   Ticket #3260.
  */
  if( *pSize==1 ) *pSize = 0;


  return SQLITE_OK;
}
Here after a successful call to osFstat, buf.st_size contained wrong file size. This is clearly not a bug in SQLite. There might be several reasons for this to happen. Probably struct stat is different in terms of packaging or field sizes from the one compiled with some of the simulators. I don't know and since I cannot fix it in iOS Simulator (the power of closed source in action), I don't really care. What I can fix, is not to use fstat() and struct stat in this function. Here is how I changed the function using other Unix ways and do the job:
/*
** Determine the current size of a file in bytes
*/
static int unixFileSize(sqlite3_file *id, i64 *pSize){
  off_t pos, size;
  pos = lseek(((unixFile*)id)->h, 0L, SEEK_CUR);
  if (-1 == pos){
    ((unixFile*)id)->lastErrno = errno;
    return SQLITE_IOERR_SEEK;
  }
  size = lseek(((unixFile*)id)->h, 0L, SEEK_END);
  if (-1 == size) {
    ((unixFile*)id)->lastErrno = errno;
    return SQLITE_IOERR_SEEK;
  }
  if (-1 == lseek(((unixFile*)id)->h, pos, SEEK_SET)) {
    ((unixFile*)id)->lastErrno = errno;
    return SQLITE_IOERR_SEEK;
  }
  *pSize = size;

  /* When opening a zero-size database, the findInodeInfo() procedure
  ** writes a single byte into that file in order to work around a bug
  ** in the OS-X msdos filesystem.  In order to avoid problems with upper
  ** layers, we need to report this file size as zero even though it is
  ** really 1.   Ticket #3260.
  */
  if( *pSize==1 ) *pSize = 0;


  return SQLITE_OK;
}
As you can see I'm using lseek to get the file size and thus avoid the struct stat and fstat() usage. This fixed the problem for me and I hope this could spare some time to others too. Note that this fix is not portable and will not work in non Unix environment.

Monday, August 29, 2011

How to have great wait cursor animations for free


While searching for a "trivial" wait animation for one of my AJAX projects I've found a great online solution for the problem. It has been around for years now, but it's new for me and I decided to share it.

Introducing http://ajaxload.info/ a free AJAX load animation generator. It's great to have it around.

Here are some images I've created briefly as a showcase ..... well I guess they already have your attention :)







Thursday, August 25, 2011

Linking to Android Market applications on the web

While working on web version of Da Dictionary I've decided to add link to Android version. Web links to Android Market looks like this http://market.android.com/details?id=com.demosten.android.dadict where 'com.demosten.android.dadict' is the package name which is unique for Android Market. This seams to work well when opened from PC browser. However opening this link from Android is a different story. The best way to open it is directly in Android Market application which works with different URI scheme. It looks like market://details?id=com.demosten.android.dadict where again we see the same package name mentioned. While built-in Android browser plays it smart and open the link in directly in Market Application alternative browsers like Firefox does not do so and viewing web version of Android Market on an Android phone is far form what users expected to see.

My solution
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
  updateAndroidMarketLinks();
  // some more core here ... 
 
  function updateAndroidMarketLinks()
  {
    var ua = navigator.userAgent.toLowerCase();
    if (0 <= ua.indexOf("android")) {
      // we have android
      $("a[href^='http://market.android.com/']").each(function() {
        this.href = this.href.replace(/^http:\/\/market\.android\.com\//,
          "market://");
      });
    }
  }
});
</script>
</head>

<body>
<a href="http://market.android.com/details?id=com.demosten.android.dadict" target="_blank">Download for Android</a>
</body>

</html>
As you can see my solution is based on JavaScript and jQuery. The idea is to search for 'android' sub-string inside browser's UserAgent and if that is the case - replace HTTP URI part with Android Market URI part, inside all links.

I believe a JavaScript only version is not hard to do, but I prefer to use jQuery.

Thursday, March 17, 2011

iPad 2 launch event impressions

I've finally found some time to watch Apple's iPad 2 launch event. I liked it. It looks like a great product and as usual, Steve and company presented it very smoothly. Someone should write a book "How to present like Apple" here!

One thing that puzzles me is why did they mentioned the competition so many times? If you are so convinced, you have the greatest product around, why should you bother even mentioning any competition? The history will probably repeat itself. The first phones that caught up with iPhone appeared 2 years later and the first which were (in my opinion) better, after 3. I believe the same will happen with tablets. Saying that, it looks to me like Apple are starting to feel the pressure now, but I don't think they'll be matched this year. Meanwhile I'm adding iPad 2 to my wish list.