Skip to content
gingerBill edited this page Nov 15, 2021 · 34 revisions

Odin vs Jai

Time of writing: November 2021 (previously February 2020)

Similarities:

Differences:

Odin Jai
Publicly Available Private Beta Only (Currently)
Arbitrary Compile Time Execution
Compile Time AST modification (Outdated video: https://www.youtube.com/watch?v=59lKAlb6cRg)
Strong Typed with virtually no implicit conversions Many implicit conversions similar to C++
Pascal-family Type System C-family Type System
Modula/Go style directory-based package system File-based library system
Discriminated union type
bit_set
cstring *u8 (not equivalent)
distinct type declarations
Built-in map type (User-level type)
Slicing notation like Python/Go [lo:hi]
where clauses for procedure and record types #modify metaprogramming
switch statements which allow for multiple cases, ranges, and any/union types if cond=={ case x:
Explicit parameter declaration with for val, idx in array{} Implicit parameter declaration with for array { val, idx := it, it_index; },
as well as explicit for val, index : array {}
Extensive constant system which "just works" reducing the need for implicit conversions Basic constant system which can be extended with the compile time execution features
rune type for Unicode Codepoints s32 (signed 32-bit integer) (No default character type)
Unicode identifiers ASCII identifiers (currently)
Array programming Available explicitly through operator overloading
matrix type Available explicitly through operator overloading
Operator overloading
Explicit procedure overloading Implicit procedure overloading (Implicit Poylmorphism)
Zero is initialized Default struct fields
Built-in complex and quaternion types (User-level type)
rawptr *void
ptr: ^int; i := ptr^; x := &i; ptr: *int; i := <<ptr; x:= *i;
proc(T) -> U (T) -> U
proc(a, b: int, c: string) (a: int, b: int, c: string)
#soa data types (User-level type through metaprogramming and operator overloading) (Video: https://www.youtube.com/watch?v=zgoqZtu15kI)
Enumerated arrays
Iterators through procedures Iterators through macros
Ranged Fields for array compounds literals
Implicit Selector Expressions .A
#partial switch #complete if cond == {
Hygenic Macros
#body_text

Commentary

Jonathan Blow's language talk was a minor inspiration, and thus his language Jai, of which Ginger Bill is quite open about, He has have found that the main reason people compare the two languages is purely regarding the similarity of the declaration syntax. From a semantic standpoint, they are quite different (Jai being very C++ like, and Odin being more Pascal/Go like). It is regularly asked about it which is why the above minor table was produced for people to understand the differences at a glance.

The declaration syntax is similar to Jai's but Blow didn't invented it, and in fact took it from Sean Barrett. And with a little research, you can find that it was Rob Pike who first invented that syntax back in the early '90s for Newsqueak and Limbo.

Some of the similarities that Odin and Jai hold are not unique to either and can be found in earlier languages. using is a good example of this in that Ginger Bill was originally going to have with from Pascal but seeing how Jon applied that idea to "live variables" was pretty clever. And the uninitialized value --- syntax is copied from Jai but it turned out to be a life safer in that it saved the declaration syntax for (foreign) procedures literals without a body. The declaration syntax of Odin was changed for a week to a more conventional proc main() syntax because it was thought the problem was unsolvable until it was realized that it could reuse this token.

Other than that, Odin and Jai are very different languages with very different philosophies behind them.

Clone this wiki locally