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

Learning Dart – A solid guide to basic development using Google’s Dart #programming language – #bookreview

Learning Dart

Learn how to program applications with Dart 1.0, a language specifically designed to produce better-structured, high performance applications 

Ivo Balbaert and Dzenan Ridjanovic

(Packt - Kindle, paperback)

 

The programming language Dart was introduced in late 2011 by Google as a potential replacement for aging JavaScript. But JavaScript, of course, has continued to spread all over the Internet and planet since it first appeared in 1995.

Not surprisingly, Google found itself getting some pushback from software developers and others who have a lot of time, education, sweat and money invested into creating, supporting and modernizing files that have .js extensions.

Dart today is billed as “a new platform for scalable web app engineering.” It is a long way from replacing JavaScript. Indeed, it compiles to JavaScript.

At the same time,  Dart is a good and powerful Open Source language. And, while it is not yet seen on most lists of top languages to know, it is gaining momentum and followers in the software world.

“Dart looks instantly familiar to the majority of today’s programmers coming from a Java, C#, or JavaScript/ActionScript background; you will feel at ease with Dart,” write the authors of Learning Dart.

“However, this does not mean it [Dart] is only a copy of what already exists; it takes the best features of the statically typed ‘Java-C#’ world and combines these with features more commonly found in dynamic languages such as JavaScript, Python, and Ruby. On the nimble, dynamic side[,] Dart allows rapid prototyping, evolving into a more structured development familiar to business app developers when application requirements become more complex.”

In their recent book,  Balbaert and Ridjanovic note this about Dart: “Its main emphasis lies on building complex (if necessary), high-performance, and scalable-rich client apps for the modern web.”

Likewise, they point out that  “Dart can also run independently on servers. Because Dart clients and servers can communicate through web sockets (a persistent connection that allows both parties to start sending data at any time), it is in fact an end-to-end solution. It is perfect on the frontend for developing web components with all the necessary application logic, nicely integrated with HTML5 and the browser document model (DOM).

“On the backend server side, it can be used to develop web services, for example, to access databases, or cloud solutions in Google App Engine or other cloud infrastructures. Moreover, it is ready to be used in the multicore world (remember, even your cell phone is multicore nowadays) because a Dart program can divide its work amongst any number of separate processes, called isolates, an actor-based concurrency model as in Erlang.”

Their well-written book, from Packt Publishing, delivers a structured and nicely paced overview of how to use the Dart programming language. The book is suited for inexperienced developers and experienced developers alike who are curious about, or ready to dig into, Dart .

The intended audience, the authors state, includes “…web application programmers, game developers, and other software engineers. Because of its dual focus (Dart and HTML5), the book can appeal to both web developers who want to learn a modern way of developing web applications, and to developers who seek guidance on how to use HTML5.”

Indeed, in the first chapter, you get more than the obligatory “Hello, World!” program. You also learn how to use the Eclipse-based Dart Editor to create some simple command-line and web applications.

From there, the 12-chapter work focuses on topics and software examples that range from variables, classes and libraries, to combining HTML forms with Dart, building games with HTML5 and Dart, developing business apps with Polymer web components, using Dart with MVC web and UI frameworks, working with local data and client-server communications, and creating data-driven web applications using Dart and MySQL or MongoDB.

I have tested some of the book’s code examples both on Linux and Windows machines and have enjoyed working with the Dart Editor. However, I did find a couple of code typos in the print version while hand-typing some of the shorter examples. The better choice is to download and use the book’s code examples found on the Packt website.

One other matter that some new Dartisans may encounter: Norton 360 antivirus software currently tends to throw dart.exe into quarantine on Windows machines–and that stops Dart cold. There is a fairly simple way to retrieve the file from quarantine and tell Norton 360 to let it run. However, check the Dart community page on Google+ for info on that and some other approaches to avoiding the problem.

Learning Dart was published soon after Dart 1.0 was released, and Dart has continued to evolve fairly quickly. (Its stable version was 1.4.3 at the time this was written.) So there will be some small differences in screen displays and other matters.

If you want to learn Dart and get up to speed for using it in application development, Learning Dart can be your handy and solid how-to guide.

Si Dunn

 ***

