Node.js Blueprints – A good how-to book that covers plenty of JS frameworks and tools – #programming #bookreview

7338OS_Node.js Blueprints (1)

 

Node.js Blueprints

Develop stunning web and desktop applications with the definitive Node.js

Krasimir Tsonev

(Packt Publishing paperback, Kindle)

 

Krasimir Tsonev’s new Node.js Blueprints book has proven helpful for me as I try to become more adept at using Node.js and a few of the many software packages that can work with it, such as AngularJS, Backbone.js, Ember.js, ExpressJS, Grunt.js and Gulp.js.

If you’ve never used Node.js before, here is its official description from the Nodejs.org site operated by Joyent, Inc.:

“Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”

The focus of Node.js Blueprints is on showing readers the basics of how to use various frameworks, libraries and tools that can help them develop real-world applications that run with Node.js.

Tsonev’s approach is to introduce several popular frameworks, libraries and tools, provide code examples and explain the roles of various sections or modules within the code. The goal in each chapter is to help the reader learn how to work with a framework or other package and create a simple application — a blueprint for something bigger — that can run with Node.js

The book is aimed at intermediate-level JavaScript developers, especially “web developer[s] with experience in writing client-side JavaScript,” who are interested in using Node.js in web and desktop applications.

The 12-chapter, 268-page book is structured as follows:

  • Chapter 1, Common Programming Paradigms, focuses on how “common design patterns known in JavaScript” can be applied in Node.js, as well.
  • Chapter 2, Developing a Basic Site with Node.js and Express, shows how to use ExpressJS, “one of the top frameworks on the market,” in applications “using the built-in Express modules and…your own modules.”
  • Chapter 3, Writing a Blog Application with Node.js and AngularJS, explains how to use the Angular frontend framework with Node.js, MongoDB and MySQL to create “a dynamic application that works with real databases.”
  • Chapter 4, Developing a Chat with Socket.IO, points out that “every big web app uses real-time data” and how it is “important to show instant results to the users.” And it covers “the creation of a simple real-time chat,” while emphasizing that “[t]he same concept can be used to create an automatically updatable HTML component.”
  • Chapter 5, Creating a To-do Application with Backbone.js, notes that “Backbone.js was one of the first frameworks that introduced data binding at the frontend of applications.” A simple (but useful) to-do application is used to illustrate how to use the powerful framework along with Node.js.
  • Chapter 6, Using Node.js as a Command-line Tool, explains that many command-line tools have been written with Node.js, and this chapter shows how to create one. The result is “a simple application which grabs all the images in a directory and uploads them to Flickr.”
  • Chapter 7, Showing a Social Feed with Ember.js, is centered on producing “an Ember.js example that will read a Twitter feed and display the latest posts. That’s actually a common task of every developer,” Tsonev says, “because a lot of applications need to visualize social activity.” (Reviewer’s caution: Ember.js has a long learning curve, and this chapter just barely gets you started.)
  • Chapter 8,  Developing Web App Workflow with Grunt and Gulp, explains how to use two popular task runners. “Grunt is the de facto standard” for simplifying and managing tasks such as concatenation, minification, templating and other operations before an application is delivered to users. Gulp, meanwhile, is a popular build system. The projects in this chapter include generating a cache manifest file using Grunt, and concatenating and minifying using Gulp.
  • Chapter 9, Automating Your Testing with Node.js, is especially aimed at fans (and forced-by-employer “enthusiasts”) of test-driven development and behavior-driven development. The chapter introduces how to use the Node.js versiosn of the Jasmine and Mocha frameworks for testing JavaScript code and how to use the headless browser PhantomJS to test user interfaces. You also are shown how to use DalekJS, a Node.js module that allows you to control major browsers such as Google Chrome, Internet Explorer and Firefox while doing interface tests.
  • Chapter 10, Writing Flexible and Modular CSS, emphasizes how “[t]he Web is built on the basis of three languages–HTML, CSS, and JavaScript” and “Node.js provides really helpful instruments to write CSS…and improve our style sheets.” Other topics include the Less preprocessor, the Stylus preprocessor, the Sass preprocessor, and the AbsurdJS preprocessor.
  • Chapter 11, Writing a REST API, focuses on building a Representational State Transfer (REST) Application Programming Interface (API). The chapter’s Node.js project is “an API of a simple online books library. The resources are the books, and they will be accessed through the REST API.” Tsonev notes that “Node.js is very often used to build REST APIs. Also, because it is a common tool, we have several possible approaches.” In this chapter, however, the emphasis is “to build our REST API from scratch, because it will be more interesting and challenging.”
  • Chapter 12, Developing Desktop Apps with Node.js, declares that “Node.js can be used to produce desktop programs, and w don’t have to learn a new language or use a new tool.” In this chapter, Tsonev shows how to use node-webkit to create a file browser that runs as a desktop program, reads files from the hard drive, displays the files on-screen, and also displays images.

