radar

radar

The Elixir Toy Robot (self-published)

:wave: You might remember me as the author of Joy of Elixir: https://forum.elixirforum.net/t/joy-of-elixir-self-published-free/

I’ve got a new book out which shows you how to do the Toy Robot exercise in Elixir:

The first 6 chapters of the book cover how to solve the common part of the exercise. Chapter 7 (coming soon) covers processes and supervision trees while building the foundations of a multiplayer Toy Robot game. Chapter 8 will finish that game.

I view this book as a “sequel” to things like Joy of Elixir, the getting started docs for Elixir or Elixir School. It’s a real (enough) project with real problems and I hope people enjoy reading it and following along.

Let me know what you think in this thread!


Table of Contents

  • Introduction
  • Introducing the Toy Robot
    • Simplifying the problem
    • Creating the application
    • The MOVE command
    • Moving west
    • Moving north and south
    • Moving in the right direction
    • Turn left!
    • Turn right!
  • Catching bugs
    • Finding the bugs within
    • Regression testing the turn_right function
    • Regression testing the move function
    • Regression testing the move_west function
    • Regression testing the move_north and move_south functions
    • Jumping back to the manual test
    • Reflections
  • Placing the robot on a table
    • The Table module
    • The missing link
  • Building our simulation
    • Moving a robot, within a simulation
    • Turning a robot, within a simulation
    • Reporting the robot’s position
  • Reading and handling commands
    • The Command Processor
    • The Command Handler
    • The Command Runner
    • Piecing it all together
  • Building the CLI
    • Reading commands from a file
    • Verifying the robot’s behaviour
    • Conclusion
  • The Toy Robot Game
  • Building a game
    • A single player game
    • Let it crash!
    • The Game Server

Most Liked

radar

radar

radar

radar

This book is now content complete! :tada:

I’ve covered all the content I set out to cover in this book, and so now we’ve got plenty of words covering:

  • How to build an Elixir project from scratch
  • Doctests
  • ExUnit tests
  • GenServers
  • Supervisors
  • Registries

It’s a smidge over 60,000 words, and about 220 pages.

I’m going to spend this next week reading through it myself and making sure everything is as correct as it can be and then I would say this book is done!

narand

narand

Seems interesting! Could you share one or two sample pages from the PDF?

radar

radar

No issue tracker so to speak, but if you email me (me@ryanbigg.com) with the page number where you found the mistakes and a bit of context around them, I should be able to fix them up quick smart!

Here’s a short version of the workflow of writing the book:

  1. Write in an ERB (Embedded Ruby) version of Leanpub’s Markdown
  2. Run my ERB parser script to convert my ERB into Leanpub’s Markdown
  3. Push it up to GitHub (for version control)
  4. Manually copy the files over to a Dropbox folder that Leanpub shares with me
  5. (Optionally) Check the “Notify readers of an update”
  6. Hit “Publish”

The ERB part of the process exists because there’s some fiddly Leanpub-specific syntax that I can automate away with some pretty basic Ruby. (This part is not written in Elixir yet because I wrote it back when I only knew Ruby :wink: )

Another thing is that I use VS Code’s file-shortcuts.code-snippets file to have tab-complete for common code blocks within my books. I configure it like this:

{
  "Code block for robot.ex file": {
    "prefix": "robot.ex",
    "body": [
      "<% elixir title: \"lib/toy_robot/robot.ex\" do %>",
      "  $1",
      "<% end %>"
    ],
    "description": "Code block for robot.ex file"
  },

Then I can type ro.ex and hit <Tab> and it will fill it out to be:

<% elixir title: "lib/toy_robot/robot.ex" do %>
  [cursor goes here]
<% end %>

Then if I put in code in that box and hit <Tab> again, it will jump to the end of it. That speeds up writing a bit!\

AstonJ

AstonJ

Looks good Ryan, congrats on writing another book :023:

Where Next?

Popular in Books Top

PragmaticBookshelf
Alexander Koutmos @akoutmos Elixir Patterns aims to surface the powerful and unique characteristics of the Erlang virtual machine and sho...
New
PragmaticBookshelf
Andrea Leopardi @whatyouhide edited by Jacquelyn Carter @jkcarter TCP, UDP, DNS, HTTP, and more: these are the network protocols that ma...
New
DevotionGeo
https://www.packtpub.com/web-development/phoenix-web-development
New
PragmaticBookshelf
This hands-on book will quickly get you building, querying, and comparing graph data models using a robust, concurrent programming langua...
New
mchean
By @emadb OVERVIEW Author Emanuele DelBono guides readers along the first steps of mastering the Elixir programming language in Elixi...
New
Eiji
The Ecto recipes were originally written for the “What’s new in Ecto 2” ebook and then made open-source by Plataformatec. Since then, the...
New
kokolegorille
by Ulisses Almeida Elixir’s straightforward syntax and this guided tour give you a clean, simple path to learn modern functional program...
New
shankardevy
Dear Elixir Alchemists I’m happy to share that I’m working on my 2nd series of books (See my first one here) and this time it’s about As...
New
codestirring
Hey Elixir Forum, I’ve written a ebook called the Phoenix LiveView Cookbook which I’ve written in the hopes of distilling the knowledge ...
New
peerreynders
Don’t forget you can get 35% off the ebook using the code ‘devtalk.com’ :023: This title will be available on or about 2018-11-10
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement