Factorial - Crystal Typing CST Test
Loading…
Factorial — Crystal Code
Calculates factorial recursively.
def factorial(n)
return 1 if n <= 1
n * factorial(n - 1)
end
puts factorial(5)Crystal Language Guide
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.
Primary Use Cases
- ▸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
Notable Features
- ▸Ruby-inspired readable syntax
- ▸Static type system with inference
- ▸Compiled to fast native binaries
- ▸Macros and compile-time code generation
- ▸Concurrency via fibers and channels
Origin & Creator
Crystal was created by Ary Borenszweig, Juan Wajnerman, and Brian Cardiff in 2011, inspired by Ruby’s syntax and modern systems programming needs.
Industrial Note
Crystal is used in web backend frameworks, DevOps tooling, microservices, and performance-critical tasks where Ruby-like syntax with compiled efficiency is desirable.