Ready to get Learning Dart? Click here: Kindlepaperback

CoffeeScript in Action – A pleasant, thorough, language-centered how-to guide – #programming #bookreview

 

CoffeeScript in Action

Patrick Lee

(Manning - paperback)

 

CoffeeScript compiles to JavaScript, that awkward, quirky mashup which remains–because of its central role in the World Wide Web–one of the world’s most heavily utilized programming languages.

When beginners first hear this about CoffeeScript, they often think: Ah, ha! I could learn that and skip having to learn JavaScript!

Nope. Sorry.

“CoffeeScript is not about avoiding JavaScript–it is about understanding JavaScript,” Patrick Lee writes in his comprehensive and pleasant new book, CoffeeScript in Action. “Learning CoffeeScript helps people to understand JavaScript.”

Lee notes: “CoffeeScript is a simple language, and there are two simple reasons for learning it. First, it fixes some problems in JavaScript that are unpleasant to work with. Second, understanding CoffeeScript will help you learn new ways of using JavaScript and new ways of programming in general.”

So, learn JavaScript and learn CoffeeScript. And, if you are hired to work with JavaScript, be very glad you took the time and effort to also learn CoffeeScript. It will come in handy.

CoffeeScript increasingly is being used to write complete applications. (Just one example: the CoffeeScript compiler used to be written in Ruby. Now it is implemented in CoffeeScript.) Likewise, CoffeeScript can work smoothly with Node.js and Ruby on Rails.

CoffeeScript is out there, and, increasingly, it is being put to work in the workaday world.

CoffeeScript in Action definitely lives up to its title. Lee’s book takes the reader from the foundations and basic building blocks of the language all the way to thoughts on the future of CoffeeScript as ECMAScript 5 and ECMAScript 6 keep bringing changes to JavaScript.

I have read and used several smaller books on CoffeeScript, including The Little Book on CoffeeScript and Jump Start CoffeeScript. These are good, and numerous other books are available. But if you want a reasonably deep understanding of CoffeeScript as a programming language, I recommend starting with, or moving up to, CoffeeScript in Action.

Patrick Lee says that his book “doesn’t try to comprehensively detail libraries, frameworks, or other ancillary matters. Instead, it concentrates only on teaching the CoffeeScript programming language from syntax, through composition, to building, testing, and deploying applications.”

The three-part, 13-chapter, 408-page (in print format) book offers dozens of short, concise code examples that illustrate such diverse aspects as objects, functions, mixins, tests, event loops, compiling, creating animations, using CoffeeScript with domain-specific languages, and deploying applications. The book also serves up some CoffeeScript cartoons, as well as practical illustrations for key points.

How long will JavaScript be around–and, with it, the impetus to learn CoffeeScript?

Lee contends that “you should count on it being around for a long time–long enough, at least, that it will probably outlast your career as a programmer.”

Si Dunn

 

Enterprise Application Development with Ext JS and Spring – (And a lot more!) – #programming #bookreview

Enterprise Application Development with Ext JS and Spring

Develop and deploy a high-performance Java web application using Ext JS and Spring

Gerald Gierer

(Packt Publishing paperback, Kindle)

A powerful JavaScript web framework such as Ext JS deserves a powerful platform for enterprise desktop application development. Gerald Gierer delivers a good one in his well-crafted new how-to book from Packt Publishing.

Gierer’s book is a bit unusual in today’s pare-it-down marketplace. It contains many before, during and after screen prints to illustrate the actions and outcomes of steps and commands. The 446-page book also has lengthy code listings that enable you to check and verify the outcomes of code changes you have made.

Ext JS and the Spring framework, however, are just a few of the packages that you work with as you set up your development tools and create, modify, expand, test and deploy a sample enterprise application (a task time tracker).

The other programs and tools include MySQL, the Java SE development kit (with the new Java API for JSON), NetBeans, Maven, Glassfish, and JUnit. And, with Ext JS, you learn to work with the Sencha Cmd tool and the Ext JS Software Development Kit (SDK).

But please note, particularly if you are new to some of this : You must pay careful attention to each paragraph as you load and configure software and as you keep building and enhancing your enterprise application.

