Crystal is an object-oriented programming language that combines the speed and power of C with the expressiveness and readability of Ruby, making it easy to write and easy to understand.
With Crystal, you can write less code and get more done. With a built-in type inference system that eliminates the need for explicit type annotations, if your code compiles, your code is guaranteed to be type error-free at compile time.
But don’t let its ease of use and high levels of abstraction fool you into thinking that it’ll be sluggish — nay, Crystal is extremely fast! It is built on top of the LLVM compiler infrastructure, giving it performance on par with C and C++. This means that your Crystal code can run faster and use less memory than code written in other languages.
Not only is Crystal a great choice for building web applications and servers, thanks to its growing ecosystem of community libraries and frameworks such as Amber that replaces Ruby on Rails or Kemal that replaces Sinatra, you can go even beyond.
Are you ready to dive into the world of Crystal programming? Read on to see my top picks for the best course to learn Crystal.
Here are my top picks. Click on one to skip to the course details:
Best free hands-on exercises to learn Crystal incrementally
What is Crystal?
Crystal is a general-purpose, object-oriented programming language designed for high performance and readability. Developed in 2014 by Ary Borenszweig, Juan Wajnerman, Brian Cardiff, and a team of over 300 contributors, Crystal has a seductive tagline: “Fast as C, slick as Ruby”.
Fast as C: Crystal is about 10% slower than C. This is quite impressive considering that C is a low-level language with no garbage collection while Crystal is a high-level language with garbage collection. In comparison, Ruby is about 8 times slower than Crystal. Crystal’s blazingly fast performance can be attributed to its LLVM compiler infrastructure, the same compiler technology used by C and C++ itself, as well as other famously fast languages such as Fortran, Rust, and Julia. Crystal also prides itself on its C interoperability, making it easy to call native C libraries. And if you want to see how Crystal fares in real-world usage, just compare the Kemal framework (Crystal) to Sinatra (Ruby) and Ruby on Rails (Ruby) in the barchart below.
Slick as Ruby: Crystal’s syntax is heavily inspired by Ruby — if you’re a Ruby veteran, you’ll feel right at home. But if you have not touched Ruby in your life, you’ll still find yourself picking up the language quite fast due to its simple, human-readable syntax. Additionally, Crystal has a built-in package manager called Shards (similar to Ruby’s gems) which makes it easy to install and manage dependencies.
But unlike Ruby, Crystal is statically type-checked, which means type errors will be caught early by the compiler rather than fail on runtime. Don’t worry though, you don’t need to explicitly define types as the compiler can intelligently infer types. Crystal also supports many modern features such as a macro system for powerful metaprogramming capabilities as well as support for concurrency, making it well-suited for high-performance and concurrent systems.
Crystal has a wide range of applications, including web development, systems programming, and data processing. It is often used by companies such as 84codes, Invidious, and Protel for building web servers, web APIs, and web scraping tools, due to its performance and expressiveness. And since it is concurrent, Crystal is also suitable for building command-line tools, distributed systems, and data processing pipelines. Though Crystal is relatively niche even compared to other niche languages out there, Crystal programmers are one of the most highly paid developers according to the 2022 Stack Overflow Developer survey, with a median yearly salary of $84,690.
Best Courses Guides Methodology
I built this ranking following the now tried-and-tested methodology used in previous Best Courses Guides (you can find them all here). It involves a three-step process:
Research: I started by leveraging Class Central’s database with 100K online courses and 200K+ reviews. Then, I made a preliminary selection of Crystal courses by rating, reviews, and bookmarks.
Evaluate: I read through reviews on Class Central, Reddit, and course providers to understand what other learners thought about each course and combined it with my own experience as a learner.
Select: Well-made courses were picked if they presented valuable and engaging content and they have to fit in a set of criteria and be ranked accordingly: comprehensive curriculum, affordability, release date, ratings and enrollments.
Course Ranking Statistics
Here are some aggregate stats about the ranking:
All of the courses are suitable for beginners to Crystal, while two courses are friendly towards complete newbies to programming.
All of the courses require you to run MacOs, Linux, or if you’re on Windows, WSL2. This is because Crystal is not yet fully supported on Windows at the time of writing.
All of the courses except for two are free.
Without further ado, let’s go through the top picks.
This short yet comprehensive guide that aims to help developers learn and understand the Crystal programming language by contrasting Ruby with Crystal. Though the course name may sound like it’s only aimed towards Ruby developers, it actually means that it assumes no knowledge of types, pointers, concurrency, or other similar things. Non-ruby developers are welcomed!
You’ll cover the basics of writing your first Crystal program, types, concurrency, metaprogramming, and more. By the end, you’ll have enough knowledge of Crystal to start exploring Crystal’s frameworks and libraries.
Prior experience with programming is required to take this course.
What You’ll Learn
After understanding the advantages of Crystal over Ruby and installing Crystal on your PC, you’ll get right into writing your first Crystal program. You’ll learn the basics of a Crystal project — implementing FizzBuzz in the language — which will help you grasp Crystal’s syntax and structure, as well as learn how to run Crystal programs.
Rubyists love testing. You’ll quickly discover that Crystal makes it easy to write and run tests using its built-in framework.
Rubyists love dynamic typing; Crystal is statically typed. Though most of the time. Crystal doesn’t feel like it’s statically typed anyways because you rarely need to specify the type thanks to intelligent type inference. And because of static types, you’ll find out about method overloading, where you have different methods with the same name and different number of arguments.
Crystal offers first-class support for concurrent programming through Channels. You’ll learn how to spawn multiple messages at the same time. You’ll also discover how Crystal’s metaprogramming capabilities can rival those of Ruby (even though Ruby is interpreted whereas Crystal is compiled), along with how to interoperate with C libraries using C bindings. Because why write something that has already been written?
How You’ll Learn
This course consists of 10 chapters. You’ll learn by reading through the course chapters and looking at the code examples provided.
Serdar Dogruyol is the author of Kemal (the blazingly fast web framework you saw in What is Crystal?), a curator of Crystal Weekly, and a Crystal Core Member. He’s a Crystalian who has extensive experience working with a variety of languages, including Ruby, Java, PHP, Crystal, and Elixir.
As this course does not provide any exercises, you should try doing some which are offered in the 6th and 7th ranking of this article.
Targeted at novice Crystal programmers and people with no experience with programming, you’ll learn the basics of the Crystal language in a very short amount of time.
The content is sufficient but limited. I recommend that you supplement your learning with the 6th and 7th practical courses in this ranking.
Prior programming experience is recommended, but not required.
What You’ll Learn
You’ll begin this course with the famous first message every programmer has ingrained into their brains — ”Hello World!”. Although it’s simple, you’ll get to know the structure of a Crystal program this way, that is top-level scope is treated as part of the main program.
Next, you’ll learn about variables and data types. One thing to note is that variables can be reassigned to different values and even different data types, which may feel a lot like dynamic types in Ruby. Then, you’ll also learn how to do arithmetic and string operations in Crystal, which are very much painless to perform.
Every programming language needs to have control constructs as well as methods. You’ll learn how to use conditionals and loops to have your program make or repeat decisions. Methods, on the other hand, allow you to avoid duplicating the same chunk of code. You’ll learn how to create methods with arguments and type restrictions to ensure correctness of your program.
Finally, you’ll be given two examples of simple programs for you to explore. One of them is a command line application where you’ll learn how to deal with getting user input and producing an output, whereas the other will open your eyes to server processing with HTTP servers.
How You’ll Learn
This course is made up of multiple tutorials focusing on different aspects of the language. You’ll learn by reading through them as well as by studying the example applications provided.
The Crystal website also contains guides to other aspects of Crystal programming such as concurrency or performance, along with manuals for the compiler and the shards command.
My third pick for the best course is a bit peculiar.
Groxio’s paidCrystal Course combines a course book, videos (informational and instructional), community resources, and coding projects all in one package.
By following the Dreyfus learning model, Groxio provides the necessary step-by-step instructions for beginners to start Crystal, and perhaps more crucially, exercises and projects that intermediates need to follow up with in order to break from their newbie status.
If you’re willing to shell out a little bit of cash for a multimodal learning experience, this course wouldn’t disappoint!
You should have some experience with programming prior to taking this course.
What You’ll Learn
You’ll begin with an elucidation of the fundamental principles and philosophy behind Crystal to help you appreciate the language. Afterward, you’ll engross yourself in the basic details of Crystal, such as installation and syntax. By creating a simple “Hello, World!” program, you’ll help crystallize the structure of a typical project into your mindspace, before diving deeper in the details.
Next, you’ll explore decision-making with cases and if statements, and learn how to group and manipulate data with arrays, tuples, and hashes. You’ll also discover the power of procs and blocks for creating reusable code.
Moving on, you’ll get a test of the object-oriented side of Crystal with classes and modules. You’ll learn how to organize and structure code in larger projects, and grasp key OOP concepts like instantiation, inheritance, and polymorphism. These concepts will help you write complex and scalable software, making it easier to maintain and upgrade in the future.
Crystal is a statically typed language. You’ll learn and master types by first understanding their importance — to ensure code correctness at compile time. You’ll also learn how to create and wield your own custom types to protect your code from potential errors too. Finally, you’ll bring everything together by planning, building, and deploying Crystal projects, including managing dependencies and concurrency, through actual hands-on projects.
How You’ll Learn
This course consists of a course book, video tutorials, community resources, and projects. You’ll learn by reading through the book chapters, watching videos about the Crystal language as well as videos by the instructor where they code hands-on, checking out the handy community resources, and most importantly, working on the larger coding projects.
Bruce A. Tate
Bruce A. Tate is a programmer and CEO of Groxio where he is helping to redefine how computer languages are taught and learned. He’s the author of Seven Languages in Seven Weeks and Programming Phoenix, among other titles, and has been involved with Elixir from the very beginning.
I like this free course particularly because it’s easy to let the video play, sitback, and learn. This is because Gábor Szabó is an excellent teacher who can explain in detail what is happening on screen with his well-crafted slides and examples. Though of course, it’d be a much more effective learning experience if you were to follow along writing down code examples at home.
The video series covers most but not all of the slides in the link, so by the end of the course, you’ll have learned the basics of the Crystal language, including its syntax, type system, and how to run code. You should check out the slides, as they also give you exercises to try and complete.
If you have an hour to spare to see what Crystal is all about, and also have some prior programming experience, this is a great course for you.
What You’ll Learn
In this course, you’ll learn the basics of the Crystal language. After some brief set up (running Crystal in a Docker container and exploring third party libraries called ‘shards’), you’ll begin learning how variables and data types work in Crystal. Indeed, you’ll be amazed by Crystal’s static but versatile types, from primitive to compound types, and concatenating strings to doing mathematical operations on numbers. You’ll be able to write a command line program that takes arguments passed into the standard input (STDIN) and prints a result to the screen.
You’ll also learn about early exit in Crystal, create basic shapes like rectangles, discover the concept of interactive environments, and also how to write Crystal one-liners. Last but not least, you’ll learn how to generate random numbers in Crystal.
How You’ll Learn
This course is 3–4 hours long. You’ll learn by watching the videos in the series and following along with the instructor. Additionally, you can complete the exercises given to strengthen your understanding of the Crystal programming concepts.
Gábor Szabó is a programmer with almost 40 years of experience in programming languages such as Perl and Python. He runs the Code Maven YouTube channel and website.
Learn Crystal Programming is another great project-based introductory course to the Crystal programming language. Unlike the third course in this ranking however, this paid course by Timnan Sheni is friendly towards absolute beginners.
You’ll learn how to write powerful, efficient, and concise programs in Crystal through four hands-on projects: a name guessing game; a rock, paper, scissors game; a simple calculator application; and lastly, an automatic file organizer.
No prior programming experience is required to take this course!
What You’ll Learn
You’ll start off this course by installing Crystal as well as its relevant extensions on VSCode to get the tooling out of the way.
Next, you’ll explore Crystal’s data types, which are very much similar to Ruby’s with types such as Strings, Numbers, Floats, and data structures like Arrays and Hashes. You’ll focus on handling user input and then making decisions based on that by using control flow.
“What is control flow?”, I hear you ask. Control flow consists of conditional statements such as if statements and loops such as while and unless loops that help the program choose between code paths or repeat blocks of code respectively. Armed with these concepts, you’ll create a name guessing game (similar to hangman) and use nested logic to play rock, paper, scissors.
The kind of programming you’ve just done is called imperative programming, where instructions are written step-by-step to perform a task. But there’s a more powerful programming paradigm called object-oriented programming, where instead of giving step-by-step instructions, you create “objects” that represent things or ideas in your program. Each object has its own properties (like name or color), can perform actions (like move or change color), and can even interact with each other. You’ll make great use of these concepts when you develop a calculator app, before finally ending the course with a IO-intensive app that organizes files into folders based on their file format.
How You’ll Learn
This course is 3 hours long. You’ll learn by watching the lecture videos and gaining hands-on experience by building various projects.
Exercism is an open-source, online platform for learning and practicing programming. They provide a collection of free coding exercises in difficulties, from easy to hard, in various programming languages (including Crystal!).
When I want to learn a programming language, I use Exercism to complement my learning experience. Not only does it allow me to practice what I’ve learned, but it also gives me the opportunity to compare my solutions with others. And that’s not all — the best part about Exercism is that it offers free mentoring.
I can submit my lousy code for any exercise, and after some time, receive constructive feedback from an experienced developer. This helps me improve my coding skills and write less lousier code. And so can you!
What You’ll Learn
Exercism offers Crystal exercises of varying difficulty levels, of which there are easy and medium exercises.
Examples of easy exercises include reporting leap years, converting binary numbers to their denary equivalent, and encrypting/decrypting ciphers such as Atbash, Caesar, or rational.
Some medium difficulty tasks are as follows: determining if a number is mathematically perfect, abundant, or deficient, calculating a person’s allergy score, and generating proverbs from a list of words.
How You’ll Learn
This course is self-paced, so you can take all the time you need to complete the 55+ hands-on programming exercises. Each exercise comes with automatic feedback of your code as well as personal mentoring to help you understand your code’s strengths and flaws.
Exercism provides exercises on 50+ programming languages like Python, Kotlin, F#, and even WebAssembly.
Their mission is to help everyone get really good at programming, regardless of their background, share the love of programming, and help people upskill as part of their upward social mobility.
Around 40 people have contributed towards the Crystal syllabus and exercises, with over 60 mentors available at the time of writing.
The Crystal Language Koans are a set of free exercises aimed at teaching you the basics (and more!) of Crystal. It’s an interactive learning tool that’ll guide you through a series of challenges through trial-and-error unit testing, incrementally building your Crystal programming skills.
This course is much more structured than the previous course, dealing with a much wider variety of Crystal topics, including syntax, data structures, control structures, object-oriented programming, web programming, and more. The goal is to provide an engaging and hands-on way of learning the language while also reinforcing key concepts.
You should have some prior experience with Crystal in order to take this course.
What You’ll Learn
The sub-bullets (in italic) in the list show what exercises are part of that topic.
Data types and data structures: The building blocks of every program, you’ll need them for correctness and efficiency.
Environment & Paths: Need to access files on the system? No worries!
require_path, env, dir, path
Data Formats: There perhaps may be as many data formats as there are trees on Earth. Learn how to read the most common ones.
html, json_plain, json_custom, csv, xml, yaml
HTTP & Networking: Experience what Crystal is built for — efficient server processing.
How You’ll Learn
This course consists of 51 Koans or exercises. You’ll learn through iterative testing — see the tests fail, and fill in the codes until all of the tests pass. Then, you’ll do it again until you finish all sets of exercises.
Andrea Manzini is a Unix System Administrator and an open-source contributor. He works for SUSE as a QE Automation Engineer, where he does automated test development and quality assurance for SUSE product release.
If you’ve read my other guides, you’ll know that other programming languages have their own Koans out there. In fact, this Koan is inspired by RubyKoans, CppKoans, GoKoans.