Draft:Odin (programming language): Difference between revisions

Content deleted Content added
m Added wasm
Added various references, added better description, more examples.
Line 15:
| file ext = .odin
| website = {{URL|//odin-lang.org/}}
| influenced by = [[C (programming language)|C]], [[Pascal (programming language)|Pascal]], [[Go (programming language)|Go]], [[ModulaOberon-2 (programming language)|Rust]], [[SwiftNewsqueak]], [[JAI_(programming languageprogramming_language)|SwiftJai]]<ref>https://odin-lang.org/docs/faq/</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>.
Odin is a general-purpose programming language with distinct typing, built for high performance, modern systems, and built-in data-oriented data types.
 
The language is designed for "high performance, modern systems, and built-in [[Data-oriented_design|data-oriented]] data types", supports [[compile-time]] [[parametric polymorphism]], [[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>
 
 
==Examples==
Line 46 ⟶ 49:
</syntaxhighlight>
 
===Array programming example===
<syntaxhighlight lang="go">
package main
 
import "core:fmt"
 
main :: proc() {
{
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]
}
 
{
a := [3]f32{1, 2, 3}
b := swizzle(a, 2, 1, 0)
assert(b == [3]f32{3, 2, 1})
 
c := swizzle(a, 0, 0)
assert(c == [2]f32{1, 1})
assert(c == 1)
}
 
{
Vector3 :: distinct [3]f32
a := Vector3{1, 2, 3}
b := Vector3{5, 6, 7}
c := (a * b)/2 + 1
d := c.x + c.y + c.z
fmt.printf("%.1f\n", d) // 22.0
 
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_shorter :: proc(a, b: Vector3) -> Vector3 {
i := a.yzx * b.zxy
j := a.zxy * b.yzx
return i - j
}
 
blah :: proc(a: Vector3) -> f32 {
return a.x + a.y + a.z
}
 
x := cross(a, b)
fmt.println(x)
fmt.println(blah(x))
}
}
</syntaxhighlight>
 
==Notable software built with Odin==
* [[EmberGen]], a [[real-time fluid simulator]] by [[JangaFX]].
 
==See also==
{{Portal|Free and open-source software|Computer programming}}
 
*[[C (programming language)|C]]
*[[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]]