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

Advertisements

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

 

Book Brief – Programming Grails – A new, solid guide for experienced developers – #programming #bookreview

Programming Grails
Burt Beckwith
(O’Reilly – paperback, Kindle )

Burt Beckwith is an experienced core developer on the Grails software team at SpringSource. His new book, Programming Grails, is written primarily for experienced Grails developers “who want to dig deeper into the architecture and understand more about how Grails works its magic and how it integrates with Groovy, Spring, Hibernate, and other technologies.”

Beckwith adds that “[d]evelopers with experience in similar frameworks such as Spring MVC, JEE, or Ruby on Rails should find this book useful in understanding how Grails implements features to which they are accustomed.”

He cautions that Programming Grails “should not be your first Grails book, since it presumes a good deal of previous experience and understanding, so be sure to read a more comprehensive Grails book first.”

The 12-chapter, 344-page book focuses on the inner workings of the Grails 2.0 feature set and emphasizes “best practices for building and deploying Grails applications,” including topics such as “performance, security, scaling, tuning, debugging, and monitoring.” It is written clearly, and its text is kept reasonably short between topic headings. Numerous short code samples and other illustrations are included.

Grails’ creator, Graeme Rocher, has given this book a solid thumb’s up, stating that “it goes much deeper than any other Grails book I have seen.”

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

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

Learning Rails 3 – It’s not easy, but this good how-to guide definitely can help – #bookreview

Learning Rails 3
Simon St.Laurent, Edd Dumbill, and Eric J. Gruber
(O’Reilly,
paperbackKindle)

Ruby on Rails frequently is hailed as an “outstanding” or “powerful” or “amazing” tool for creating web applications.

But beginners often dive into it, quickly go off the rails, and give up in frustration.

“Building a Ruby on Rails application requires mastering a complicated set of skills,” the authors of Learning Rails 3 concede. Indeed, you may encounter several “problems and confusions” just getting everything installed, configured and running the right way.

Fortunately, Learning Rails 3 shows how to make the installation, configuration, and initial testing go fairly smoothly. I didn’t know (or understand) Rails and had only a smattering of Ruby experience. But I was able to accomplish an easy installation on a Windows XP machine, using railsinstaller.org. Then I was able to follow the instructions in Learning Rails 3 and get it all running.

Caution: Read and follow the book’s steps very carefully, in the correct order. Pay close attention to the text and code examples. At several different points, I glanced past a step or skipped an important character as I typed. And, no surprise, I ran into puzzling error messages or code failures until I backtracked and figured out what I had skipped. Also, a lot of stuff happens or appears to happen when you create a new Rails application or do some other tasks. Long lists of status notifications, warnings, and miscellaneous cryptic messages will stream by. But don’t panic.

“The only mandatory technical prerequisite for reading this book is direct familiarity with HTML and a general sense of how programming works,” the authors emphasize. “You’ll be inserting Ruby code into that HTML as a first step toward writing Ruby code directly, so understanding HTML is a key foundation.”

Once you get past the initial shock of installing Ruby on Rails, working at the command line, and modifying some bits of code deep within a few subdirectories, you will start discovering the power and possibilities of Rails.

If you’ve never worked with Ruby, the authors offer, in Appendix A, “An Incredibly Brief Introduction to Ruby.” (Appendix B is “An Incredibly Brief Introduction to Relational Databases,” and Appendix C provides “An Incredibly Brief Guide to Regular Expressions.”) You won’t need to be a Ruby expert; just have some basic knowledge of how to work it.

The remainder of the 387-page book is organized into 20 chapters:

  1. Starting Up Ruby on Rails
  2. Rails on the Web
  3. Adding Web Style
  4. Managing Data Flow: Controllers and Models
  5. Accelerating Development with Scaffolding and REST
  6. Presenting Models with Forms
  7. Strengthening Models with Validation
  8. Improving Forms
  9. Developing Model Relationships
  10. Managing Databases with Migrations
  11. Debugging
  12. Testing
  13. Sessions and Cookies
  14. Users and Authentication
  15. Routing
  16. From CSS to SASS
  17. Managing Assets and Bundles
  18. Sending Code to the Browser: JavaScript and CoffeeScript
  19. Mail in Rails
  20. Pushing Further into Rails

The book mercifully does not dump you head-first into the middle of Model-View-Controller (MVC) architecture. You begin by gently nibbling at its edges and using a few things you likely already know. Once you feel comfortable and can find your way around some of the subdirectories, then the real fun begins. The authors offer a rich array of how-to discussions, code examples, screen shots and “Test Your Knowledge” quizzes (with the answers conveniently available).

Learning Rails 3 is an excellent guide for Ruby on Rails newcomers. And those already working with Rails can learn from it, too.

Si Dunn