In this book, it is easy start jumping from one screen print to the next, or from one code listing to the next, while skipping the intervening text. When you do, you can miss key steps that sometimes are buried without highlights in the wording.

This was my first time to work with some of the required software packages, so I had to force myself to really slow down and pay close attention to each paragraph, as well as each graphic.  My initial development attempt went off the rails when I discovered, more than 100 pages into the book, that I had misconfigured a couple of tables, skipped a couple of data changes, and generally screwed up the database. And, being new to some of the software, I couldn’t figure out to repair everything. So I simply started over from scratch and this time moved carefully from one page to the next, closely checking code entries and the book’s text before clicking “Enter.” That made all the difference in my results.

If you are looking to do enterprise application development with a JavaScript framework, definitely consider Ext JS and definitely consider Gerald Gierer’s fine Enterprise Application Development with Ext JS and Spring.

And definitely take your time as you work your way through his book.

Si Dunn

Rapid Android Development – Using Processing to build apps fast – #programming #bookreview

Rapid Android Development

Build Rich, Sensor-Based Applications with Processing
Daniel Sauter
(Pragmatic Bookshelfpaperback)

The main goal of Daniel Sauter’s nicely written new book is to help you learn “how to develop interactive, sensor-based Android apps” quickly.

At first glance, you may question how “quickly” you can go through 13 chapters with a total of 363 pages, including the index.

But there’s good news here, particularly if you are not a patient programmer. The book is divided into five parts, all structured to serve as “self-contained mini-courses.” And the author has geared his text toward six semi-specific categories of readers.

Sauter, by the way, is an artist and educator with some eight years’ experience teaching Processing. Processing is a free “award-winning, graphics-savvy” programming language and development environment that can be used to work with Android devices and software.

Let’s go to the six reader categories first. Rapid Android Development is aimed at:

  1. Readers with at least “a basic understanding of programming concepts….”
  2. Intermediate Processing users “looking to create Android apps from within the Processing IDE….”
  3. “Educators who teach courses on mobile technologies” and need “a free tool that does not require developer licenses or subscriptions.”
  4. Java and Android developers who want to use Processing to leverage “a host of libraries for productivity gains.” (Java developers will quickly see that Processing builds on Java.)
  5. JavaScript and Web developers who want to use Processing.js syntax to help them create “JavaScript-powered web applications that can run inside browsers without plugins or other modifications. Processing.js also takes advantage of WebGL hardware acceleration.”
  6. Arduino users and hobbyists, particularly those “interested in adapting Android phones or tablets for use as sensing devices, controllers, or graphics processors.”

Now let’s look at the five parts of Rapid Android Development.

  • Part I focuses on installing Processing and the Android SDK but also looks at touch screens and Android sensors and cameras.
  • Part II is devoted to “working with the camera and location devices found on most Androids.”
  • Part III’s emphasis is on peer-to-peer networking, including Wi-Fi, Bluetooth and Wi-Fi Direct, plus Near Field Communication (NFC), which is “expected to revolutionize the point-of-sale industry,” Sauter notes.
  • Part IV “deals with data and storage,” he adds, “as all advanced apps require some sort of data storage and retrieval to keep user data up-to-date.”
  • Part V examines 3D graphics and cross-platform apps.

You will need several software tools and at least one Android device to work with the code examples in this book. (The book lists several Android phones and tablets that have been tested with the code examples, which are available online.)

If you want to do some work in Part III, you will need at least two Android devices (so your peer can have a peer). And if you have absolutely no programming experience, you should get some first. Sauter, an associate professor of New Media art at the University of Illinois–Chicago School of Art and Design, offers some suggestions for good sources.

His new book seems a bit light on illustrations. But its well-displayed, well-explained code examples and clear how-to paragraphs keep the reader moving and making progress.

If you are a creative coder looking for some new skills, projects and challenges, check out Rapid Android Development, ASAP.

Si Dunn 

Instant Handlebars.js – A short but effective how-to guide – #programming #bookreview

Instant Handlebars.js

Learn how to create and implement HTML templates into your projects using the Handlebars library
Gabriel Manricks
(Packt Publishing – e-book, paperback)

