Draft:Odin (programming language)
Submission declined on 21 November 2021 by Artem.G (talk). This submission is not adequately supported by reliable sources. Reliable sources are required so that information can be verified. If you need help with referencing, please see Referencing for beginners and Citing sources. Neologisms are not considered suitable for Wikipedia unless they receive substantial use and press coverage; this requires strong evidence in independent, reliable, published sources. Links to sites specifically intended to promote the neologism itself do not establish its notability.
Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
This draft has not been edited in over six months and qualifies to be deleted per CSD G13. Declined by Artem.G 3 years ago. Last edited by Wukuendo 2 years ago. Reviewer: Inform author.
| ![]() |
Comment: of 9 refs 6 are from odin website, and 2 are youtube videos Artem.G (talk) 18:35, 21 November 2021 (UTC)
![]() | |
Paradigms | imperative, procedural |
---|---|
Designed by | Ginger Bill |
First appeared | July 7, 2016 |
Typing discipline | Static, strong, inferred, nominal, structural, generic |
Platform | x86-64, ARM/ARM64, WebAssembly |
OS | Cross-platform |
License | 3-clause BSD.[1] |
Filename extensions | .odin |
Website | odin-lang |
Influenced by | |
Pascal[2], C, Go, Oberon-2, Newsqueak, Jai, GLSL[3] |
Odin is an imperative, general-purpose, statically typed, distinctly typed, compiled system programming language designed by Ginger Bill[4]
The language is designed for "high performance, modern systems, and built-in data-oriented data types", supports compile-time parametric polymorphism, runtime reflection, cross-compilation, manual memory management, array programming, and SOA data types.[5][6][7][8]
Example
package main
import "core:fmt"
main :: proc() {
program := "+ + * 😃 - /"
accumulator := 0
for token in program {
switch token {
case '+': accumulator += 1
case '-': accumulator -= 1
case '*': accumulator *= 2
case '/': accumulator /= 2
case '😃': accumulator *= accumulator
case: // Ignore everything else
}
}
fmt.printf("The program \"%s\" calculates the value %d\n",
program, accumulator)
}
Design
Odin is designed as being an alternative for the C programming language on "high performance, modern systems"[9][10], with features like compile-time parametric polymorphism, array programming, and runtime reflection.
Syntax
Odin's declaration syntax is inspired by Newsqueak and Jai.
// Variable declarations
x : int = 123
x := 123 // Type inference
// Constant value declarations
X :: 123
Y : int : 123
// Function declaration
Z :: proc() {}
Explicit procedure overloading
Odin has procedure overloading[11], but unlike C++ the overloads have to be specified explicitly.
bool_to_string :: proc(b: bool) -> string {...}
int_to_string :: proc(i: int) -> string {...}
// "to_string" is will call either "bool_to_string" or "int_to_string" depending on type.
to_string :: proc{bool_to_string, int_to_string}
Array programming
Odin provides array programming[12][13], enabling arithmetics on array elements:
a := [3]f32{ 1, 2, 3 }
b := [3]f32{ 5, 6, 7 }
c := a * b
d := a + b
e := 1 + (c - d) / 2
fmt.printf("%.1f\n", e) // [0.5, 3.0, 6.5]
The language also features "swizzling" of arrays, similar to the operation in shader languages like GLSL.[14]
// Declaring type Vector to be the same as array of 3 f32's.
Vector3 :: [3]f32
// Cross product using swizzle function
cross :: proc(a, b: Vector3) -> Vector3 {
i := swizzle(a, 1, 2, 0) * swizzle(b, 2, 0, 1)
j := swizzle(a, 2, 0, 1) * swizzle(b, 1, 2, 0)
return i - j
}
// Cross product using shorter swizzle notation
cross_shorter :: proc(a, b: Vector3) -> Vector3 {
i := a.yzx * b.zxy
j := a.zxy * b.yzx
return i - j
}
Matrix support
A matrix
is a mathematical type built into Odin[15]. It is a regular array of numbers, arranged in rows and columns. Odin's matrix support allows for matrix-array and matrix-matrix operations making it a Level 3 Basic Linear Algebra Subprograming language.
a: matrix[2, 3]f32 // matrix that has 2 rows and 3 columns with an element type of f32
b: matrix[3, 2]f32 // matrix that has 3 rows and 2 columns with an element type of f32
v: [2]f32 // array that has 2 elements with an element type of f32
a = matrix[2, 3]f32{
1, 9, -13,
20, 5, -6,
}
b = matrix[3, 2]f32{
3, 5,
7, 9,
}
v = [2]f32{2, -4}
m := a * b // matrix-matrix multiplication
vp := m * v // matrix-array multiplication
The internal representation of a matrix
in Odin is stored in column-major format[16] while the matrix literals are written in standard (row-major like) order (e.g. matrix[2, 3]f32
is internally [3][2]f32
(with different a alignment requirement)). Column-major is used in order to utilize (SIMD) vector instructions effectively on modern hardware, if possible.
Comparisons with other languages
The syntax of Odin resembles Go's syntax[17] with many adjustments.
Compared to C, Odin:
- Removes UB from the language
- Removes text-based preprocessing stage
- Introduces strong typing
- Adds array programming and improves runtime reflection
- Has explicit function overloading[18]
Compared to Go, Odin:
- Has manual memory management[19]
- Does not have interfaces
Notable software built with Odin
- EmberGen, a real-time volumetric fluid simulator by JangaFX[20][21][22].
See also
References
- ^ https://github.com/odin-lang/Odin/blob/master/LICENSE
- ^ https://gamefromscratch.com/odin-programming-language/
- ^ https://odin-lang.org/docs/faq/
- ^ https://www.youtube.com/watch?v=2YLA4ajby00
- ^ https://www.youtube.com/watch?v=iCqW_RepcW0
- ^ "Overview". odin-lang.org. Retrieved 2022-10-20.
- ^ https://graphitemaster.github.io/odin_review/#quality-of-life
- ^ https://medium.com/swlh/something-is-happening-to-our-programming-languages-and-i-like-it-a66447beade
- ^ https://odin-lang.org/
- ^ https://www.c3-lang.org/compare/#odin
- ^ https://graphitemaster.github.io/odin_review/#procedure-groups
- ^ https://bgthompson.com/blog/octonions-in-odin.html
- ^ "Overview". odin-lang.org. Retrieved 2022-10-20.
- ^ https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling
- ^ "A review of the Odin programming language". graphitemaster. Retrieved 10 September 2022.
- ^ https://odin-lang.org/docs/overview/#matrix-type
- ^ "Low-Level Programming with Odin Lang". Dev. Retrieved 21 September 2022.
- ^ "Overview". odin-lang.org. Retrieved 2022-10-20.
- ^ https://dev.to/patrickodacre/low-level-programming-with-odin-lang-perfect-for-beginners-5cc3
- ^ https://jangafx.com/software/embergen/
- ^ https://gamefromscratch.com/embergen-real-time-fluid-simulation-2/
- ^ https://www.allanmckay.com/289/
External links
Category:Programming languages Category:Cross-platform free software Category:Cross-platform software Category:Free compilers and interpreters Category:Programming languages created in 2016 Category:Statically typed programming languages Category:Systems programming languages