Tsonev’s well-written book introduces a lot of good material to help you get started. After that, you have to do the work to get better at using the various frameworks and tools. But the writer gives you plenty of possibilities to start with in your quest to become a better developer.

You may encounter an occasional typo in the book’s printed code. Thus, be sure to download the available code examples for reference, even if you prefer to type in code by hand (one of my favorite ways to learn, too).

And, during the lengthy process to write, edit, and publish the book, some of the software has changed to newer versions than are called for in the text–which may affect how something works in certain small areas of code.  Indeed, in programming books that rely on several different software packages, changes always happen, and those changes seldom are convenient to the printing deadline.

So if something doesn’t work the way you expect, and you are positive your hand-typed code has no known mistakes, don’t yell at the author. Download the code examples. Look for the publisher’s errata files. Seek out comments at book sites such as the readers’ reviews on Amazon, as well as comments on social media sites and specialized sites where JavaScript and Node.js developers hang out. Also take a look at the “official” websites for the frameworks and tools.

I have been wanting to learn more about working with Node.js, and Node.js Blueprints definitely is filling that need.

Si Dunn

Advertisements

HTML5 and JavaScript Web Apps – With emphasis on the Mobile Web – #programming #bookreview

HTML5 and JavaScript Web Apps
Wesley Hales
(O’Reilly,
paperbackKindle)

Increasingly, the world of Web development is taking on a “mobile first” attitude. And for good reason. Sales of desktop and laptop computers are shrinking, while sales of mobile devices seem to be swelling into a flood.

“Consumers are on track to buy one billion HTML5-capable mobile devices in 2013,” Wesley Hales writes in his new book. “Today, half of US adults own smartphones. This comprises 150 million people, and 28% of those consider mobile their primary way of accessing the Web. The ground swell of support for HTML5 applications over native ones is here, and today’s developers are flipping their priorities to put mobile development first.”

Hales’ HTML5 and JavaScript Web Apps focuses on using HTML5, JavaScript, and the latest W3C specifications to create mobile and desktop web apps that can work on a wide range of browsers and devices.

Indeed, deciding what to support is a key point in this useful, well-focused how-to guide. Hales notes: “Unfortunately the Mobile Web isn’t write-once-run-anywhere yet. As specifications become final and features are implemented, interoperability will be achieved. In today’s world of mobile browsers, however, we don’t have a largely consistent implementation across all browsers. Even though new tablets and phones are constantly being released to achieve a consistent level of HTML5 implementation, we all know that we’re [also] stuck with supporting the older, fragmented devices for a set amount of time.”

The 156-page book straddles “the gap between the Web and the Mobile Web” but puts a lot of emphasis on developing mobile applications. Here are its nine chapters:

  1. Client-Side Architecture
  2. The Mobile Web
  3. Building for the Mobile Web
  4. The Desktop Web
  5. WebSockets
  6. Optimizing with Web Storage
  7. Geolocation
  8. Device Orientation API
  9. Web Workers

This is not a book for JavaScript, HTML, or CSS beginners. But if you have at least some basic experience with Web application development, Hales can help you get on track toward becoming a Mobile Web guru. Meanwhile, if you are already well-versed in the ways of the Web app world, you may still learn some new and useful things from HTML5 and JavaScript Web Apps.

Si Dunn

Programming Google App Engine, 2nd Edition – An important how-to guide, updated – #programming #bookreview

Programming Google App Engine, 2nd Edition
Dan Sanderson
(O’Reilly,
paperbackKindle)

O’Reilly recently has published a new edition of Dan Sanderson’s Programing Google App Engine.  The new edition updates the 2009 first edition and includes coverage of Java 6 and Python 2.7 support, multithreading, asynchronous service APIs, and using frameworks such as webapp2 and Django 1.3. (“App Engine does not yet support Python 3,” Sanderson notes.)

