Odin Programming Language

Fall in Love with Programming, all over Again.

The Data-Oriented Language for People Who Ship

Software from the Showcase and games shipping on Steam, all built with Odin.

See the Showcase See the Games

Join the Odin community on Discord.

Programming Done Right

Odin is a general-purpose programming language with distinct typing built for high performance, modern systems and data-oriented programming.

Odin is the C alternative for the Joy of Programming.

hellope.odin
package main

import "core:fmt"

main :: proc() {
	greetings := []string{"Hellope", "Bonjour", "こんにちは"}
	for greeting, i in greetings {
		fmt.println(i, "=", greeting)
	}
}
package main

import "core:fmt"

main :: proc() {
	a := [3]f32{1, 2, 3}
	b := [3]f32{4, 5, 6}

	fmt.println(a * b) // [4, 10, 18]  component-wise
	fmt.println(a + b) // [5, 7, 9]
	fmt.println(a.zyx) // [3, 2, 1]    swizzle
}
package main

import "core:fmt"

main :: proc() {
	nums := make([]int, 3)
	defer delete(nums) // runs when main returns

	nums[0], nums[1], nums[2] = 1, 2, 3
	fmt.println(nums)
}
package main

import "core:fmt"

Permission  :: enum {Read, Write, Execute}
Permissions :: bit_set[Permission]

main :: proc() {
	p: Permissions = {.Read, .Write}
	fmt.println(.Execute in p)  // false
	fmt.println(p + {.Execute}) // Permissions{Read, Write, Execute}
}
package main

import "core:fmt"

Suit :: enum {Hearts, Diamonds, Clubs, Spades}

main :: proc() {
	symbols := [Suit]rune{
		.Hearts   = '♥',
		.Diamonds = '♦',
		.Clubs    = '♣',
		.Spades   = '♠',
	}
	fmt.println(symbols[.Spades]) // ♠
}
package main

import "core:fmt"

Pos :: struct { line, col: int }

Token :: struct {
	using pos: Pos,
	text: string,
}

main :: proc() {
	tok := Token{Pos{3, 12}, "hello"}
	fmt.println(tok.line, tok.col) // reach in without .pos
	fmt.println(tok.text)
}
package main

import "core:fmt"

main :: proc() {
	xs := [5]int{10, 20, 30, 40, 50}

	fmt.println(xs[:])   // [10, 20, 30, 40, 50]  whole array as a view
	fmt.println(xs[1:4]) // [20, 30, 40]
	fmt.println(xs[2:])  // [30, 40, 50]
	fmt.println(xs[:3])  // [10, 20, 30]
}
package main

import "core:fmt"

main :: proc() {
	grid := [3][3]int{
		{1, 2, 3},
		{4, 5, 6},
		{7, 8, 9},
	}

	search: for row, y in grid {
		for val, x in row {
			if val == 5 {
				fmt.printfln("found at (%d, %d)", x, y)
				break search
			}
		}
	}
}
package main

import "core:fmt"

divmod :: proc(a, b: int) -> (quotient, remainder: int) {
	return a / b, a % b
}

main :: proc() {
	q, r := divmod(17, 5)
	fmt.println(q, r) // 3 2
}
package main

import "core:simd"

// Vectorized check that a utf8 buffer is all ASCII
is_ascii :: proc(utf8: []#simd[16]u8) -> bool {
	acc: #simd[16]u8
	for chunk in utf8 {
		acc |= chunk // fold every set of code units into the result
	}
	return simd.reduce_max(acc) < 0x80 // every lane in the ASCII range?
}
package main

import "core:fmt"

rdtsc :: asm() -> (lo, hi: u32) [
	lo = %eax,
	hi = %edx,
] {
	rdtsc
}

main :: proc() {
	lo, hi := rdtsc()
	cycles := (u64(hi) << 32) | u64(lo)
	fmt.println("cycle counter:", cycles)
}

The Odin Principles

Simplicity

Odin has been designed for readability, scalability, and orthogonality of concepts. Simplicity is complicated to get right, clear is better than clever.

High Performance

Odin allows for the highest performance through low-level control over the memory layout, memory management and custom allocators and so much more.

For Modern Systems

Odin is designed from the bottom up for the modern computer, with built-in support for SOA data types, array programming, and other features.

Joy of Programming

We got into programming because we love to solve problems. Why shouldn't our tools bring us joy whilst doing it? Enjoy programming again, with Odin!

Batteries Included

Odin comes with high quality packages out of the box in its core library.

Odin provides official libraries for all major graphics APIs: OpenGL, Vulkan, Direct3D11, Direct3D12, Metal, wgpu, and WebGL 1 & 2.

Odin additionally brings you officially maintained bindings for popular libraries such as SDL2, GLFW, raylib, microui, miniaudio and much more, in its vendor library!

Simple DirectMedia Layer raylib OpenGL WebGL Vulkan Metal DirectX gpu box3d microui miniaudio curl lua ggpo commonmark commonmark

All product names, logos, and brands are property of their respective owners.

The Odin Community

Odin is Open Source

Odin is an open source programming language and contributions from the community are welcome! If you want to help out, check the issue tracker for open issues that may interest you. Those labelled help wanted are in particular need of community assistance right now.

Join the Odin Discord and help us bring the joy of programming in Odin to all. 🥳

Thank You!



GitHub Sponsors

Thank you to everyone who sponsor Odin.