<!-- Do not remove this line! -->
{{short description|Programming language}}{{Infobox programming language
{{AFC submission|d|n|u=Ncfishy|ns=118|decliner=S0091|declinets=20230815193453|reject=yes|ts=20230815182138}} <!-- Do not remove this line! -->
{{AFC submission|d|v|u=Xplane80|ns=118|decliner=Artem.G|declinets=20211121183548|reason2=neo|small=yes|ts=20211118005047}} <!-- Do not remove this line! -->
{{AFC comment|1=I think If submission is rejected by an Afc reviewer, so, don't submit for review, I suggesting you, firstly you ask for advice [[Wikipedia:WikiProject Articles for creation/Help desk/New question|here]] for your submission. ~~ <span style="background-color:magenta; padding: 2px 5px 1px 5px">[[User:Aviram7|<span style="color:white">αvírαm</span>]]<nowiki>|</nowiki>[[User talk:Aviram7|(tαlk)]]</span> 12:37, 27 November 2023 (UTC)}}
{{AFC comment|1=None of the sources used are reliable and/or independent and nothing suggests this can meet the notability guidelines. [[User:S0091|S0091]] ([[User talk:S0091|talk]]) 19:34, 15 August 2023 (UTC)}}
{{AFC comment|1=of 9 refs 6 are from odin website, and 2 are youtube videos [[User:Artem.G|Artem.G]] ([[User talk:Artem.G|talk]]) 18:35, 21 November 2021 (UTC)}}
----
{{Short description|Programming language}}
{{Draft topics|software|computing|technology}}
{{AfC topic|other}}
{{Infobox programming language
| name = Odin
| logo = The_odin_programming_language_logo.svg
| logo =
| paradigms = [[Imperative programming|imperative]], [[Procedural programming|procedural]]
| designer = Ginger Bill Hall
| released = {{start date and age|2016|06|02}}
| latest release version = dev-2025-06<ref>{{cite web |title=Release dev-2025-06 · odin-lang/Odin |url=https://github.com/odin-lang/Odin/releases/tag/dev-2025-06 |website=GitHub |access-date=3 June 2025 |language=en}}</ref>
| latest release version =
| latest release date = {{Start date and age|2025|06|02}}
| latest preview version =
| latest preview date =
| typing = [[Static typing|Static]], [[Strong typing|strong]], [[Type inference|inferred]], [[StructuralNominal_type_system|nominal]], type system[[Structural_type_system|structural]], [[Generic programming|generic]]
| platform = [[x86-64]], [[ARM architecture|ARM]]/[[AArch64|ARM64]], [[WebAssembly]]
| operating system = [[Cross-platformMicrosoft Windows|Windows]], [[Linux]], [[macOS]]
| license = [[BSD_licenses#3-clause|3-clause BSD]].<ref>{{cite web |title=BSD 3-clause license |website=[[GitHub]] |url=https://github.com/odin-lang/Odin/blob/master/LICENSE|access-date=2023-11-27}}</ref>
| license = [[BSD-3 License]]
| file ext = .odin
| website = {{URL|https://odin-lang.org/}}
| influenced by = [[CPascal (programming language)|CPascal]]<ref>{{cite web | url=https://gamefromscratch.com/odin-programming-language/ | title=ODIN Programming Language | date=13 April 2022 }}</ref>, [[PascalC (programming language)|PascalC]], [[Go (programming language)|Go]], [[Oberon-2]], [[Newsqueak]], [[JAI_(programming_language)|Jai]]<ref>{{cite web |title=Jai vs Odin systems programming languages | website=[[YouTube]] |url=https://www.youtube.com/watch?v=M763xHjsPk4 |access-date=2022-07-06}}</ref>, [[GLSL]]<ref>{{cite web | url=https://odin-lang.org/docs/faq/ | title=Frequently Asked Questions }}</ref>
}}
'''Odin''' is an [[imperative programming|imperative]], [[General-purpose programming language|general-purpose]], [[compiled programming language|compiled]] and [[statically typed]] [[system programming language]].<ref>{{cite web | url=https://www.youtube.com/watch?v=2YLA4ajby00 | title=Interview with Odin language creator gingerBill | website=[[YouTube]] }}</ref><ref>{{cite book |last1=Zylinski |first1=Karl |title=Understanding the Odin Programming Language |date=December 9, 2024 |edition=1st |url=https://www.amazon.com/Understanding-Odin-Programming-Language-Zylinski-ebook/dp/B0DQ1V7LW4 |access-date=24 May 2025}}</ref> It is designed as an alternative to the [[C_(programming_language)|C programming language]]<ref>{{cite web |title=Introducing Odin Lang (Japanese) |url=https://qiita.com/sh1so6/items/40bdda93d6fa2f094fd7 |access-date=2019-09-29 |website=Qiita}}</ref><ref>{{Cite web |date=2022-11-04 |title=Programming Games by Hand Using Odin |url=https://community.codenewbie.org/patrickodacre/programming-games-by-hand-using-odin-55lh |access-date=2023-11-27 |website=CodeNewbie Community 🌱 |language=en}}</ref>. It has features such as compile-time [[parametric polymorphism]], [[array programming]], and [[Type_introspection|runtime reflection]].<ref name=":0">{{cite web |title=Odin programming language review (quality of life) |url=https://graphitemaster.github.io/odin_review/#quality-of-life}}</ref><ref>{{Cite web |title=Writing an Operating System in Odin |url=https://flysand7.hashnode.dev/writing-an-os-kernel-in-odin |access-date=2023-11-27 |website=flysand7's blog |date=22 November 2023 |language=en}}</ref><ref>{{Cite web |last=hasen |date=2022-08-25 |title=Why I like Odin |url=https://hasenjudy.wordpress.com/2022/08/25/odin-praise/ |access-date=2023-11-27 |website=Hasen Judy |language=en}}</ref>
'''Odin''' is an [[imperative programming|imperative]], [[General-purpose programming language|general-purpose]], [[statically typed]], [[distinctly typed]], [[compiled programming language|compiled]] [[system programming language]] designed by [[Ginger Bill]]<ref>https://www.youtube.com/watch?v=2YLA4ajby00</ref>.
The language comes with bindings for several libraries and graphics APIs such as [[OpenGL]], [[DirectX]], [[Simple DirectMedia Layer|SDL]] and [[Vulkan]].<ref>{{Cite web |last=Mike |date=2022-04-13 |title=ODIN Programming Language |url=https://gamefromscratch.com/odin-programming-language/ |access-date=2023-11-27 |website=GameFromScratch.com |language=en-US}}</ref><ref>{{Cite web |title=Odin/vendor at master · odin-lang/Odin |url=https://github.com/odin-lang/Odin/tree/master/vendor#readme |access-date=2023-11-27 |website=GitHub |language=en}}</ref>
The language is designed for "high performance, modern systems, and built-in [[Data-oriented_design|data-oriented]] data types", supports [[compile-time]] [[parametric polymorphism]], [[Type introspection|runtime reflection]], [[cross-compilation]], [[manual memory management]], [[array programming]], and [[AoS_and_SoA|Structure of Arrays (SOA)]] data types.<ref>https://www.youtube.com/watch?v=iCqW_RepcW0</ref><ref>https://odin-lang.org/docs/overview/</ref>
== ExampleHistory ==
Work started on the language in July 2016<ref>{{cite web |title=Odin first commit |url=https://github.com/odin-lang/Odin/commit/f7a669d342c96451a3e0be84e2e51af8631f90ec |website=GitHub |access-date=24 May 2025 |language=en}}</ref>. Designer Bill Hall decided to make a language that could replace his needs for [[C (programming language)|C]] and [[C++]].<ref>{{Cite web |date=2016-07-08 |title=The Odin Programming Language |url=https://handmade.network/forums/t/1338-the_odin_programming_language#7533 |access-date=2023-11-27 |website=Handmade Network |language=en-US}}</ref> Since then the language has been developed as open source on GitHub.<ref>{{Citation |title=The Odin Programming Language |date=2023-11-27 |url=https://github.com/odin-lang/Odin |access-date=2023-11-27 |publisher=Odin}}</ref>. It was considered sufficiently widely used to be added to GitHub's Linguist in July 2020<ref>{{cite web |title=Odin's pull request to Linguist |url=https://github.com/github-linguist/linguist/pull/4676 |website=Github}}</ref>.
<syntaxhighlight lang="go">
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)
}
</syntaxhighlight>
== Design ==
Initially Odin was being designed as a replacement for the C programming language, however with features like compile-time [[parametric polymorphism]], [[array programming]] and [[runtime reflection]], it started to be designed more as a C++ replacement. The syntax of Odin resembles [[Go (programming language)#Syntax|Go]]'s syntax with some adjustments.
Compared to C++, Odin:
* Removes UB from the language
* Removes text-based preprocessing stage
* Introduces [[strong typing]]
* Adds array programming and improves [[Type introspection|runtime reflection]]
* Has explicit function overloading<ref>{{Cite web|title=Overview|url=https://odin-lang.org/docs/overview/|access-date=2021-11-15|website=odin-lang.org}}</ref>
Compared to Go, Odin:
* Has [[manual memory management]]
* Doesn't have built-in [[package manager]]
* Doesn't have interfaces
=== Syntax ===
Odin expects a UTF-8 encoded text file as its input. The file is required to have ''.odin'' extension. The declaration syntax is inspired by [[Newsqueak]] and Jai. Here's an example of some declarations:<syntaxhighlight>
a : int = 3 // Declares variable a of type int
a : = 3 // Declares variable a. Type is inferred from RHS expression
a := 3 // : and = are usually written together
a : int : 3 // Declares constant a of type int
a : : 3 // Declares constant a. Type is inferred from RHS expression
a :: 3 // : and : are usually written together
</syntaxhighlight>The semicolons are statement terminators and optional. Unlike Go, the Odin permits a newline in certain places where semicolon could otherwise be inserted, allowing programmer to have a higher selection of [[Indentation style|indentation styles]], for example chosing to use Stroustrup's variation of K&R indentation style:<syntaxhighlight>
if cond {
} else { // Go requires else to be on the same line as closing }
}
if cond {
}
else { // Odin allows else to be on the next line
}
</syntaxhighlight>
=== Untyped Literals ===
Odin allows numeric and string literals to not have a concrete type until the value is casted or assigned to an lvalue.<syntaxhighlight>
a: float = (2 - 1)/3 // assigns 0.333 to a
c: int = (2 - 1)/3 // assigns 0 to a
</syntaxhighlight>The untyped expression is calculated in the type to which it is being assigned or casted. For floats the computation would be equivalent to <code>(2.0-1.0)/3.0</code> and for integers its the same as <code>(2-1)/3</code>. In the case where the type of the variable is unspecified, the untyped expression is casted to the default type, that is <code>int</code>, if the untyped expression is composed of integers, and <code>float</code> if it contained untyped floats.
[[Constant (computer programming)|Constant]]<nowiki/>s can be untyped, meaning when these constants are used within other expressions they are treated the same as if they were untyped literals.
Under Odin terminology both untyped literals and untyped constants would have "untyped" types, which is a [[misnomer]].
=== Explicit procedure overloading ===
Odin has procedure overloading, but unlike C++ and Go the overloads have to be specified explicitly. Each overloaded is specified as a procedure with a distinct name. The overload is then specified explicitly by listing all the names of procedures that are being overloaded and giving the overload a new name.<syntaxhighlight>
bool_to_string :: proc(b: bool) -> string {...}
int_to_string :: proc(i: int) -> string {...}
to_string :: proc{bool_to_string, int_to_string}
</syntaxhighlight>In the example above the procedure <code>to_string</code> can is an explicit overload of <code>bool_to_string</code> and <code>int_to_string</code>. If <code>to_string</code> is called with <code>bool</code> parameter, <code>bool_to_string</code> will be called.
===Array programming ===
Odin provides [[array programming]] feature. The arrays of numeric types can be added, subtracted, multiplied together, while the compiler will implicitly do the same operation value-by-value.<syntaxhighlight lang="go">
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]
</syntaxhighlight>Using <code>swizzle(array, indices..)</code> function, the elements of the array can be reordered in an arbitrary way. The indices specify the which element of the original array that is placed at a given spot in the new array. <code>swizzle(a, 3,2,1)</code> will reorder elements of 3 dimensional array to be in backwards order. For arrays up to dimension 4, there is a shorter notation for swizzling, using combination of letter ''x'', ''y'', ''z'', ''w'' in any order.<syntaxhighlight lang="go">
// 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
}
</syntaxhighlight>
==Notable software built with Odin==
* '''EmberGen''', a real-time [[Voxel|volumetric]] [[Fluid_animation|fluid simulator]] by JangaFX<ref>{{cite web | url=https://jangafx.com/software/embergen/ | title=EmberGen: Real-Time Fluid Simulations for Fire, Smoke, and Explosions! }}</ref><ref>{{cite web | url=https://gamefromscratch.com/embergen-real-time-fluid-simulation-2/ | title=EmberGen Real-Time Fluid Simulation | date=9 May 2022 }}</ref><ref>{{cite web | url=https://www.allanmckay.com/289/ | title=Episode 289 - EmberGen | date=9 March 2021 }}</ref>
* [[EmberGen]], a [[real-time fluid simulator]] by [[JangaFX]].
== See also ==
{{Portal|Free and open-source software|Computer programming}}
* [[Go (programming language)|Go]]
* [[D (programming language)|D]]
* [[V (programming language)|V]]
* [[Rust (programming language)|Rust]]
* [[Zig (programming language)|Zig]]
==References==
*[[C (programming language)|C]]
<references/>
*[[Go (programming language)|Go]]
*[[Pascal (programming language)|Pascal]]
*[[Zig (programming language)|Zig]]
== External links ==
* {{Official website|https://odin-lang.org/}}
* [https://odin.handmade.network/ Odin at Handmade Network]
[[:Category:Programming languages]]
*{{Official website|https://odin-lang.org/}}
[[:Category:Cross-platform free software]]
*[https://odin.handmade.network/ Odin at Handmade Network]
[[:Category:Cross-platform software]]
[[:Category:ProgrammingFree and open source languagescompilers]]
[[:Category:Cross-platformProgramming languages created freein software2016]]
[[:Category:Cross-platformStatically typed programming softwarelanguages]]
[[:Category:Free compilersSystems andprogramming interpreterslanguages]]
[[:Category:ProgrammingSoftware languagesusing createdthe inBSD 2016license]]
{{Drafts moved from mainspace|date=November 2021}}
[[Category:Statically typed programming languages]]
[[Category:Systems programming languages]]
|