Want to see the full-length video right now for free?

Sign In with GitHub for Free Access


Crystal is a programming language with syntax unabashedly inspired by Ruby. It’s incredibly fast, statically typed, and an absolute pleasure to write.

Catch most nil errors at compile time

Crystal helps you catch one of the most prevalent errors in programming, nil errors.

class User
  # This tells Crystal to allow a String or nil for the age
  def initialize(@name : String?)

user = nil)

# Would result in an error at compile time
Error in undefined method 'downcase' for Nil (compile-time type is (String | Nil))

Handling requests in Lucky

Lucky is a web framework written in Crystal that helps you catch bugs early, forget about most performance issues, and spend more time on code instead of debugging and writing tests.

Here’s an example of how a Lucky action helps you write reliable code:

class Announcements::Show < BaseAction
  get "/announcements/:id" do
    p id # Prints the :id param
    render_text "List of announcements"

Lucky will inspect the path at compile time and create a method for every named parameter. This is what lets you call id in the action. You are guaranteed that that parameter exists.

Lucky actions also generate a path helper for you:

Announcements::Show.route(id: "123") # Generates "/announcements/123"

The route method ensure that all parameters are present. It’s also a lot easier to remember than path helpers in most frameworks because you call the action directly instead of some helper methods like announcement_path.

Type safe database querying

Instead of using strings or symbols, Lucky generates Crystal methods from your model so that when you query the database, you’re guaranteed that those fields exist. No more worrying about renaming columns and forgetting to change a query, Lucky will catch it for you.

# Define a model
class Announcement < BaseModel
  table :announcements do
    field title : String

# Query it"This is the title").first

You also get type specific query methods. For example, you can use lower with string types"this is the title")

Crystal and Lucky help you catch bugs, write beautiful code, and make your customers happy

You can write better applications thanks for Crystal’s lightning fast speed, helpful compiler, and beautiful syntax . Combine Crystal and Lucky and you can write beautiful, reliable, and fast applications that your customers are going to love.