Tuesday, May 17, 2011

Book review: Dive into HTML5

Inspired by the review published by Gábor Török I bought the book Dive Into HTML5 by Mark Pilgrim. I finished reading it yesterday, and in short I'm a bit disappointed.

First of all I should mention that I'm not the primarily targeted reader of the book since I'm mainly a PHP developer and I'm not really a HTML guy. Since HTML5 is not only HTML but also CSS and JS I was interested in the new features - now it's high time to learn them - but primarily I was interested in the new Javascript API-s. The following review is totally subjective, please read it from the aspect of somebody who sometimes works with the described technologies but definitely not all the time.


The first chapter

is an introduction and a detailed history of the evolution of HTML and XHTML. It also involves the the development process of the HTML5 specification and some stories about the browsers and rendering modes. Maybe this chapter is a bit too long. It's fun to read it, but when you finished you just can't wait to read something useful.

The second chapter

is an introduction about each feature of HTML5. It also contains sample codes to detect if the feature is available in the browser or not, and in every subsection it mentions the Modernizr API also as a simple way of detection. Read the chapter through quickly and use it as a reference when you need it.

The third chapter

is about the new semantic HTML5 tags. It mentions the proper doctype, the html and head tags and the lang attribute, then it gives a detailed description of the rel tag. Then a long description comes about the article, hgroup, time, nav, header and footer tags - what is the expected semantics and how to use these tags. I will be honest - this chapter totally left me cold. Maybe it will be useful one time when I will be expected to use these tags but I found nothing interesting here. Of course a HTML guy's opinion would be totally different. The chapter also mentions that IE8 (and previous versions) don't know these tags, and in IE you can't add any CSS formatting to unrecognized tags unless doing some javascript hacks - at this point I decided I will still be happy with div, span and p in the shorter future...

The fourth chapter

is about the Javascript Canvas. This was one of the chapters I was really interested in. The chapter mainly describes the API for drawing and filling simple shapes, writing text on the canvas and adding gradients, rendering pictures. Well, the book gives pretty detailed instructions on how to do that, but I would have been interested in a bit more, for example how to move an image on the canvas if you have non-single-color background, what about double-buffering etc. Furthermore afaik the pixel data of the canvas is accessible directly from the Javascript API but it's read-only, but the book says nothing about it. I'm very interested if canvas is the right rendering technology for a web-based game, but based on this chapter I still couldn't decide. In short, the book introduces the simple drawing API but does not provide any information and best practices related to advanced usage, which is definitely needed if you are going to use the canvas instead of just playing with it.

The fifth chapter

is about video, the video tag and different media formats. I skipped this chapter, currently I'm not interested in such stuff. I will read it when I will need it in a real-life project.

The sixth chapter

is about the Geolocation API. The contents can be summarized in a few lines:
  • navigator.geolocation.getCurrentPosition(function(pos) { /* pos.coords.latitude and pos.coords.longitude are important here */})
  • the access to the position information is limited by the user
  • the returned information is not always correct
  • error handling is important
That's all. Reading a 10-pages long chapter and getting such low quantity of useful information is really boring.

The 7th chapter

is about local storage solutions. It describes the problems of cookies and some non-standard solutions like Internet Explorer userData or Google Gears. Then it moves on to the HTML5 Local Storage. The book gives very good, detailed instructions about using this key-value store and it's event handling, the local storage is the main topic of the chapter. Then it goes to the local SQLite database and mentions the Indexed DB. Well, this would be the part I would be mainly interested in, but the author points that out the future of those technologies is at least unclear, so I still don't know the answer to my primary question - what to do if I need something more complex than a key-value store? Of course it's not a failure of the book since at the time of writing nobody knew the answer, maybe I should look at the current state of the Web SQL database and Indexed DB. I would like to add that it's possible to store complex data structures in the local storage by storing JSON-encoded objects, in a NoSQL-like manner, and it definitely fits the needs of Javascript applications.

The 8th chapter

is about offline web applications - more precisely it's only about booting them. The chapter mainly talks about the cache manifest file, the loading and updating process. At the beginning it mentions that there is a flag in the DOM that marks if the connection is alive or not, but it doesn't say what it is (I had to google for that - navigator.onLine); then it also mentions some DOM events fired when the value of the flag changes, but I didn't find any information about that (I must add that I didn't read the original text, so it can be the failure of the Hungarian translation). These informations are definitely needed and working examples should have been written by the author, since an offline-working web application is not all about loading some resources and using them. A real-world application surely uses ajax, and if the connection is down then collects the data to be uploaded in a local cache then uploads it for batch processing when the connection is alive again. It definitely should be mentioned but it's not. It was very disappointing for me.

The 9th chapter

is all about the new input types with information about the rendering and keyboard usage on mobile devices, mainly about iPhone. It's worth reading but nothing special can be said about the topic.

The 10th chapter

is about HTML micro-data. It's also something I'm curretly not interested in. Maybe I will read it one time.


To sum up, the book doesn't contain so many useful information for me as I would expect. Especially the second chapter (detecting HTML5 technologies) totally doesn't make sense since it's related content is also the beginning of each chapters, so this way the book is a bit redundant. Furthermore some chapters - like the 4th one (canvas) - contains too many pictures for those very simple examples, it was something disturbing for me and not something that made the understanding easier. Furthermore the book doesn't say anything about WebSockets and WebWorkers which I would have been also interested in, therefore I feel that the book didn't completely give the "big picture" of HTML5, and this would be that I would expect. At last I would like to mention that the javascript code snippets of the book are coded in under_score style which is at least interesting in a book that is about web standards, since camelCase is definitely the standard coding style of Javascript.

1 comment:

  1. The book is a great starting point to get an idea what HTML5 is. You probably already knew that. It is not a definitive guide and even I do not think it should be its goal. Anyway, I see your point but this book just simply cannot be more than what HTML5 is. Beyond the hype, HTML5 is an increasing amount of capabilities and features. The book tried to show them off by giving you a summary of them. Maybe you chose the wrong book, and would have rather read "Pro HTML 5 Programming".

    ReplyDelete