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


Make something new, with MakerBot or Raspberry Pi – #bookreview #programming #diy

O’Reilly has released two new books to help you get started with two hot new products: the MakerBot desktop 3D printer and the Raspberry Pi, a tiny, inexpensive computer the size of a credit card.

Here are short reviews of the two how-to guides:

Getting Started with MakerBot
Bre Pettis, Anna Kaziunas France & Jay Shergill
(O’Reilly –
paperback, Kindle)

The MakerBot 3D printer has captured worldwide attention for its ability to replicate objects such as game pieces, knobs and other plastic parts no longer available from manufacturers, and its use also to produce small art works.

“In our consumer-focused, disposable world, a MakerBot is a revitalizing force for all your broken things,” the authors state. (One of them, Bre Pettis, is one of MakerBot’s creators.)

The MakerBot machine, however, also can be a revitalizing force for artistic endeavors and, in some cases, dreams of self-employment. It is, after all, essentially a small factory in a box.

Getting Started with MakerBot introduces the machine and things you can make with it from your own designs or from designs downloaded from the web. “Though the underlying engineering principles behind a MakerBot are quite complex, in a nutshell, a MakerBot is a very precise, robotic hot glue gun mounted to a very precise, robotic positioning system,” the three writers point out.

In 213 pages, the book covers the basics, from history to set-up, and then shows you how to “print 10 useful objects right away.” It also introduces how to design your own 3D objects, using SketchUp, Autodesk 123D, OpenSCAD, and some other tools.

Getting Started with MakerBot is well-written, heavily illustrated, and organized to help you advance from unboxing a MakerBot to turning out products and creations and becoming a significant citizen of the “Thingiverse”—where “one must share designs…but all are welcome to reap the bounty of shared digital designs for physical objects.”


Getting Started with Raspberry Pi
Matt Richardson & Shawn Wallace
O’Reilly –
paperback, Kindle)

The Raspberry Pi “is meant as an educational tool to encourage kids to experiment with computers.” But many adults are latching to the tiny device as well, because it comes preloaded with interpreters and compilers for several programming languages, including Python, Scratch, C, Ruby, Java, and Perl. Its operating system is Linux Raspbian.

The Raspberry Pi is not plug-and-play, but it can be connected to – and control –a number of electronic devices. And the list of uses  for the microcomputer keeps growing.

Some owners have made their Raspberry Pi devices into game machines. Others have connected many of the units together to create low-budget supercomputers. Some are using them as web servers. And still others work at the  “bare metal” of a Raspberry Pi to create and test new operating systems. Intriguing new roles for the Raspberry Pi keep appearing, and the surge will continue as more adults and kids start working with the tiny but powerful device.

Getting Started with Raspberry Pi covers the basics of hooking up, programming and running the device. It also provides several starter projects, including how to use a Raspberry Pi as a web server or in other roles.

Once you know what you’re doing, “You can even create your own JSON API for an electronics project!” the authors promise.

The well-written book packs a lot of how-to information into its 160 pages, including working at the command line in Linux, learning to program the device, and creating simple games in Python and Scratch.

— Si Dunn

Exploring Everyday Things with R and Ruby – An entertaining & challenging guide to learning 2 languages – #programming #bookreview

Exploring Everyday Things with R and Ruby
Sau Sheong Chang
(O’Reilly, paperbackKindle)

Sau Sheong Chang has embarked joyfully on Mission Next-to-Impossible. With his new book, he wants to inspire everyone to recapture at least some of their childhood passion for exploring and discovering.

“For many professional programmers,” he writes, “coding is a job. It’s drudgery, low-level work that brings food to the table. We have forgotten the promise of computers and the power of programming for discovery. This book is an attempt to bring back that wonder and sense of discovery.”

His new book is indeed full of opportunities for exploration and discovery. If you have a basic understanding of computer programming, a playful curiosity, and a willingness to learn new things, you can have some real fun with this entertaining, well-written how-to guide.

Exploring Everyday Things with R and Ruby provides a basic introduction to both programming languages and shows how to use them in simulations that can create solutions to several practical problems.

A few examples:

  • You must set up a new office with 70 employees. How can you accurately determine the number of restroom stalls that will be needed?
  • How can you do data mining and pattern analysis within your own email, accumulated over years? (Caution: You may discover things about yourself that you haven’t yet realized.)
  • What is the process for building a homemade stethoscope and extracting useful data from a WAV file of your heartbeat?

Author of two previous books on Ruby, Sau Sheong Chang is director of applied research for HP Labs in Singapore. In this new work, he shows how to use “simulations to create experiments, isolate factors, and propose hypotheses to explain the results of the experiments.” And you learn how to work with both Ruby and R in the exercises.

In his view, “…Ruby is a programming language for human beings. Yukihiro “Matz” Matsumoto, the creator of Ruby, often said that he tried to make Ruby natural, not simple, in a way that mirrors life. Ruby programming is a lot like talking to your good friend, the computer. Ruby was designed to make programming fun and to put the human back into the equation for programming.”

Meanwhile, “R offers a powerful and appealing interactive environment for exploring data, and using that interactive environment is part of its appeal. The other reason why R is getting increasingly popular is that it is free [like Ruby]. The existing batch of tools for data analysis—S, MATLAB, SPSS, and SAS—can be quite expensive, and R is a cost-effective way to achieve the same goals. Also, R has a very vibrant and active community of domain experts and developers, including statisticians and data scientists who contribute many very useful packages that enhance its overall capabilities.”

The 233-page book is nicely organized and adequately illustrated. There are, however, two minor dings that may briefly irritate some beginners.

First, in his introduction to R, Sau Sheong Chang describes the virtues of using a graphics package known as ggplot2 and states that it will be used extensively in the book’s exercises. But he doesn’t, at that point, specifically instruct readers how to get it—install.packages(‘ggplot2’)—and verify that it has been downloaded and installed—installed.packages(). So a teaching moment is missed. Instead, you have to remember to turn back about 20 pages to the “Installing Packages” discussion and figure out that you now need to download ggplot2. (But that’s just part of “discovery,” it could be argued.)

Second, a few of the code examples in Chapter 2 require tedious amounts of command-line typing. You don’t get code you can download from the author’s site until Chapter 3—just a nitpick.

You won’t become an R or Ruby expert by reading Exploring Everyday Things with R and Ruby. But this excellent book can show you how to install the software, learn the basics of using it, and actually put it to work in some practical ways.

From there, you can launch your own journeys of exploration and discovery—and use R and Ruby as you go.

Si Dunn

Rails Recipes: Rails 3 Edition – Solutions to 70 Problems & More – #bookreview #in #rails #programming

Rails Recipes: Rails 3 Edition
Chad Fowler
Pragmatic Bookshelf, paperback, list price $35.00)

Chad Fowler’s Rails Recipes: Rails 3 Edition is aimed at developers who need to solve tough problems while using Rails. But Rails beginners also can learn plenty from the 70 “recipes” in this excellent guide.

The 280-page book is divided into seven parts. Busy Rails developers can jump directly to any part that deals with their latest vexation. Those new to Rails also can read the book in any “recipe” order, or they can take it straight through like a textbook.

The seven parts are:

  1. Database Recipes
  2. Controller Recipes
  3. User Interface Recipes
  4. Testing Recipes
  5. Email Recipes
  6. Big-Picture Recipes
  7. Extending Rails

The author uses a simple problem-solution approach. For example, in Recipe 28, the problem is: “You notice a recurring pattern in your application. You’re writing code for the same actions over and over again in your controllers.” The solution Fowler presents involves learning how to use the Rails versions of macros to create “code that writes codes for you….” by taking “advantage of Ruby’s metaprogramming capabilities.”

He then shows how, noting that “Ruby, like Lisp and Smalltalk before it, allows programmers to easily write code that writes and loads code at runtime.” He adds: “This is a really deep topic, and we’re not going to attempt to dig too deep into it here. Instead, we’ll focus on the details necessary to implement our own Action Controller macros.”

Each recipe spans only a few pages but is presented clearly and is well illustrated with code examples.

Anyone working with Rails or still adding it to their programming capabilities should consider getting Rails Recipes: Rails 3 Edition and keeping it within easy reach.

Si Dunn

Ride Some Rails with The Rails View – #bookreview #in #rails #programming

The Rails View: Create a Beautiful and Maintainable User Experience
John Athayde and Bruce Williams
(Pragmatic Bookshelf, paperback, list price $35.00)

Rails was created in 2004 “and the web discovered the MVC (model-view-controller) pattern in earnest, which brought a whole new level of productivity and fun to a world of developers and designers,” the authors of this “very ambitious” book declare.

They note that many books “provide a firm foundation for writing controllers and models (which benefit greatly from being written top-to-bottom in plain Ruby), but when it comes to views—that meeting place of Ruby, HTML, JavaScript, and CSS (not to mention developers and designers)—what’s a disciplined craftsman to do?”

Athayde and Williams have written this views-centric book to help “widen the discussion of Rails best practices to include solid, objective principles we can follow when building and refactoring views.”

They add: “Many developers are uneasy around the view layer” and frequently in a hurry to just get out of it, leaving it “easy for the view layer to become a no-man’s land that no one owns or adequately polices or a junkyard that no one feels safe to walk through.”

The 245-page book’s nine chapters are well-written and adequately illustrated with code examples, screen shots and other illustrations, including highlighted tips.

The book follows a structure where chapters build upon the content of the previous chapter. The chapters are:

  • Creating an Application Layout
  • Improving Readability
  • Adding Cascading Style Sheets
  • Adding JavaScript
  • Building Maintainable Forms
  • Using Presenters
  • Handing Mobile Views
  • Working with Email
  • Optimizing Performance

One of the appendices is titled “The Rails View Rules.” It is a handy list of 10 “rules of thumb” when doing development work.

The book is aimed mostly at designers working with Rails and Rails developers working in the view layer. But newcomers curious about Rails or just getting started with Rails can learn from it, too.

The Rails View was built on top of Rails 3.2.1 and Ruby 1.9.3 and should be compatible with future stable releases for quite some time,” the authors say.

If you try to use earlier versions, you may run into some problems, they caution. “Much of the content and code would need to be modified to work with some earlier versions due to our coverage of the Rails 3.1+ asset pipeline and use of the new Ruby 1.9 Hash literal syntax.”

Si Dunn