“Short, fast, and focused.” These are the three promises offered for Gabriel Manricks’ new book, Instant Handlebars.js, from Packt Publishing. And, at just 62 pages in print format, it lives up to those vows.

Manricks explains and demonstrates Handlebars using five well-structured sections. First, he introduces Handlebars.js and describes what a templating engine is and does. He notes that “[t]he purpose of using a templating engine such as Handlebars is to generate some kind of viewable content (usually HTML pages), dynamically.” He then shows how to download the Handlebars library and create a “Hello {{name}}” template and a simple helper.

His “Top 6 Features you need to know about” section goes to the heart of Handlebars.js and shows how you can organize large projects and pre-compile templates.

The Top 6 topics include: (1) Expressions—“the core of templates”; (2) Helpers—“[t]hese are where Handlebars gets its extendibility”; (3) Partials—“the building blocks of the template world” and important for modular design; (4) Structuring a Handlebars app—the pros and cons of various potential structures; (5) Pre-compilation—which can lead to “a more optimized and efficient site”; and (6) Logging and comments—“writing clear and debug-able templates and helpers, so you can easily test and maintain them in the future.”

In the book’s final section, “People and places you should get to know,” Manricks describes some individuals and websites you should follow so you can “stay up to date and dive deeper into the Handlebars community.”

Despite its small page count, the book contains numerous short code examples that show how to put Handlebars.js to work in HTML files.

You need at least some modest experience with JavaScript and HTML to get full benefit from this book. You also will make brief use of Node.js to install Handlebars.js.

If you have done any work with Ember.js, you already have picked up some Handlebars.js experience. However, even here, this short, handy guide can help you get a better understanding of how to use Handlebars, with or without Ember.

Instant Handlebars.js can be ordered in e-book or paperback format direct from Packt Publishing’s website. Or, the Kindle version and the paperback can be ordered via Amazon.

Si Dunn

Functional JavaScript – Applying functional techniques and Underscore.js – #programming #bookreview

Functional JavaScript
Introducing Functional Programming with Underscore.js
Michael Fogus
(O’Reilly – paperback, Kindle)

When I first started tinkering with JavaScript, object-oriented programming (OOP) was the rage, and JavaScript frequently was touted as one of the key object-oriented languages. After all, according to many online descriptions, almost everything within JavaScript “is OO.”

Now, in this enjoyable new book, JavaScript is hailed as a functional programming language. Of course, functional programming recently has been the rage in many programming circles. And “enjoyable” may seem an odd word to attach to a software text. Yet, it fits. Michael Fogus shows here that he is a technical writer who can be entertaining, effective and well-organized.

“This book,” he states, “is not about spewing dogma regarding the virtues of functional programming. I think there are many functional techniques that offer ways to rein in the complexities of software development, but I realize that at times, there are better ways to implement any given individual part.”

It is possible, of course, to debate object-oriented vs. functional JavaScript until the digital cows are called back home and put into infinite loops. But, for those who don’t know or care much about the differences, here are some basic views.

The Mozilla Developers Network (to simply pick  one example) discusses objected-oriented JavaScript on its site and declares: “Object-oriented programming may be seen as the design of software using a collection of cooperating objects, as opposed to a traditional view in which a program may be seen as a collection of functions, or simply as a list of instructions to the computer. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent little machine with a distinct role or responsibility.”

Meanwhile, HaskellWiki offers this explanation of functional programming: “In functional programming, programs are executed by evaluating expressions, in contrast with imperative programming where programs are composed of statements which change global state when executed. Functional programming typically avoids using mutable state.

“Functional programming requires that functions are first-class, which means that they are treated like any other values and can be passed as arguments to other functions or be returned as a result of a function. Being first-class also means that it is possible to define and manipulate functions from within other functions.”

Some of the programming languages typically labeled “functional” include Clojure, OCaml, Erlang,  Haskell, Scala, and F#.

Here is how Michael Fogus defines functional programming:

“As a bare-bones introduction, functional programming can be described in a single sentence:

Functional programming is the use of functions that transform values into units of
abstraction, subsequently used to build software systems.

“This is a simplification bordering on libel,” he continues, “but it’s functional (ha!) for this early stage in the book. The library that I use as my medium of functional expression in JavaScript is Underscore, and for the most part, it adheres to this basic definition.”

