Sunday, 26 January 2014

Book review: Boost C++ Application Development Cookbook

Although I write a lot about Clojure, I use C++ and Boost for the majority of my work. As such, when Packt offered me a review copy of Boost C++ Application Development Cookbook (sample chapter), I gladly took them up on the offer.

About the book

As you may infer from the word ‘cookbook’ in the title, this is not a comprehensive Boost reference or a book you expect to read from cover to cover. It consists of scores of recipes, all of which follow the same formula:

  1. An introduction the problem to solve.
  2. A brief statement of the prerequisite knowledge for the solution.
  3. A step-by-step walkthrough on how to solve the problem.
  4. A brief explanation as to how/why the solution works.
  5. Discussion about comparable/related functionality in C++11 or in other parts of Boost.
  6. Pointers to related recipes, external resources, and related Boost documentation.

These recipes are all grouped together into chapters, with each chapter having a general topic such as resource management or multithreading.

The intended audience for this book is experienced C++ developers who may not be familiar with all of Boost’s functionality and how compares with C++11.

Highlights

There are a lot things that I like about this book, in particular its emphasis on C++11 and the way it introduces a topic and then gives you to resources for more in-depth learning.

Though it’s been out for a couple years now, C++11 is still a relatively new standard and it takes time for programmers and programs to adopt it. Many of the new library features in C++11 are based on Boost libraries, and some Boost libraries exists to help ‘backport’ new language features to older versions of C++. The Cookbook does a very good job of letting the reader know whether C++11 has the same or similar features as Boost and how they differ.

The other thing I really enjoyed about this book is how it gently introduces the reader to Boost. There are a lot of Boost libraries, and the quality of the official documentation varies from very good to cryptic. In the past, I have avoided some libraries simply because I could never figure out how to even get started using them. This book can make some of these more accessible by giving me a simple example from which I can get a toehold. From that point, I can start to make sense of the documentation.

Room for improvement

No book is perfect, and there are a couple of ways in which this book could be more useful:

  1. It is not exhaustive. Granted, the number of Boost libraries is enormous, and some of them have limited applicability. Fortunately, the Cookbook does a good job of covering the most useful libraries.
  2. It only barely touches on the situation when you have to do deal with different Boost versions. Some Boost libraries have source and ABI incompatibilities between versions, and it can sometimes be a bit of a nightmare to write code that has to support different versions of Boost. It would have been nice to see if the author had any insights on how to handle that issue.

Concluding thoughts

Boost C++ Application Development Cookbook is definitely worth considering if you are a C++ developer that uses or would like to use Boost. It’s a good reference to have handy when you find yourself in a situation where you think: 'There has got to be a library for this.’

Thursday, 19 May 2011

The Motorola Xoom and the Asus Eee Pad Transformer: a developer’s perspective

I have been getting more deeply involved in Android development of late, and these days that means developing for both phones and tablets. Unfortunately, the emulator for Honeycomb is incredibly slow. Therefore, I decided to purchase the Wi-Fi version of the Motorola Xoom shortly after it was released.

Just a month later, I learnt about the Asus Eee Pad Transformer and its well-integrated keyboard dock. Seeing the opportunity to have a device that can be used as a netbook, I decided to get one of these as well.

Now that I have had the chance to use both of these devices, I thought I would take the time to write about both of them primarily from the standpoint of a developer.

The Motorola Xoom

The Motorola Xoom was the first Honeycomb tablet, and Google used it as their development device. It was initially released as a 3G model for Verizon, and later as a less expensive Wi-Fi only model. Both versions have 32GB of built-in memory, and a non-functioning microSDHC card slot. Overall, it is a well-built and solid tablet.

Developing with the Xoom

Developing applications with the Xoom is a fairly standard experience. Simply connect the tablet to your computer via USB, just as you would with most any other Android device.

However, if you want to work at a lower level, the Xoom’s bootloader can easily be flashed just like a Nexus device. Unfortunately, it seems like the full source code for Honeycomb will not be released, at least not until it’s released as Ice Cream Sandwich.

On the cutting edge

