Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Crystal is a compiled, statically typed language created by Ary Borenszweig and the team at Manas Technology Solutions in Argentina, first appearing publicly around 2014. Its syntax is deliberately close to Ruby — many Ruby snippets run almost unchanged — but Crystal compiles to native code through LLVM and infers types instead of interpreting them, so you get Ruby-like ergonomics with performance nearer to C. There is no interpreter at runtime; the sandbox compiles your source to a native binary and runs it. Type inference means you rarely write annotations, yet mistakes are still caught at compile time. On XCODX you can explore that Ruby-flavored syntax and Crystal's standard library directly in the browser.
print "Enter your name: "
name = gets.to_s.chomp
print "Enter a number: "
n = gets.to_s.chomp.to_i
puts "Hi #{name}! Squares up to #{n}:"
(1..n).each do |i|
puts "#{i} => #{i * i}"
end
Crystal appeals most to Ruby developers who want the same expressive syntax without the interpreter's runtime cost — web backends (with frameworks like Kemal or Lucky), CLI tools, and text processing are common targets. Choose it when readability matters and you still want a compiled, type-checked binary. Its concurrency model uses lightweight fibers, which suits IO-bound services. It is a weaker fit where you need a large, mature package ecosystem or first-class Windows support, and here specifically the Shards package manager is unavailable, so only the standard library is in reach.
No. The sandbox provides only Crystal's standard library, with no Shards, no network, and no persistent filesystem, so external shards cannot be fetched or installed. Stick to what requiring the built-in standard modules gives you.
Call `gets`, which reads one line from standard input and returns a `String?` (it can be `nil` at end of input), so a common pattern is `gets.to_s.chomp`. In the live terminal the program waits for you to type and press Enter; you can also feed the Stdin Box, and Ctrl+D closes the stream. Convert with `.to_i` or `.to_f` for numbers.
Not quite. The syntax is intentionally Ruby-like and much code looks identical, but Crystal is statically typed with compile-time type inference, has no runtime monkey-patching, and compiles to a native binary via LLVM rather than being interpreted. Some dynamic Ruby features are deliberately left out.
`gets` returns `nil` when there is no more input — for example when the stream is closed with Ctrl+D or the Stdin Box is empty. Guard it with `if line = gets` or convert defensively with `gets.to_s`. This nil-awareness is part of Crystal's null safety.
You can write the code, but it will not accept outside connections — the sandbox has no network access and each run is isolated and temporary. Crystal's HTTP server lives in the standard library, so it compiles, but treat this as a syntax playground rather than a live host.
The runtime badge shows the exact version, typically a recent 1.x release. Because programs compile to native code before running, execution is quick, though you will see a short compile step first and there is an overall run timeout.
main.crrubygetsputs "Hello from Crystal!"
puts "Welcome to XCODX Online Compiler!"
message = "Crystal is fast!"
puts message