Crystal

Apache 2.0
Platform
Linux Windows macOS
Licence
Apache 2.0 Open source
Crystal

Overview

Crystal is a general-purpose, compiled programming language built on a deliberate idea: keep the syntax programmers like about Ruby and the speed they get from C, without asking them to write either one well. It was started in 2014 by Ary Borenszweig and Juan Wajnerman at Manas Tech and has been developed in the open ever since, with the current release 1.22.2 published in October 2026. Programs are statically type-checked and compiled to native machine code through LLVM, but you rarely write a type annotation — the compiler infers types across the whole program and reports a mistake before the binary is ever produced. The language is licensed under Apache 2.0, the repository is active daily, and it runs on Linux, macOS and — still in preview — Windows, along with FreeBSD, OpenBSD and Android through Termux.

Key Features

  • Ruby-like syntax — blocks, string interpolation, symbols, do ... end, method calls without parentheses and everything-is-an-object semantics, so Ruby code reads almost like Crystal. Compatibility with Ruby is deliberately not a goal.
  • Type inference with static checking — types are checked at compile time, unions such as String? are part of the type system rather than an afterthought, and the compiler refuses to build a program that could fail on a nil at runtime.
  • Compiles to native code — the LLVM backend emits a single self-contained binary with no virtual machine and no runtime interpreter, so startup is immediate and memory use is what the program actually needs.
  • C bindings without glue — declaring libc functions and structs directly in Crystal is enough to call C libraries; there is no separate interface file to generate or maintain.
  • Macros and compile-time evaluation — macros run Crystal code at compile time to generate methods, types and boilerplate, which is how the standard library offers high-level APIs with no runtime cost.
  • Fibers and channels — lightweight concurrency is built into the language: spawn starts a fiber, Channel passes values between them, and the event loop handles the scheduling.
  • Shards — the package manager and dependency format ship with the compiler. A shard.yml pins dependencies, shards install fetches them, and dependencies are compiled in rather than loaded at runtime.
  • Built-in tooling — crystal run compiles and executes in one step, crystal build --release produces an optimised binary, crystal spec runs the bundled test framework and crystal tool format enforces one code style.

Why Use Crystal?

Crystal removes the trade-off that usually decides between a scripting language and a compiled one. You write in a language that feels like Ruby — short, expressive, no type declarations to maintain — and you ship a native binary that starts in milliseconds and uses a fraction of the memory a managed runtime needs. Because the compiler resolves types for the whole program, whole classes of bugs (nil dereferences, wrong argument types, typos in method names) become build errors rather than production incidents, and the code that does compile runs at speeds comparable to C. For a web service, a CLI tool or a background worker where throughput and memory matter but developer time matters more, that combination is unusually convenient: one binary to deploy, no interpreter on the target machine, and no garbage-collection tuning to get started.

Use Cases

  • HTTP services and JSON APIs — the standard library includes an HTTP server and client, and the Lucky and Kemal frameworks build on them.
  • Command-line tools and system utilities that need to start instantly and ship as a single binary.
  • Background workers, crawlers and scrapers where fiber-based concurrency keeps thousands of connections cheap.
  • Wrapping C libraries — image, database and crypto bindings call the native library directly.
  • Performance-sensitive scripts migrated from Ruby, where the syntax barely changes but the speed does.
  • Learning how a statically typed, compiled language can still feel dynamic — try it in the browser at play.crystal-lang.org.

Getting Started

Install with the official installer script (curl -fsSL https://crystal-lang.org/install.sh | sudo bash), a distribution package such as apt install crystal, Homebrew on macOS, or the Docker image crystallang/crystal. Confirm the install with crystal --version, then write a file and run it in one step: crystal run hello.cr compiles and executes, while crystal build --release hello.cr produces the optimised binary you deploy. Start a project with crystal init app myapp, which creates the directory layout, a shard.yml and a spec file. Read the language reference at crystal-lang.org/reference, keep the standard library API at crystal-lang.org/api open, and add dependencies by editing shard.yml before running shards install. Windows support is usable but still labelled preview — for anything production-critical, Linux or macOS is the safer target today.

Explore More Categories

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.