One thing that makes the Xoom particularly interesting to developers is that it appears to be the primary tablet used for development at Google. As a result, it is the first to get operating system updates. Android 3.1 was announced at Google I/O, and within days both versions of the tablet started getting OTA updates to this latest Android release.

Not quite complete

Unfortunately, despite its expense, it is not quite complete. It has now been three months since the initial release of the Xoom, and the software to make the microSDHC card slot is still vapour-ware. This is particularly embarrassing since other tablets have now shipped with working slots.

Similarly, for the 3G version, the upgrade to LTE will require mailing the device to Motorola and waiting at least a week for it to be returned. For a user, this is very annoying; for a developer, this is potentially downtime.

The Asus Eee Pad Transformer

The Transformer was released in the US late last month. In many ways, it is a typical Android tablet: 10.1 inch 1280×800 pixel display, 1GB RAM, and a 1.0GHz dual core Tegra 2 processor. It is currently on Wi-Fi only, and available in both 16GB and 32GB configurations. It also has a working microSDHC card slot.

However, what really sets the Transformer apart is this keyboard dock. Slipping your tablet into the dock transforms your tablet into a nice Honeycomb netbook. In addition to the full keyboard, the dock also adds a full size SDHC/MMC card reader, two full-size USB host mode ports, and a battery that combines with the tablet’s battery to provide upwards of 14 hours’ worth of power.

Developing with the Transformer

Like the Xoom, you can just plug the Transformer into your computer’s USB slot, and you are ready to develop. However, the Transformer has a couple of differences that make it less developer-friendly.

The tablet (and dock) use a proprietary socket that handles charging the battery, connecting to the dock, and connecting to a computer. The most important implication of this is that you cannot charge your tablet at the same time you do development. To make matters worse, the cable included with the tablet is quite short.

In practice, the battery life of the tablet is fairly good. Using the dock should give enough battery life to handle any marathon coding session, but if you forget to recharge your batteries you may end up having to disconnect from the computer in order to charge the tablet. I have not investigated if the dock’s USB ports can be used for an adb session.

Additionally, the Transformer does not have an unlocked bootloader. This makes it much more difficult to root the device or to do any low-level development. It is too bad Asus has chosen not to make the device more hackable.

Keeping up to date

According to Asus, Android 3.1 will not be released for the Transformer until sometime in June. While this may not be as speedy as some may like, it is roughly in line with other non-Xoom tablets.

One way in which I believe Asus has been better than Motorola is in releasing updates to fix problems experienced by users. Some engineers from Asus apparently hang out in the XDA developer forums, and have worked with users to solve various software problems. The result has been a series of updates since the product’s launch.

Beyond the tablet experience

The one thing that struck me while using the Xoom is that a tablet makes a splendid consumption device. It is good for surfing the web, watching a video, or playing a game. However, as a production device, such as writing e-mail or taking notes, it could not replace my laptop. It is true that the large screen makes typing on the tablet much better than trying to do the same on a phone, but it still cannot match the productivity of having a full keyboard.

The Transformer promises to change all of that. The keyboard dock will allow me to replace my laptop for many lighter tasks, such as checking e-mail, writing, and even some system administration and programming. I am currently working on modifying [ConnectBot][cbot], the popular Android SSH client, to work with the Asus keyboard (and other full keyboards via USB and bluetooth). This will help make the tablet not just a platform for development, but a useful tool in its own right.

Choosing a tablet

The Xoom and the Transformer are not the only options for an Android tablet. However, at the moment, I think these two tablets are the most compelling for the Android developer. Which should you choose? That all depends on your needs.

Choose the Xoom, if you…
  • Want to be running the latest Android release
  • Need to easily root your device or modify the firmware
  • Do not mind paying a premium. The Wi-Fi version retails at $600, $100 more than the equivalent Transformer.
Choose the Transformer, if you…
  • Want the best value in an Android tablet. At $400 for the 16GB version, it is the least expensive Honeycomb tablet on the market.
  • Would like to get more out of your tablet. You can spend the same amount of money and get a better netbook. However, if you are going to get an Android tablet for development anyway, spending the extra $150 for the dock may change how you use your tablet.