Quick Access:
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 courses to learn Crystal.
Click on the shortcuts for more details:
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 earn an average pay rate for developers according to the 2023 Stack Overflow Developer survey, with a median yearly salary of $77,100.
Why You Should Trust Us
We know how online learning works. Class Central, a Tripadvisor for online education, has helped 60 million learners find their next course. We’ve been combing through online education for more than a decade to aggregate a catalog of 200,000 online courses and 200,000 reviews written by our users. And we’re online learners ourselves: combined, the Class Central team has completed over 400 online courses, including online degrees.
Courses Overview
- 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 one are free.
Prior experience with programming is required to take Crystal For Rubyists written by Serdar Dogruyol.
This short yet comprehensive guide 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.
What you’ll learn:
- Understand the advantages of Crystal over Ruby and install Crystal
- Write your first Crystal program and implement FizzBuzz to learn syntax and structure
- Learn to run Crystal programs
- Discover Crystal’s built-in testing framework
- Understand static typing with intelligent type inference in Crystal
- Learn about method overloading with static types
- Explore concurrent programming with Channels
- Discover Crystal’s metaprogramming capabilities
- Learn to interoperate with C libraries using C bindings.
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 from other courses in this article.
Website | crystalforrubyists.com |
Instructor | Serdar Dogruyol |
Level | Beginner |
Workload | N/A |
Certificate | None |
Targeted at novice Crystal programmers and people with no experience with programming, you’ll learn the basics of Crystal in a very short amount of time with Crystal Language tutorials. Hosted on the official Crystal language website, the content is sufficient but limited. I recommend that you supplement your learning with the practical courses in this guide.
Prior programming experience is recommended, but not required.
What you’ll learn:
- Start with “Hello World!” to understand Crystal program structure
- Learn about variables and data types, including reassignment to different types
- Perform arithmetic and string operations easily
- Use control constructs: conditionals and loops
- Create methods with arguments and type restrictions
- Explore two example programs: a command line application and an HTTP server.
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.
Also, the entire website is open-sourced including the tutorials and guides. Anyone can contribute towards helping new Crystallians learn and adopt the language!
Institution | Crystal Team |
Provider | crystal-lang.org |
Level | Beginner |
Certificate | None |
Gábor Szabó has an excellent introductory course to Crystal programming.
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’s a much more effective learning experience to follow along writing down code examples as you watch.
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 complete.
If you have a few hours to spare to see what Crystal is all about, and also have some prior programming experience, this is a great course for you.
In this course, you’ll:
- Set up Crystal in a Docker container and explore third-party libraries (shards)
- Learn how variables and data types work in Crystal, including primitive and compound types
- Perform string concatenation and mathematical operations
- Write a command line program that processes STDIN arguments and prints results
- Learn about early exit in Crystal
- Create basic shapes like rectangles
- Explore interactive environments and write Crystal one-liners
- Generate random numbers in Crystal.
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.
Channel | Code Maven |
Provider | YouTube |
Instructor | Gábor Szabó |
Level |