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.
Nim is a statically typed, compiled language created by Andreas Rumpf and first released in 2008. It compiles through C by default (and can also target C++ or JavaScript), which lets it produce small, fast native binaries while keeping a clean, indentation-based syntax that reads a little like Python. The language leans heavily on compile-time execution and a real macro system, so work that other languages leave for runtime often happens while the program is being built. On XCODX it runs as an ordinary compiled program: you write Nim, the sandbox compiles and executes it, and the output appears in the terminal. It is a practical way to explore Nim's syntax and standard library without installing the compiler or the Nimble toolchain locally.
import std/strutils
echo "Enter your name:"
let name = readLine(stdin)
echo "Enter a number:"
let n = parseInt(readLine(stdin).strip())
echo "Hi ", name, "! Counting to ", n, ":"
for i in 1 .. n:
echo i
Nim suits people who want C-like performance with a higher-level, readable syntax — command-line tools, systems utilities, and compute-heavy code all fit well, and its metaprogramming makes it handy for building small domain-specific languages. Reach for it when you want a single self-contained binary and are comfortable with a smaller ecosystem than Python or Rust. Because Nim compiles ahead of time, a quick throwaway script is slightly heavier than in an interpreted language, though the syntax stays close. It is a poor fit here for anything needing third-party Nimble packages, since the sandbox only exposes the standard library.
No. The XCODX sandbox ships only Nim's standard library, and there is no Nimble, no network access, and no persistent filesystem, so anything `nimble install` would fetch is unavailable. Every module you import has to come from the `std/` packages bundled with the compiler.
Use `readLine(stdin)`, which returns the typed line as a string; `stdin` is available without any import. In the live terminal your program pauses at that call until you type a line and press Enter, or you can pipe text through the Stdin Box, and Ctrl+D closes the stream. To read a number, wrap it with `parseInt` from `std/strutils`.
Nim is compiled. The sandbox translates your source to C and then to a native executable before running it, so you get compiled-language speed. There is no REPL here — each run compiles the whole program fresh.
Yes, Nim uses indentation to delimit blocks instead of braces, though it is more relaxed about spacing than Python and treats identifiers as case- and underscore-insensitive after the first letter. That keeps short programs compact and easy to read in the editor.
The exact version appears in the runtime badge above the editor — it is a recent Nim 2.x release. The sandbox uses whatever the Piston backend currently ships, and you cannot pin a different toolchain.
The sandbox has no network access and no disk that persists between runs, so opening sockets or writing files that survive is not supported. Each execution starts from a clean environment, so use stdin for input and stdout for output, and keep the program within the size limit and the short run timeout.
main.nimpythonreadLine(stdin)echo "Hello from Nim!"
echo "Welcome to XCODX Online Compiler!"
let message = "Nim is efficient!"
echo message