Elixir in Action: A good guide to the ‘alternative language for the Erlang virtual machine’ – #programming #bookreview

 

 

Elixir in Action

Saša Jurić

Manning – paperback

“Elixir,”  Saša Jurić writes, “is a modern functional programming language for building large-scale, distributed, fault-tolerant systems for the Erlang virtual machine.”

What Elixir really is, of course, is a breath of fresh air for software developers who find it hard or confusing to work with Erlang’s sometimes complicated syntax and conventions.

Erlang has long been almost off the chart–the bottom of the chart–when computer languages are stacked up by popularity.  It began its oddball life in the 1980s as a programming language for the computers in telephone switching systems, specifically Swedish-made, Ericsson telephone switching systems.

Indeed, I first encountered Erlang in the  late 1980s while trying to help Ericsson sell Swedish-made computers to American banks. Back then, I counted my lucky stars that I didn’t have to learn it, because I was a tech writer, not a software developer.

Today, however, Erlang and its Open Telecom Platform (OTP) libraries are gaining new converts among serious practitioners of functional programming. Many of them likewise are drawn to Erlang’s built-in support for concurrency, distribution and fault tolerance.

The digital Swedish meatball known as Erlang turns out to be a powerful choice for providing high reliability and scalability to networked and distributed systems with multi-core processors. Telephone networks require high reliability and flexible scalability. And Erlang was designed to help provide both — without limiting itself to telecom systems.

Some of Erlang’s lack of popularity can be blamed on the language’s somewhat difficult learning curve. But it also has not been heavily promoted to software developers. That has been changing recently as companies and developers learn more about Erlang’s good track record, Saša Jurić points out.

“It powers various large systems and has been doing so for more than two decades, such as the WhatsApp messaging application, the Riak distributed database, the Heroku cloud, the Chef deployment automation system, the RabbitMQ message queue, financial systems, and multiplayer backends. It’s truly a proven technology.”

In Elixir in Action,  Saša Jurić nicely meets his goal of writing a book that brings “programmers new to Elixir and Erlang to the point where they can develop complex systems on their own.” Elixir provides an alternative language based on several other languages, including Ruby and Clojure, as well as Erlang.

Jurić’s how-to guide requires no prior experience with either Erlang or Elixir, but you should be familiar with at least one other programming language, such as JavaScript, C# or Ruby.

His book is divided into three parts:

  • Part 1, “The Language,” offers a high-level overview of Erlang and Elixir. Then it delves into Elixir’s basic building blocks and details common functional programming idioms.
  • Part 2, “The Platform,” focuses on primary aspects of BEAM, the Erlang virtual machine, as well as “how concurrency works and how it can help you build reliable systems.” Indeed, “[c]oncurrency is at the heart and soul of Erlang systems,” Jurić writes. “Almost every nontrivial Erlang-based production system is highly concurrent. Even the programming language is sometimes called a concurrency-oriented language.”
  • Part 3, “Production,”discusses “production aspects of BEAM-powered systems,” as well as “how to package components, reuse third-party libraries, and build a simple web server,” and “how to build a deployable standalone release and how to interact with the running system.”

Elixir in Action does not cover everything. But it provides fine overviews, clear how-to instructions, and compact code examples that illustrate important points. It can get you going in good directions.

“Elixir,” the author emphasizes, “lowers the entry barrier into the Erlang world and improves developer productivity.”

 — 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

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

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

Introducing Regular Expressions – Finding your perfect match…in strings – #bookreview

Introducing Regular Expressions
Michael Fitzgerald
(O’Reilly, paperbackKindle)

“Regular expressions are specially encoded text strings used as patterns for matching sets of strings,” Michael Fitzgerald writes in this example-rich new book that focuses on learning by doing.

Veteran programmers who work with Perl, Java, JavaScript, C# and a number of Unix utilities often consider regular expressions to be an important part of their toolkit. Ruby 1.9 and Python 3 also support regular expressions.

“Regular expressions have a reputation for being gnarly,” Fitzgerald notes. However, using the online Regexpal JavaScript regular expression tester, he shows you how to dive right into the very basics and start working your way up.

