Secret Omens: Book Update


Jeff Atwood wrote up a post today on the merits of writing a technical book in this day-and-age and specifically called out my past post on programming book profits and my work-in-progress Secrets of the JavaScript Ninja.

I wanted to give a brief status update on the book and how it’s going. I started the book in early 2008 and was actually quite productive, finishing nearly the entire book that year (with some missing gaps that I fixed up in 2009). There was some work left to do to make it a better book but, honestly, I got caught up in coding and stopped focusing on writing. I had to prioritize my time and I chose to prioritize doing more development and focusing on my personal life. Some time last year Manning brought on a co-author, Bear Bibeault, to finish the book and get it out the door. He’s done a bunch of revision bringing it up-to-date and just the other week I finally wrote the preface. It’s in final revisions now and should be out-the-door very soon. This is a huge relief for me and it’s great that there’s one less thing to worry about.

To the point of Jeff’s post, I would absolutely not write a technical book again. It’s a tedious process and unless you LOVE writing and are really good at it (like Nicholas Zakas or Dave Flanagan) then I suggest that you stick with the medium that is truly successful: Writing long-form articles/blog posts and possibly spinning them off into purchasable ebooks. (As an example, I’d point to Juriy Zaytsev and Peter-Paul Koch both of whom could get any JavaScript position in the world purely based upon the quality of their articles and sites, without ever having written a book.)

I realized at some point in late 2008 that that’s really what I should’ve done with Secrets of the JavaScript Ninja but I was already neck-deep in the book with most of it complete. Ironically working on the book (or not working on it, however you look at it) actually compelled me to NOT blog more as every time I wanted to write a technical blog post I was forcing myself to make the decision “I’m writing about 1000 words on a technical matter, shouldn’t this just be going towards my uncompleted book?” and would just end up writing nothing as a result.

I do feel bad for, and apologize to, the people that pre-ordered hard copy version of my book over the years only to have to wait on a time scale comparable to George R. R. Martin’s writing schedule. Amusingly the book has been extremely successful as a pre-order e-book at Manning.com – it’s the best-selling MEAP book of all time. I’ve gotten numerous emails from readers who’ve gotten enormous benefit from the book, even in it’s rough form, and this has pleased me greatly.

I’m excited to finally have this book be out in the “wild”, as it were. It’s no longer (as Jeff put it) “permanently unfinished”.

I’ve included the preface from my book below, to give some more detail:

When I started writing Secrets of the JavaScript Ninja four years ago, in early 2008, I saw a real need: There were no books providing in-depth coverage of the most important parts of the JavaScript language (functions, closures, and prototypes) nor were there any books that even attempted to cover writing truly cross-browser code. Unfortunately it appears as if the situation has not improved very well, which is truly surprising.

More and more development energy is being put into new technologies (such as the ones coming out of HTML 5 or the new versions of ECMAScript). There isn’t a point to diving into new technologies, or using the hottest libraries, if you don’t have a proper understanding of the fundamental characteristics of the JavaScript language. While the future for browser development is very bright the reality is that most development needs to make sure that code continues to work in the majority of browsers and for the majority of potential users.

Even though this book has been under development for a long time, thankfully it is not out of date. The book has been given a solid set of revisions by my co-author Bear Bibeault. He’s gone through and made sure that the material will continue to be relevant for a long time to come.

A major reason why this book has taken so long is largely due to the experience that I was drawing upon to write the material for the later chapters on cross-browser code. Much of my understanding of how cross-browser development happens in-the-wild has come from my work on the jQuery JavaScript library. As I was writing the later chapters on cross-browser development I realized that so much of jQuery’s core could be written differently, optimized, and made capable of handling a wider range of browsers.

Perhaps the largest change that came to jQuery, as a result of writing this book, was a complete overhaul from using browser-specific sniffing to using feature detection at the core of the library. This change made it so that jQuery could be used almost indefinitely, without assuming that browsers would always have specific bugs or be missing specific features.

As a result of these changes jQuery directly anticipated many of the improvements to browsers that have come during the past couple years: Google released the Chrome browser, the number of useragents have exploded as mobile computing has increased in popularity, Mozilla, Google, and Apple have gotten into a browser performance war, and Microsoft has finally started making substantial improvements to Internet Explorer. It can no longer be assumed that a single rendering engine (such as WebKit or Trident, in Internet Explorer) will always behave the same way. Substantial changes are occurring rapidly and are spread out to an ever-increasing number of users.

Using the techniques outlined in this book, jQuery’s cross-browser capabilities provide a fairly solid guarantee that code that you write with jQuery will work in a maximal number of browser environments. This guarantee has led to explosive growth in jQuery over the past four years, with it now being used in over 57% of the top 10,000 websites on the Internet, according to Builtwith.com.

The portions of this book that cover features that are relatively un-changing, such as code evaluation, with statements, and timers are continually being used in interesting ways. There are now a number of active programming languages that are built on top of, or compiled to, JavaScript: Such as CoffeeScript or Processing.js. These languages require complex language parsing, code evaluation, and scope manipulation in order to work effectively. While dynamic code evaluation has been maligned due to its complexity and potential for security issues, without it we would not have had the CoffeeScript programming language – which has gone on to influence the upcoming ECMAScript specification itself.

I’m personally making use of all of these features, even today, in my work at Khan Academy. Dynamic code evaluation in the browser is such a powerful feature: You can build in-browser programming environments and do crazy things like inject code into a live runtime. This can result in an extremely compelling way to learn computer programming and provide all sorts of capabilities that wouldn’t be possible in a traditional learning environment.

The future for browser development continues to be very strong and it’s largely due to the features encapsulated in JavaScript and in the browser APIs. Having a solid grasp of the most crucial parts of the JavaScript language, combined with a desire for writing code that’ll work in many browsers, will result in your code being elegant, fast, and ubiquitous.

Posted: July 11th, 2012


If you particularly enjoy my work, I appreciate donations given with Gittip.

37 Comments (Show Comments)



Comments are closed.
Comments are automatically turned off two weeks after the original post. If you have a question concerning the content of this post, please feel free to contact me.


Secrets of the JavaScript Ninja

Secrets of the JS Ninja

Secret techniques of top JavaScript programmers. Published by Manning.

Ukiyo-e Database and Search

Ukiyo-e.org

Japanese woodblock print database and search engine.


John Resig Twitter Updates

@jeresig

Infrequent, short, updates and links.


via Ad Packs