Learn Crystal - 10 Code Examples & CST Typing Practice Test
Crystal is a modern, statically typed, compiled programming language with syntax heavily inspired by Ruby. It aims to combine the efficiency and speed of compiled languages with the readability and productivity of Ruby, supporting type inference, concurrency, and high-performance applications.
Learn CRYSTAL with Real Code Examples
Updated Nov 20, 2025
Installation Setup
Install Crystal compiler via package manager or from source
Verify installation with `crystal --version`
Install Shards (dependency manager)
Create project with `crystal init app project_name`
Build and run sample project
Environment Setup
Install Crystal compiler
Install Shards
Set PATH for Crystal binaries
Verify with `crystal --version`
Run sample application
Config Files
shard.yml for dependencies
.cr files for source code
config/ for environment settings
spec/ for tests
bin/ for compiled binaries
Cli Commands
crystal build file.cr
crystal run file.cr
crystal spec
shards install
crystal tool format
Internationalization
UTF-8 strings supported
Locale-specific formatting via libraries
Web frameworks support i18n
No built-in multi-language runtime
Strings and symbols fully Unicode-compatible
Accessibility
Crystal compiler with clear error messages
REPL via `crystal play`
Rich documentation and tutorials
Active GitHub community
Language server for IDEs
Ui Styling
Primarily CLI or web backend
Web rendering via Kemal/Amber
No native GUI focus
Integration with frontend via JSON/HTTP
Console output formatting supported
State Management
Variables and constants in scope
Fiber-local state for concurrency
Immutable types for safety
Shared memory via channels
Global state discouraged
Data Management
Arrays, hashes, tuples
Structs and classes
IO streams and JSON handling
Database queries via ORM
Shards for external libraries
Frequently Asked Questions about Crystal
What is Crystal?
Crystal is a modern, statically typed, compiled programming language with syntax heavily inspired by Ruby. It aims to combine the efficiency and speed of compiled languages with the readability and productivity of Ruby, supporting type inference, concurrency, and high-performance applications.
What are the primary use cases for Crystal?
Web applications (via Kemal, Amber frameworks). Command-line tools. Microservices and APIs. High-performance backend services. System utilities and scripting. Prototyping with production-ready performance
What are the strengths of Crystal?
High performance due to compilation to native code. Readable Ruby-like syntax. Strong static typing with minimal verbosity. Macros for metaprogramming and code reuse. Good concurrency model with lightweight fibers
What are the limitations of Crystal?
Smaller ecosystem than Ruby or Python. Slower compiler for large projects. Limited libraries for certain domains. Less community support compared to mainstream languages. Still maturing in tooling and IDE support
How can I practice Crystal typing speed?
CodeSpeedTest offers 10+ real Crystal code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.