Pro JavaScript for Web Apps

Author:Adam Freeman
Publisher: Apress
ISBN: 978-1430244615
Audience: Advanced JavaScript programmers
Rating: 3.5
Reviewer: Ian Elliot

"Pro" JavaScript is not something everyone thinks can exist. Can a short book change your mind?

This isn't a book that everyone will like or want to read but for a few it will be very welcome. First it is important to say what it isn't. This is not really about about how to use the JavaScript language to write good code. It assumes that you are already a good JavaScript programmer. However this said the code that is presented isn't particularly radical or hardline object-oriented. Objects are used but without much fuss. In the same way the usual JavaScript tricks of immediate function evaluation and using objects as namespaces are explained. However language issues such as closure, first class functions, functions as objects and so on aren't mentioned. This book mostly strives to use JavaScript as if it was a poor relation to a proper object-oriented language.




The narrative of the book has a single focus - implementing a moderately big example. If you like plenty of code then this will please you however you will have to work at understanding the ideas from the code.

Chapter 1 discusses some tools that you might like to use. This immediately indicates one of the problems of JavaScript coding - the lack of tools. From here we have a first look at the example.

Chapter 2 develops the example a little by using jQuery. This is the first of the JavaScript libraries that are heavily used in the construction of a "pro" application. The problem with the approach is that while it might be what you do in practice it tends to cover up the inner workings and the problem that the libraries aim to solve. By the end of the chapter you have discovered how to modify the DOM, hookup events and modify the CSS. In this particular case the example doesn't really make a case for the practice of making such changes - why not just modify the HTML or the CSS directly, what is the advantage of dynamic components?

Part of the answer is to be found in the next two chapters where the MVC design is briefly introduced. Again JavaScript libraries are used to implement a view model and URL routing. If you don't want to use or learn about the particular libraries used Knockout and Crossroads. These are good choices but it would be fairer to the reader to make it clear what was being used in the book.




Chapter 5 is where things begin to go a little wrong - and it isn't really the book's fault. The subject is creating web apps that can work offline and this is where we first meet the problems of working with standards that are implemented differently by each of the browsers. At the start of the chapter it says

Caution The browser support for offline storage is in an early stage, and there are a lot of inconsistencies.

Other similar messages can be found in a lot of the remainder of the book. The caution is certainly accurate but it raises the question of what such flaky technologies are doing in a book about creating "pro" apps. No real solutions are provided to most of the inconsistencies pointed out and hence you can't really treat any of the techniques as secure enough to be used unless you limit your attention to a particular browser. Even then there are usually problems with implementation.

The application cache is the main topic of Chapter 5. Local storage is the topic of Chapter 6 with a brief explanation at the end  using IndexDB. Chapter 7 is a mixture of topics under the heading of responsive web apps - setting the viewport, screen size changes and using jQuery UI. The final part of the chapter is about using touch and again it is admitted that the raw APIs aren't ready for pro use and so we have to use a library - TouchSwipe in this case.  Chapter 8 is about creating mobile web apps - user agent detection and using jQuery Mobile.

The final chapter is on writing better JavaScript here we meet the problems of creating namespaces and managing dependencies. If you are not a JavaScript expert then these might be side issues compared with what you might want to know about better JavaScript.

Overall this is quite a good book if what you are looking for is a set of long examples. Much of the code is repetitive and the relevant parts being discussed in the text are generally highlighted in bold. Often it seems that a page of HTML is presented simply to show a single bold line of interest. You might like this style of presentation but I think it wastes space and makes it harder to focus on what is important.

The other major factor is the use of particular libraries to solve problems. This is realistic but it would have been better to make the libraries more obvious. For example instead of calling a chapter "Adding a View Model" it would have been better to title it "Adding a View Model With Knockout". This book isn't explaining pure JavaScript, but JavaScript augmented with libraries that the author happens to like. This is a problem for many JavaScript books and the only way to deal with it is to be up front and say what libraries are used in big type.

How much you will get from this book depends on how persistent you are at following the example. There are lots of small valuable chunks of advice and ideas but these are hard to pull out from a narrative. The one idea you can't help but come away with is that much of this technology is not ready for "pro" use. Perhaps in a year or so...



Learn Quantum Computing with Python and Q#

Author: Dr. Sarah Kaiser and Dr. Chris Granade
Publisher: Manning
Date: June 2021
Pages: 384
ISBN: 978-1617296130
Print: 1617296139
Kindle: B098BNK1T9
Audience: Developers interested in quantum computing
Rating: 4.5
Reviewer: Mike James
Quantum - it's the future...

Seriously Good Software

Author: Marco Faella
Publisher: Manning
Date: March 2020
Pages: 328
ISBN: 978-1617296291
Print: 1617296295
Kindle: B09782DKN8
Audience: Relatively experienced Java programmers
Rating: 4.5
Reviewer: Mike James
Don't we all want to write seriously good software?

More Reviews

Last Updated ( Saturday, 01 December 2012 )