Book: Programming Crystal

I’m delighted to announce that Programming Crystal, written by Ivo Balbaert and myself, is now available in print as well as electronically:

https://pragprog.com/book/crystal/programming-crystal

We tried to keep the book accessible to a broad audience, assuming programming knowledge but not Ruby mastery. We provide a broad overview of how to apply the language, with special attention given to Crystal’s strong interest in type safety. Ivo interviewed companies working with Crystal today, and their stories at the end of each chapter give real-world context to a very new language.

It’s brief - 226 pages - and we hope it will be a solid introduction for anyone approaching the language.

Thank you,
Simon St.Laurent

30 Likes

Thanks for the first book on Crystal from pragprog!

Although I would have enjoyed more technical content in book I also find the interviews part very interesting and important as I believe that’s what Crystal needs a lot right now:

People sharing their stories on how they use pre 1.0 programming language in production :fearful: and what are their experience (spoiler - it’s very positive!).

3 Likes

This book is on my shopping list! Might be a few months before I can buy it, as I’m flat broke for now. But I will use Crystal as best I can in the meantime. Having something to read that isn’t technical reference, API reference, or a blog post or article on a narrow topic or small toy programs, will be helpful to those of us new to Crystal but experienced with other languages.

Huge congratulations! I’m so glad to see this book finished. Hopefully, it will help Crystal pick up some followers.

I’m reading the book right now on O’Reilly Learning (2 chapters done so far) and so far so good. I wish it was more in-depth, but it’s a good introductory one. Maybe in the 2nd ed! :wink:

I’m reading this book, so far it’s nice :slight_smile:

I was trying to learn Crystal alonside with Ruby, but since Crystal had my most interest, I finally bought the book.
@simonstl in Your Turn 6, there is an ‘a’ and a ‘b’, the classes.cr in the exercises directory only answers ‘b’, the hint is to use self, but it also works without, but better with self?
Here is my version for both a and b:

class Mineral
   getter common_name : String
   setter common_name
   getter hardness : Float64
   getter crystal_struct : (String | Nil)    # YT6a: union
   setter crystal_struct

   def initialize(@common_name, @hardness, @crystal_struct)
   end

   def describe
      "This is #{common_name} with a Mohs hardness of #{hardness} \
and a structure of #{crystal_struct}."
   end

   def to_s    # YT6b: string representation of the Mineral object
      "#{common_name}, #{hardness}, #{crystal_struct}" # works without 'self'
   end
end

min = Mineral.new("talc", 1.0, "monoclinic")
puts "#{min.describe} (with initial structure)"
puts min.to_s

min = Mineral.new("diamond", 10.0, nil)
puts "#{min.describe} (no initial structure)"
min.crystal_struct = "cubic"
puts "#{min.describe} (structure added)"
puts min.to_s

As an addition to my previous message, union.cr is supposed to be the answer to Your Turn 6a.
But it is only 3 lines showing the definition of an union, not the answer to the question in my opinion.
My post is meant to improve the book/answers, not to criticize, because I like it so far very much!

Some pages are free to read here:
The books looks really good.


Oh wow! Fantastic!

I read your book about Erlang a while back, you have such a graceful way of explaining things. I’ll pick this up ASAP.

I just finished this book! Thank you! As someone who has read more than a few books like this, yours really stood out as just the right blend of information density and conciseness.

1 Like

Is a new edition coming up for “Programming Crystal”?

2 Likes

Just wanted to say many thanks to both of you for writing the book, it was excellent. I feel confident now that I can really use Crystal moving forward.

I bought the book some weeks ago and I finished it in a couple of days. It is a very nice book and can be considered a very good introduction to the language and to its ecosystem. I’m still using it while trying to build my first app with Crystal. It is of great help. I strongly suggest new Crystal programmers to buy and read it. It will save them a lot of try-and-error.

My only complaint is that it is too small. Crystal is a small and nice language and can be effectively described in a few pages but its ecosystem is rapidly growing and would deserve some more documentation. In particular, it would be important to have a detailed description of the tools used to interface Crystal with C and C++ libraries.

My personal hope is to see soon a new, improved, larger version of this book.

3 Likes