The Well-Grounded Rubyist, 2nd Edition – A solid, well-written, updated guide to the Ruby programming language – #bookreview

 

black3_cover150

The Well-Grounded Rubyist

David A. Black

(Manning – paperback)

Ruby, predominately known as an object-oriented programming language, shows up frequently on lists of the top ten (or whatever) languages to know. And Ruby has long been paired with Rails to create the popular Ruby on Rails web application framework.

When the forerunner of this book appeared eight years ago, it was titled Ruby for Rails: Ruby Techniques for Rails Developers. And R4R, as it is sometimes known, was well received in both the Ruby and Rails camps.

In 2009, the R4R book was revised and retitled The Well-Grounded Rubyist. “This new edition is  a descendant of R4R but not exactly an update. It’s more of a repurposing,” the author, David A. Black, noted at the time. “The Well-Grounded Rubyist is a ‘just Ruby’ book, and it’s written to be read by anyone interested in Ruby.”

That focus continues in this second edition, which has been updated to cover Ruby 2.1. Ruby newcomers can get started and advance quickly with this fine “just Ruby” book in hand. Ruby veterans also can use it to gain new knowledge and sharpen familiar skills.

Black approaches the process of explaining Ruby “as a kind of widening spiral, building on the familiar but always opening out into the unknown.”

His well-written text does not try to be a “complete” language reference. Instead, reading The Well-Grounded Rubyist is like having a well-experienced and patient mentor close at hand–a mentor who willingly offers up clear examples and explanations. You likely will want to keep this book around as a go-to how-to reference long after you have learned and begun to work with Ruby.

It does help to have at least a little experience with programming before you tackle Ruby and this book. And, if you already have an older version of Ruby installed on your computer, upgrade it to 2.1.x. (As this review is being written, 2.1.2 is the current version.)

Yes, Ruby can be used in several different programming paradigms, including functional and imperative. But The Well-Grounded Rubyist is essentially all-object-oriented-all-the-time in its approach.

“Ruby is an object-oriented language, and the sooner you dive into how Ruby handles objects, the better,” Black states. “Accordingly, objects will serve both as a way to bootstrap the discussion of the language (and your knowledge of it) and as a golden thread leading us to further topics and techniques.”

Si Dunn

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

 

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

Deploying Rails – A good how-to guide covering choices, tools & best practices – #programming #bookreview

Deploying Rails: Automate, Deploy, Scale, Maintain, and Sleep at Night
Anthony Burns and Tom Copeland (Pragmatic Bookshelf, paperback)

Maybe you have been studying Ruby and Rails and now feel ready for the next big step. Perhaps you are already on a job where a Rails application needs to be deployed and running on a server ASAP. Or, maybe you manage a team that must deploy and support a Rails app, and you want to understand more of what they actually must accomplish to get the app up and running – and keep it running.

Deploying Rails is a very good guide to the decisions that must be made and to the tools and best practices essential for success. The two writers are both professional Rails developers with strong backgrounds.

Their 217-page book, they note, “is “centered around an example social networking application called MassiveApp. While MassiveApp may not have taken the world by storm just yet, we’re confident that it’s going to be a winner, and we want to build a great environment in which MassiveApp can grow and flourish. This book will take us through that journey.”

That “journey” is organized into 10 chapters and two appendices, all well written and illustrated with code examples.

  • Chapter 1: Introduction – (including choosing a hosting location)
  • Chapter 2: Getting Started with Vagrant – (setting up and managing a virtual server and virtual machines)
  • Chapter 3: Rails on Puppet – (“arguably the most popular open source server provisioning tool.…”)
  • Chapter 4: Basic Capistrano – (“the premier Rails deployment utility….”)
  • Chapter 5: Advanced Capistrano – (deals with making deployments faster and also easier when “deploying to multiple environments.”)
  • Chapter 6: Monitoring with Naigos – (monitoring principles and how to apply them to Rails apps. Also, how to perform several types of checks.)
  • Chapter 7: Collecting Metrics with Ganglia – (how to gather a Rails app’s important metrics from an infrastructure level and an application level.)
  • Chapter 8: Maintaining the Application – (how to handle “the ongoing care and feeding of a production Rails application.”)
  • Chapter 9: Running Rubies with RVM – (using the Ruby enVironmental Manager [RVM] in development and deployment.)
  • Chapter 10: Special Topics – (“We’ll sweep through the Rails technology stack starting at the application level and proceed downward to the operating system, hitting on various interesting ideas as we go.”)