(Underscore.js can be obtained from http://underscorejs.org and imported into “the applicable project directories.”)

Fogus refuses, in his text, “to create a false dichotomy and say that functional and object-oriented styles should stand in opposition.” Indeed, he notes that JavaScript supports both models and “systems can and should be composed of both models.”

He also points out that JavaScript can be used with other paradigms, including imperative programming, prototype-based object-oriented programming, and metaprogramming.

“In no way does this book represent even a modicum of original thinking regarding functional programming in JavaScript,” he states. Yet, it is a worthy effort.

It is well written, smoothly organized, and nicely illustrated with short code examples and helpful diagrams. And Fogus notes that JavaScript does have “[l]anguage oddities, unsafe features, and a sea of competing libraries” that raise concerns when it is selected for a project. Functional programming, he contends, can be one way to help ensure that JavaScript “can be not only safe, but also simple to understand and test, in addition to being proportionally scalable to the size of the code base.”

Here is the chapter lineup for Fogus’s 237-page book:

  • Chapter 1. Introducing Functional JavaScript
  • Chapter 2. First-Class Functions and Applicative Programming
  • Chapter 3. Variable Scope and Closures
  • Chapter 4. Higher-Order Functions
  • Chapter 5. Function-Building Functions
  • Chapter 6. Recursion
  • Chapter 7. Purity, Immutability, and Policies for Change
  • Chapter 8. Flow-Based Programming
  • Chapter 9. Programming without Class

Functional JavaScript is a winner on at least two counts: (1) as a how-to text for long-time JavaScript programmers wishing to learn more about functional programming; and (2) as a how-to text for long-time functional programmers desiring to learn more about JavaScript.

The book is not recommended for JavaScript newcomers who are still at the level of typing console.log(“The answer to everything in the universe is 42″). However, experienced beginners can learn from it, and so can those of us who just tinker with JavaScript periodically and use it mainly to work with Node.js, Backbone.js, Ember.js, CoffeeScript, HTML and other choices.

Si Dunn

The Modern Web: Multi-Device Web Development with HTML5, CSS3, and JavaScript – #bookreview

The Modern Web
Multi-Device Web Development with HTML5, CSS3, and JavaScript
Peter Gasston
(No Starch Press – Kindle, paperback)

After a quick first glance, you might look right past this book. You might assume its title, “The Modern Web,” simply introduces some kind of heavily footnoted, academic study of the Internet.

Not so, Web breath. In this case, it’s the subtitle that should grab your attention.

Whether you hope to go into web development, or you’re already there, Peter Gasston’s new book can help you get an improved grasp on three important, device-agnostic tools that will be essential to your work and career development. They are: HTML5, CSS3, and JavaScript, that not-so-simple programming language that many new web specialists often try to avoid learning. (That’s because, typically, it’s easier, more fun and a bit less cryptic to work with HTML5 and CSS3.)

Also, Gasston notes, there have been big explosions in the number of libraries and frameworks that use JavaScript, further clouding a developer’s ability to know which ones he or she should learn next. (The author limits his coverage to four: jQuery, YepNope, Modernizr, and Mustache.)

Gasston’s well-written book zeroes in on the three “web technologies that can be used anywhere, from open websites to device-specific web apps.” And on all sorts of devices, ranging from tiny phones to tablet computers to wall-covering HDTVs.

And his teaching aim is to show you “modern coding methods and techniques that you can use to build websites across multiple devices or that are tailored to the single device class you’re targeting.”

By the way, “websites” is simply a shorthand term the author uses “to avoid repetition. The features you’ll learn from this book are relevant to websites, web applications, [and] packaged HTML hybrid applications–in short, anything that can use HTML, CSS, and JavaScript.”

Gasston also wants you to learn that “fast” is the main thing that matters to those who will use your site. “Your site needs to be fast–and feel fast–regardless of the device it’s being displayed on,” he emphasizes. “And fast means not only technical performance (which is incredibly important) but also the responsiveness of the interface and how easily users can navigate the site and find what they need to complete the task that brought them to you in the first place.”

His 243-page book contains many short, useful code examples and illustrations, and is excellent for developers who have at least a little bit of experience with HTML5, CSS3, and JavaScript but aren’t sure where and how to focus their energies and attention for the rapidly changing career road ahead.

The Modern Web offers a well-organized introduction, plus 11 chapters:

  1. The Web Platform
  2. Structure and Semantics
  3. Device Responsive CSS
  4. New Approaches to CSS Layouts
  5. Modern JavaScript
  6. Device APIs
  7. Images and Graphics
  8. New Forms
  9. Multimedia
  10. Web Apps
  11. The Future

There also are two appendices: Browser Support as of March 2013 and Further Reading.

Peter Gasston has been a web developer for more than 12 years, and his previous book is The Book of CSS3.

He notes that “[t]he Web is constantly evolving, and book publishing means taking just a single snapshot of a moment. Some things will change; some will wither and be removed. I’ve tried to mitigate this by covering only technologies that are based on open standards rather than vendor-specific ones and that already have some level of implementation in browsers.”

He urges developers to stay alert to changing Web standards and to “be curious, be playful, keep on top of it all. He stresses: “There’s never been a more exciting time to work in web development, but you’ll need to put in an extra shift to really take advantage of it.”

Si Dunn

Jump Start Sinatra – With this book and a little Ruby, you can make Sinatra sing – #programming #bookreview

Jump Start Sinatra
Get Up to Speed with Sinatra in a Weekend
Darren Jones
(SitePoint – Kindle, Paperback)

Many Ruby developers love Rails for its power and capabilities as a model-view-controller (MVC) framework. But some of them don’t like Rails’ size, complexity, and learning curve.

Meanwhile, many other Rubyists love Sinatra for its simplicity and ease of learning, plus its ability “to create a fully functional web app in just one file,” says Darren Jones in his new book, Jump Start Sinatra. “There are no complicated setup procedures or configuration to worry about. You can just open up a text editor and get started with minimal effort, leaving you to focus on the needs of your application.”

Jones does not temper his enthusiasm for Sinatra, adding that “there isn’t a single line of bloat anywhere in its source code, which weighs in at fewer than 2,000 lines!”

His 150-page book covers a lot of ground, from downloading and installing Sinatra to building websites, working with SQLite, Heroku, Rack, jQuery, and Git, and even using some CoffeeScript (to avoid “getting our hands dirty writing JavaScript…”). He also shows how to create modular Sinatra applications that use separate classes.

“Sinatra makes it easy–trivial almost–to build sites, services, and web apps using Ruby,” the author states. “A Sinatra application is basically made up of one or more Ruby files. You don’t need to be an expert Rubyist to use Sinatra, but the more Ruby you know, the better you’ll be at building Sinatra apps.”

Jones adds: “Unlike Ruby on Rails, Sinatra is definitely not a framework. It’s without conventions and imposes no file structure on you whatsoever. Sinatra apps are basically just Ruby programs; what Sinatra does is connect them to the Web. Rather than hide behind lots of magic, it exposes the way the Web works by making the key concepts of HTTP verbs and URLs an explicit part of it.”

Jump Start Sinatra is a well-written, appropriately illustrated guide to getting started with this popular free software. Ruby newcomers may wish for a few more how-to steps or code examples. But the counter argument is, if you’re brand-new to Ruby, save Sinatra for later; focus on getting learning Ruby first. 

Darren Jones does not buy into a common assessment that’s often heard when developers are asked their views of Rails vs. Sinatra. “Opinions abound that Sinatra can only be used for small applications or simple APIs, but this simply isn’t true,” he argues. “”While it is a perfect fit for these tasks, Sinatra also scales impressively, demonstrated by the fact that it’s been used to power some big production sites.”

Some of those “big production sites,” according to Wikipedia, include such notables as Apple, LinkedIn, the BBC, the British government, Heroku, and GitHub.

Si Dunn

Four good books that can help boost your JavaScript skills – #programming #bookreview

Ready for some enlightenment that can boost your JavaScript programming skills?

O’Reilly recently has published four books that can help you move from basic JavaScript library user to confident, experienced developer. 

“JavaScript started out as a simple and approachable front-end scripting language,” the publisher notes. “It has matured into a true cross-platform environment targeted by the latest emerging languages, frameworks, and developer tools.” The four new JavaScript books can help you “[l]earn how you can get the ultimate in responsiveness and interactivity from JavaScript, whether you use it on the front-end or server-side.” 

The four books are: JavaScript Enlightenment and DOM Enlightenment, both by Cody Lindley; Learning from jQuery by Callum Macrae; and Testable JavaScript by Mark Ethan Trostler.

#

JavaScript Enlightenment
Cody Lindley
(O’Reilly – paperback, Kindle)

Short, clear code samples are the stars of this fine, informative book. And most of the code samples can be viewed, executed and modified online using file links provided for the jsFiddle.net website.

The book’s goal is “to give the reader an accurate JavaScript worldview through an examination of native JavaScript objects and supporting nuances: complex values, primitive values, scope, inheritance, the head object, etc.” Cody Lindley adds: “I intend this book to be a short and digestible summary of the ECMAScript 3 Edition specification, focused on the nature of objects in JavaScript.”

Lindley keeps that promise in his 147-page book. His code samples rarely span more than a half page, and his explanatory paragraphs also are taut and to the point.

For example: “In JavaScript, objects are king: Almost everything is an object or acts like an object. Understand objects and you will understand JavaScript. So let’s examine the creating of objects in JavaScript….An object is just a container for a collection of named values (a.k.a properties).” 

Lindley’s book covers six of the nine native object constructors that are pre-packaged with JavaScript. The six are: Number(); String(); Boolean(); Object(); Array(); and Function(). He skips Date(), Error(), and RegEx() “because, as useful as they are, grasping the details of these objects will not make or break your general understanding of objects in JavaScript.” But he does hope you will learn them later, on your own. 

“JavaScript,” he writes, is mostly constructed from just these nine objects (as well as string, number, and boolean primitive values.) Understanding these objects in detail is key to taking advantage of JavaScript’s unique programming power and language flexibility.”

 # 

DOM Enlightenment
Cody Lindley
(O’Reilly – paperback, Kindle)

If you work with JavaScript, you probably rely on a Document Object Model (DOM) library such as jQuery to help you handle HTML scripting. 

But you can script the DOM without a DOM library, using JavaScript. Cody Lindley shows how in this excellent guide aimed at two types of developers who have experience with JavaScript, HTML, and CSS.

“The first developer is someone who has a good handle on JavaScript or jQuery, but has really never taken the time to understand the purpose and value of a library like jQuery,” Lindley writes. “The second type of developer is an engineer who is tasked with scripting HTML documents that will only run in modern browsers or that will get ported to native code for multiple OSes and device distributions (e.g., PhoneGap) and needs to avoid the overhead (i.e., size or size versus use) of a library.”

He notes that “HTML documents get parsed by a browser and converted into a tree structure of node objects representing a live document. The purpose of the DOM is to provide a programmatic interface for scripting (removing, adding, replacing, eventing, and modifying) this live document.”

Much of his 161-page DOM Enlightenment  focuses on how to work in JavaScript with “the most common types of nodes…one encounters when working with HTML documents.” He purposefully has “left out any details pertaining to XML or XHTML.” And, to help keep the book small, he has “purposely excluded the form and table APIs,” but adds: “I can see these sections being added in the future.”

Lindley also imposes a key technical limitation on the “content and code in this book….” It was, he says, “written with modern browsers (IE9+, Firefox latest, Chrome latest, Safari latest, Opera latest) in mind.”  

In keeping with the goals of O’Reilly’s Enlightenment series, explanations are short and concise and code examples are kept small. Also, the code examples are available online and can be displayed, run, and modified at the jsFiddle.net website.

 Cody Lindley emphasizes that he is “not promoting the idea of only going native when it comes to DOM scripting….” He hopes, instead,  “that developers may realize that DOM libraries are not always required when scripting the DOM.”

#

Learning from jQuery
Callum Macrae
(O’Reilly – paperback, Kindle)

Some developers work comfortably with jQuery yet have only a modest understanding of JavaScript.

Callum Macrae’s concise, well-written new book is intended to help fill that gap. It is “targeted at developers who know jQuery, but who don’t feel comfortable in their JavaScript knowledge or would just like to know more.”

The 102-page book focuses on the JavaScript code that jQuery covers up. It offers five chapters and two appendixes, with many short code examples and other illustrations. Much of the code is available through a GitHub repo.

Chapter 1, “Event Handling,” explains how event handling works in JavaScript and notes that “[e]vents are the heart of pretty much all web applications….jQuery provides a suite of functions to make event handling considerably easier than in JavaScript alone.” But these functions “add overhead and remove control from you, the developer. For this reason, it is important to know how you can handle events without jQuery in pure JavaScript.”

Chapter 2 covers “Constructors and Prototypes.” Writes Macrae: “Constructors are a way of creating objects, and can be initiated via the new keyword. Prototypes are one of the more powerful features of JavaScript, and allow the developer to declare a method or property that all instances of an object will inherit.” The chapter also can “help you understand how jQuery works, as jQuery itself uses prototypes.” 

Chapter 3 deals with “DOM Traversal and Manipulation.” Macrae notes that “jQuery includes a number of functions that make working with the DOM a lot easier than with JavaScript alone, which can be pretty ugly. However, the functions provided by jQuery can be rather hefty (especially in older browsers), and it is often a lot faster to just use pure JavaScript. Therefore, it is important to know how to work both.”

Chapter 4, “AJAX,” covers jQuery’s AJAX functions and concedes that they “offer some significant improvements over the native JavaScript AJAX features, as they are a lot easier to use.” Macrae explains: “AJAX is the act of making an HTTP request from JavaScript without having to reload the page; you could think of it as an inline HTTP request.” The chapter shows some jQuery AJAX requests and how those AJAX requests are sent in JavaScript. The goal is to help you get better at debugging code and also realize that “it isn’t worth loading the entire jQuery library to send a few requests and nothing else….”

Chapter 5, “JavaScript Conventions,” explains some “common conventions that you can use to improve your JavaScript…such as making your code more readable by using comments and whitespace correctly, optimizing your code in order to improve performance, design patterns, and some common antipatterns (code that causes more problems than it solves.)”

 This book is not recommended for persons who have no jQuery or JavaScript experience. Still, Appendix A, “JavaScript Basics,” provides a 28-page introduction to JavaScript, starting at “Hello World!” Appendix B, meanwhile, describes several applications and websites that can help you improve your JavaScript knowledge.

 # 

Testable JavaScript
Mark Ethan Trostler
(O’Reilly – paperback, Kindle)

“You have to test your code,” Mark Ethan Trostler emphasizes, “so why not make the process as easy and painless as possible?”

That’s a very desirable goal. Yet, as he notes a few sentences later, “testing–especially JavaScript testing–is complicated.”

For example: “Client-side JavaScript is especially difficult to test properly, as we have very little control over the environment within which our code runs. Multiple operating systems, multiple versions of operating systems, multiple browsers, multiple versions of browsers, not to mention plug-ins, extensions, different languages, zoom levels, and who knows what else, all conspire to hinder the performance of our applications. These permutations slow down, break, crash, and eat our applications for lunch. It’s a jungle out there!”

Trostler, a software engineer who works in test at Google, says his book “attempts to bridge the gap between sane development practices and JavaScript. JavaScript is a weird little language.” And he has aimed his guide at “people who encounter JavaScript professionally. Beginning, intermediate, or guru-level developers are all welcome, as this book has something for everyone.”

His 250-page how-to guide is structured into eight chapters that “tackle testable code in several steps. First we will investigate complexity. Then we will look at an architecture choice that attempts to limit complexity and coupling. With that as our foundation,” Trostler continues, “we will move on to testing, both at the functional level and at the application level.” From there, he delves into: code coverage; integration, performance, and load testing; debugging; and using automation in tests.

 “Writing unit tests for client-side JavaScript can be daunting,” Trostler states. “That means too many people don’t do it. This is not OK…”

Testable JavaScript is well written and rich with code examples, screenshots, diagrams and other illustrations. Whether you write client-side or server-side JavaScript — or both — or you are trying to rework some legacy files, Mark Ethan Trostler’s text can help you learn how to better create and maintain testable code.

Si Dunn