He introduces several other applications that let you work with regular expressions. And his chapters smoothly take you from matching single digits to matching text strings, number strings, boundaries such as the beginnings or endings of words, character classes, and beyond, including white-space patterns and Unicode. He also shows how to perform some fairly esoteric operations such as “negative lookaheads,” where you verify that a certain pattern of text or digits does not appear in a string ahead of certain other text, numbers, or other qualifiers.

The 136-page book has ten chapters:

  1. What Is a Regular Expression?
  2. Simple Pattern Matching
  3. Boundaries
  4. Alternation, Groups, and Backreferences
  5. Character Classes
  6. Matching Unicode and Other Characters
  7. Quantifiers
  8. Lookarounds
  9. Marking Up a Document with HTML
  10. The End of the Beginning

An appendix provides a regular expression reference, listing such items as control characters, Unicode whitespace characters, metacharacters, and others. There is also a glossary of regular expression terms, such as “greedy match” and “zero-width assertions.”

Fitzgerald recommends his book for those who are “new to regular expressions or programming…the reader who has heard of regular expressions and is interested in them but who really doesn’t understand them yet.”

Those who are a bit beyond the beginner level, however, likewise can benefit from Introducing Regular Expressions and its handy examples and how-to summaries.

Si Dunn

The Data Journalism Handbook – Get new skills for a new career that’s actually in demand – #bookreview

The Data Journalism Handbook: How Journalists Can Use Data to Improve the News
Edited by Jonathan Gray, Liliana Bounegru, and Lucy Chambers
(O’Reilly, paperbackKindle)

Arise, ye downtrodden, unemployed newspaper and magazine writers and editors yearning to be working again as journalists. Data journalism apparently is hiring.

Data journalism? I didn’t know, either, until I read this intriguing and hopeful collection of essays, how-to reports, and case studies written by journalists now working as, or helping train, data journalists in the United States and other parts of the world.

Data journalism, according to Paul Bradshaw of Birmingham City University, combines “the traditional ‘nose for news’ and ability to tell a compelling story with the sheer scale and range of digital information now available.”

Traditional journalists should view that swelling tide of information not as a mind-numbing, overwhelming flood but ”as an opportunity,” says Mirko Lorenz of Deutsche Welle. “By using data, the job of journalists shifts its main focus from being the first ones to report to being the ones telling us what a certain development actually means.”

He adds: “Data journalists or data scientists… are already a sought-after group of employees, not only in the media. Companies and institutions around the world are looking for ‘sense makers’ and professionals who know how to dig through data and transform it into something tangible.”

So, how do you transform yourself from an ex-investigative reporter now working at a shoe store into a prizewinning data journalist?

A bit of training. And, a willingness to bend your stubborn brain in a few new directions, according to this excellent and eye-opening book.

Yes, you may still be able to use the inverted-pyramid writing style and the “five W’s and H” you learned in J-school. But more importantly, you will now need to show you have some good skills in (drum roll, please)…Microsoft Excel.

That’s it? No, not quite.

Google Docs, SQL, Python, Django, R, Ruby, Ruby on Rails, screen scrapers, graphics packages – these are just a few more of the working data journalists’ favorite things. Skills in some these, plus a journalism background, can help you become part of a team that finds, analyzes and presents information in a clear and graphical way.

 You may dig up and present accurate data that reveals, for example, how tax dollars are being wasted by a certain school official, or how crime has increased in a particular neighborhood, or how extended drought is causing high unemployment among those who rely on lakes or rivers for income.

You might burrow deep into publically accessible data and come up with a story that changes the course of a major election or alters national discourse.

Who are today’s leading practitioners of data journalism? The New York Times, the Texas Tribune, the Chicago Tribune, the BBC, Zeit Online, and numerous others are cited in this book.

The Data Journalism Handbook grew out of MozFest 2011 and is a project of the European Journalism Centre and the Open Knowledge Foundation.

This book can show you “how data can be either the course of data journalism or a tool with which the story is told—or both.”

If you are looking for new ways to use journalism skills that you thought were outmoded, The Data Journalism Handbook can give you both hope and a clear roadmap toward a possible new career.

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