The two appendices cover (1) “a line-by-line review of a Capistrano deployment file” and (2) “deploying MassiveApp to an alternative technology stack consisting of nginx and Unicorn.”

A key focus of the book is building a set of configuration files and keeping the latest versions stored in Git, so deployment of a new or updated app can go smoother.

Deploying a Rails app involves making many different choices, and the process can go wrong quite easily if not set up properly.

“The most elegant Rails application,” the authors caution, “can be crippled by runtime environment issues that make adding new servers an adventure, unexpected downtime a regularity, scaling a difficult task, and frustration a constant.

“Good tools do exist for deploying, running, monitoring, and measuring Rails applications, but pulling them together into a coherent whole is no small effort.”

Deploying Rails can significantly ease the complicated process of getting a new Rails application running on a server. Equally important, Rails experts Anthony Burns and Tom Copeland can show you how to keep the app running smoothly and configured for growth as it gains users, functionality, and popularity.

Si Dunn

Build Awesome Command-Line Applications in Ruby – #programming #bookreview

Build Awesome Command-Line Applications in Ruby
David Bryant Copeland
(Pragmatic Bookshelf,
paperback)

The word “awesome” now is grossly overused in contemporary culture. And I hate it in book titles.

That being said, Build Awesome Command-Line Applications in Ruby is an excellent how-to guide, particularly if you have a little bit of UNIX and some basic Ruby programming in your background.

The book is “aimed at both developers and system administrators who have some familiarity with Ruby and who find themselves automating things on the command line (or wish they could),” David Bryant Copeland writes. And he adds: “Writing command-line apps in Ruby is also a great way to really learn Ruby and become a better programmer, since you can apply it directly to your day-to-day tasks.”

Mac and Linux users will have the easiest time with this book’s code examples. Things get a little bit more complicated for Windows users, especially those with no UNIX experience and not much programming background, either. The author, fortunately, lays out some workarounds.

For example, on UNIX systems, the first line of code commonly is called the shebang. In a piece of Ruby code, the shebang might look something like this: #!/usr/bin/ruby. (That example tells where the Ruby interpreter is installed.) But, at a Windows command prompt, if Ruby has been installed correctly and is in the path, the # character simply will be interpreted as the start of a comment line, and the rest of the shebang will be ignored when code is run directly, such as: ruby hello_world.rb.

In this book, David Bryant Copeland’s focus definitely is code. “There is a lot of code,” he says, “and we’ll do our best to take each new bit of it step by step.” As the book progresses, two command-line applications are developed, enhanced, and improved. One is a database-backup app, and the other is a command suite, “an app that provides a set of commands, each representing a different function of a related concept.”

This is not a Ruby primer, so get some experience in that language first before tackling this book. But if you are now reasonably comfortable with Ruby coding on a graphical user interface (GUI) and want some new challenges, consider moving to the command line and use this excellent book as your guide.

The requirements are minimal: a free Ruby download and a text editor or a UNIX-like shell. But the payoff is very good.

In his 10 chapters, the author discusses and illustrates “every detail of command-line application development, from user input, program output, and code organization to code handling, testing, and distribution” while the two example applications are created, tested, and enhanced.

There is plenty to learn, and Build Awesome Command-Line Applications in Ruby does a fine job of  leading you through the process in short-chapter steps.

Si Dunn