The 509-page, 20-chapter book shows how “to develop applications that run on Google App Engine, and how to get the most out of the scalable model. A significant portion of the book discusses the App Engine scalable datastore, which does not behave like the relational databases that have been a staple of web development for the past decade,” the author states.

Sanderson is a technical writer and software engineer at Google, Inc. His new edition is well-written and appropriately illustrated with code samples, diagrams, screen shots and other graphics.

With clear steps and good detail, the book shows you first how to install and use the Python or Java SDKs on Mac OS X, Linux, and Windows machines and how to develop simple Python and Java applications. From there, it expands deeper into the how-to aspects of programming the Google App Engine.

In some chapters, the Python and Java options are presented together. Python’s and Java’s data modeling libraries, however, are discussed in separate chapters.

“Google App Engine, Google’s application hosting service, does more than just provide access to hardware,” Sanderson points out.

“It provides a model for building applications that grow automatically. App Engine runs your application so that each user to accesses it gets the same experience as every other user, whether there are dozens of simultaneous users or thousands. The application uses the same large-scale services that power Google’s applications for data storage and retrieval, caching, and network access. App Engine takes care of the tasks of large-scale computing, such as load balancing, data replication, and fault tolerance, automatically.”

Programming Google App Engine, 2nd Edition can take you from asking “What is Google App Engine?” to well down the road toward becoming an App Engine expert.

Si Dunn

For more information: paperbackKindle

YUI 3 Cookbook – Keep your web apps from spiraling out of control – #bookreview #yahoo

YUI 3 Cookbook
Evan Goer
(O’Reilly, paperback, Kindle)

If you want to learn how to put the Yahoo! User Interface (YUI) Library to work in your web applications, this book definitely can help you get started.

The author, Evan Goer, brings the right credentials to the pages. He is Principal Technical Writer at Yahoo!, where he works for an engineering team that develops Yahoo’s internal deployment structure. He also works with Yahoo’s YUI core engineering team.

He describes YUI as “a powerful open source JavaScript and CSS toolkit for building web applications.”

His YUI 3 Cookbook focuses on using YUI’s  tools to solve a wide range of problems that can crop up while cranking out new web apps. The 406-page book is written clearly and illustrated with numerous code samples. It follows a problem-solution-discussion approach and is divided into 12 chapters:

  1. Loading Modules
  2. DOM Manipulation [DOM = Document Object Model manipulation]
  3. UI Effects and Interactions
  4. Events
  5. Ajax
  6. CSS
  7. Infrastructure
  8. Using Widgets
  9. Utilities
  10. Server-Side YUI
  11. Universal Access
  12. Professional Tools

“While YUI is succinct enough for ‘light’ JavaScript work,” Goer writes, “where it really shines is in providing a solid foundation for more maintainable code.”

For example, suppose you have used a prepackaged software widget and then had to modify it, and now you are locked into kludged code that will be difficult to maintain or extend.

Goer notes that YUI avoids lockin, because “every component in YUI is designed for extension. Every YUI widget shares the same solid API core and offers the same extension points, including a common rendering lifecycle with standard hooks to intercept or override. YUI lets you extend components in a classlike hierarchy, mix in new methods and properties, plug new behaviors into instances, and even inject arbitrary behavior before and after methods. In short, there is always a clean way to extend a YUI component instead of creating an unmaintainable mess.”

He highlights several other advantages of YUI and emphasizes that “YUI adheres to the bizarre, unfashionable philosophy that library code should, as much as possible, run as-is in a wide array of environments. This is actually a bit confusing to developers, who tend to assume that since there is no ‘YUI Mobile’ fork of the library, that must mean YUI doesn’t work on mobile devices. In fact, the YUI team tests all library code on a wide selection of mobile devices, and adds methods and synthetic events to help you abstract away differences between platforms. Likewise, YUI runs in a Node.js server environment as-is. There is no YUI Mobile Edition or YUI Tablet Edition or YUI Server Edition. There is just YUI.”

Goer concedes that many people use jQuery “to build beautiful pages every day” and likely would wonder why they should use YUI, instead.

“YUI,” he emphasizes, “focuses on keeping the complexity of web applications from spiraling out of control. Its key strengths are modularity and structure.”

Si Dunn