r/odinlang • • 1d ago

Anyone purchased this book? Odin: A Practical Guide to Low-Level Programming on LeanPub? Is it AI-generated?

18 Upvotes

Hello, Came across this book which interested me as it touches upon concurrency in late chapters. Is this just AI-generated? Thanks. As an addendum, I already have Karl's book which is excellent but interested in more networking and concurrency options/roadmaps.

https://leanpub.com/odinapracticalguidetolow-levelprogramming


r/odinlang • • 1d ago

Tutorial Course: Learn Odin with Karl2D For people with some programming experience This has been made with AI!!!

Thumbnail ian-gb.itch.io
0 Upvotes

r/odinlang • • 3d ago

Understanding weird stored polymorphic proc misbehavior

7 Upvotes

I'm very new to Odin, and while messing around with polymorphic procs I ran into some behavior I can't intuit. It feels like a bug, but it could also be my misunderstanding the language. I have the following code:

Foo :: struct(T : typeid) {
    fun: proc(T) -> ()
}

bar :: proc(a : int) -> () {
    fmt.println("bar!")
}

baz :: proc(a : $T) -> () {
    fmt.println("baz!")
}

If I run the following:

f := Foo(int){bar}
f.fun(123)

I get the expected result "bar!". But if I pass in baz instead:

f := Foo(int){baz}
f.fun(123)

I get a segfault.

My intuition would be since Foo is polymorphic and can accept an int as it's T, and baz is also polymorphic and accept an int, I should be able to store and call baz. If its not a bug, why isn't it a compile error, like when passing a procedure with an incorrect type? Why is it a segfault? Are there any other proc storing pitfalls I should be aware of?

Edit: this is on version dev-2026-09-nightly:a2fb372, on linux.


r/odinlang • • 5d ago

Rocco 3D game engine: Walking through the entity game

Thumbnail
pixelsprout.dev
7 Upvotes

r/odinlang • • 6d ago

Trying to figure out how to use my own library...

7 Upvotes

Hey all,

so i've been working on an http 1.1 compliant server library for the past few months (it's been a while since i looked at it) and i'm trying to figure out how to actually USE the library. I've seen recommendations that the best way to use it "globally" is to put it in a shared dir in the odin soruce files which is great the big question for me though is thtat my http library is structured into different subpackages taht can create some friction with this approach for example:

i have response/build.odin for building responses but i also have a request/build.odin for building requests the question i have is based on namespaces for this modules.. if i do the direct shared directory approach i'll have to import res "http/response" then res.build() for the approach right? i'm sorry this is the first language i've ever really done something this deep and detailed in so i'm not quite sure how it all comes together (in rust it's a cargo dep so it's slightly simplified in this aspect).

the question is mostly if that's how it works OR if there's a way to define a "header" file like in c where i can define abstractions for the subpackaged functions to be directly called from http "http" and then do something like http.res.build(""""") or http.resbuild() and the like.

thankfully AI is bubkiss at understanding how odin really works so i can actually learn how this works

I'm not really sure what i'm saying or how to verbalize what I mean so if you need more from me to answer feel free to ask and i'll do my best.


r/odinlang • • 7d ago

Inferring type of variable from usage

10 Upvotes

``` init :: proc() -> GameState { gs := {} reset(&gs) return gs }

```

In this case you can infer the type of gs from the signature of the resetfunction and return gs statement. But it doesn't work in Odin.

Is this intentional?


r/odinlang • • 8d ago

making a software-rendered mpd client for pixel art people in Odin!

46 Upvotes

r/odinlang • • 9d ago

I thought I'd try to make video series on graphics programming in Odin, here's ep 1 - "Setting up SDL"

Thumbnail
youtube.com
38 Upvotes

r/odinlang • • 9d ago

Using Odin's RTTI for Shader Interop

32 Upvotes

Odin's RTTI (Runtime Type Information) features can be very useful if you're working with graphics API's. I made a quick little proc that checks if a given struct would match in layout with a Constant Buffer in HLSL:

// Checks if a given struct would align the same way in an HLSL's constant buffer
is_struct_aligned_to_cbuffer :: proc(cb_type: typeid) -> bool {

    if reflect.align_of_typeid(cb_type) != 256 {
        lprintfln("Constant buffer struct needs an alignment of 256")
        return false
    }

    current_hlsl_offset: int

    for i in 0..<reflect.struct_field_count(cb_type) {
        sf := reflect.struct_field_at(cb_type, i)
        field_size := sf.type.size

        // if it's more than 16 bytes, just align it to the row
        if field_size > 16 {
            align_to(&current_hlsl_offset, 16)
        } else {
            // If it's a basic scalar type... align it to the type alignment
            if is_basic_scalar_type(sf.type) {
                align_to(&current_hlsl_offset, field_size)
            }

            offset_start := current_hlsl_offset
            offset_end := current_hlsl_offset + field_size

            if offset_start / 16 != (offset_end - 1) / 16 {
                // crosses row boundary. add padding so it starts at next row.
                current_hlsl_offset += 16 - (current_hlsl_offset % 16)
            }
        }

        if cast(int)sf.offset != current_hlsl_offset {
            lprintfln("Field: %v is misaligned.", i)
            return false
        }

        current_hlsl_offset += sf.type.size
    }

    return true
}

(Note: This is very incomplete. This code will not predict exactly how the struct would get laid out in HLSL. But even in this form, it's very useful for me. I might improve it in the future)

This is very useful, as nothing will warn me otherwise if the struct's layout does not match its HLSL counterpart. Nasty bugs thus occur. I check this when creating a Constant Buffer, where an Odin struct type is passed:

// created buffer on the upload heap, and maps it. keeps it mapped
cb_upload_create :: proc(cb_type: typeid, pool: ^DXResourcePool, name: string = "") -> ConstantBufferUpload {
    assert(is_struct_aligned_to_cbuffer(cb_type), "CONSTANT BUFFER STRUCT IS MISALIGNED!")

    /// rest of the proc
}

The HLSL code for the struct is auto-generated from the Odin Struct. So I only have to write it once.

GeneralConstants :: struct #align (256) {
    view: dxm, // Row 0-3
    projection: dxm, // Row 4-7

    // Row 8
    inv_screen: v2, // 1.0 / (width, height)
    screen: v2,

    // Row 3
    sb_sprites_idx: u32, // index of the sprite structured buffer into the resource heap
    tx_idx_quad_out, tx_idx_post_process_out: i32,
}

/// ...

ldx.dx_generate_hlsl_types({Sprite, GeneralConstants}, "shaders/gen/lucy2d-structs.gen.hlsl")

This code is generated from that:

struct GeneralConstants {
    float4x4 view;
    float4x4 projection;
    float2 inv_screen;
    float2 screen;
    uint sb_sprites_idx;
    int tx_idx_quad_out;
    int tx_idx_post_process_out;
};

You can then #include this file in other HLSL files.

The layout for constant buffers in HLSL is very particular. You can only check that a struct is aligned in this particular way with something like Odin's RTTI. This is a very good resource that helped me understand how constant buffers are laid out.

As an aside: I also generate the Vertex Input layout from an Odin Struct, in pso_create

// vertex buffer
Vertex :: struct {
    pos: v3 `POSITION`,
    normal: v3 `NORMAL`,
    tangent: v4 `TANGENT`,
    uv: v2 `TEXCOORD`,
    uv_2: v2 `TEXCOORD_SECOND_UV`,
}

// ...
ct.psos[.GBuffer_Pass] = pso_create(gbuffer_shader_filename, &ct.root_signatures, &g_resources_longterm, PSOParameters {
    vertex_input = Vertex,
    /// Rest of call.
)

The Input Layout for the vertex shader is auto-generated from the Odin Struct.

Though on my new 2D engine, so far I have not needed any kind of Vertex Input Layout. I render sprites by vertex pulling.

You can read all this code in-context here

Link to post on my website


r/odinlang • • 10d ago

Physics Engine in Odin from Scratch, Part VI

Thumbnail
marianpekar.com
62 Upvotes

r/odinlang • • 11d ago

First impression / Pet project - HTTP server

37 Upvotes

Hi guys, I just wanted to share my first impressions of using Odin.

I come from the JS land and have used it for almost everything. However, from some time ago, I see less and less value in spending all my time learning high-level abstractions (frameworks, and other tools in that ecosystem), while missing important low-level concepts. Honestly, I also started experiencing less joy from doing it.

Tbh, I did not have a strong reason for choosing Odin, I saw it in one of ThePrimeagen's vids, and it simply looked very cool.

My first project is a very basic HTTP server, I have really enjoyed using the language, and I am planning to continue with it.

That's it :)


r/odinlang • • 12d ago

Scrolling gotta got brrrrrrrrr - text editor demo.

72 Upvotes

Hey all. Here is my text editor scrolling 250k sqlite3.c file. tree-sitter highlighter. piece table implementation for text editing. Closer to the end of the video will be FZF picker and multicursor demo. On the right side you can see mem and cpu usage in btop. I'm having a lot of joy with odinlang and sdl3.


r/odinlang • • 18d ago

Strange odin bug(?)

17 Upvotes

I'm writing it more to show bizarre bug than to report and laugh from how bad the language is(its not)

So I tried to make ipc for my app, and when I made a switch to show ipc help commands it stopped working with error Refused.

also for some reason when I add println(os.args) before then it works

I tested with println("hello"), println(os.args[0]) and even looping through all args and printing them one by one and it does not work.

odin tells me that I have version dev-2026-08 which is also strange because nix has dev-2026-05 on stable branch at the time of writing this. Even unstable is before 08(it's on 07a), so I genuinely have no idea how I have 08 installed

Edit1: also for some reason that workaround exist only when running main process with -debug flag, and when running without the second process cant connect either way

Edit2: when I deleted both switch and print, then it works with sending when -debug is not provided, but if print exist, then it still allows to run only with -debug

Edit3: when run without switch and print... it does not work when optimized for speed but runs normally with default optimization??? what kind of bug is that???

Edit4: Ok, there is no error in language, it was all my fault. I passed ^App struct to thread by &app, which resulted in overflow


r/odinlang • • 20d ago

Can Odin/Raylib be used to IOS/Android apps!

17 Upvotes

I am new to Odin and I used it with Raylib and man I fall in love!. I want to continue learning and build a mobile phone app (away from this AI insanity). Can Odin/Raylib be used for such project. thanks


r/odinlang • • 23d ago

I think my renderer is coming along nicely

72 Upvotes

I've been working on my game, an immersive sim I'm making using Odin and Sokol and I think the renderer finally reached a point where it looks decent. Still working on the reflections though


r/odinlang • • 25d ago

Replacing the Windows start menu

Thumbnail
gallery
33 Upvotes

My first project with Odin was, as the title suggests, replacing the Windows start menu.

I started by digging into the windows api’s and learning how to create a window. That was easy enough. Decided I needed to separate windows. One for the main process and one to hide the start icon. Up until windows 8 it appears adjusting the behavior of the super key and the windows icon on the taskbar was simpler. Now it is very convoluted and protected. I decided I would simple create a low level keyboard hook and draw an icon over the top and adjust placement when the taskbar adjusted. Turns out Odin did not have all the api bindings I needed so I had to create some foreign imports and empty structs to reimplement children of the IUknown interface.

After I had basic expected behavior of the taskbar and winkey I turned my attention to the main process and came at a fork in the road. After reading more into the windows docs it seemed the direct2d api was the obvious choice. Problem was Odin did not have a pre existing library for it. I was faced with a decision either switch to the direct3d api or re-implement a ton of bindings. I went with the former. This took me down the deep and dark road of the directX11 api. Probably spent 100 hours just reading docs. After a week I got the window drawing shapes. Then I needed icons. This meant learning basic HLSL and the shader pipeline. Finally I could draw icons and layout my start menu. I learned where windows stores pinned start menu apps and created a procedure to generate app data from the .lnk files. Now I was drawing rectangles with icons. I created an event storage and made the boxes highlight on hover. Implanting fonts stash for text wasn’t so bad. Finally I have a rough alpha of my project. Pictures attached and GitHub repo below. Honestly this has been a fun journey. It’s finally at a point where I can use it and track bugs and work on it over time until it’s the defacto option. Thank you to anyone who read this.

GitHub:

https://github.com/gamershoney/thor-start


r/odinlang • • 25d ago

Try the new Karl2D Playground: You can edit and recompile the Odin code, directly in your browser!

Thumbnail
karl2d.com
100 Upvotes

Technical details: The Odin compiler runs in your browser. Even on your phone! This is enabled by an experimental Odin compiler fork called wodin: https://github.com/karl-zylinski/wodin

wodin has a WASM backend that lets it emit WASM directly, without LLVM. The Playground site runs wodin, which compiles the gameplay code and emits new WASM, which is the run within the browser. Note that wodin's WASM backend is AI generated: It's roughly 20000 lines of C++. Nevertheless, I am flabbergasted that this is even possible.


r/odinlang • • 26d ago

My first (completed) Odin project - Trackor the issue tracker

Thumbnail
github.com
30 Upvotes

Hey all i've been developing my own DAP using Miniaudio and Raylib to learn memory management and to have a really cool tool to listen to my Flac files... i've learned an incredible amount through that project but I found my self using TODO.md in the project instead of just having a simple CLI friendly issue trackor. I know the idea isn't new but i did think for a simple 1-2 day project (ultimately it was closer to 4 days cause i'm a newbie) now i have my own issue tracker for myself.

leaving it here for any potential feedback or if anyone wants a tool like this!


r/odinlang • • 27d ago

Made a wobbly planet

84 Upvotes

Learned a lot of rotation math and had a lot of fun and headaches

Made using odin and raylib no AI has been used

The source code is available here for anyone interested

https://codeberg.org/pwnM/planet


r/odinlang • • 29d ago

My first Odin project (Solar system sim)

71 Upvotes

This was a learning project to try to learn Odin, OpenGL and Physics/Math it evolved to be more of the latter :)

I felt like i struggled a bit a how to structure things in Odin.

I'm happy for any feedback or pointers regarding the Odin parts or anything else.

https://github.com/lounge/sol_sim


r/odinlang • • Sep 04 '26

Help with type casting

4 Upvotes

[SOLVED] use microarch flag

I've noticed issues when using runtime/modified values inside a struct when using raylib.

I was trying to draw a rounded rectangle that follows the mouse pointer while highlighting the cell position in a grid.

``` package test import ray "vendor:raylib"

main :: proc() { ray.SetTargetFPS(20) ray.InitWindow(200, 200, "Test") defer ray.CloseWindow() for !ray.WindowShouldClose() { ray.BeginDrawing() defer ray.EndDrawing() ray.ClearBackground(ray.BLACK) ms := ray.GetMousePosition() mx := f32(i32(ms.x)/50) * 50 my := f32(i32(ms.y)/50) * 50 rec := ray.Rectangle{mx, my, 50, 50} ray.DrawRectangleRounded(rec, 0.3, 10, ray.YELLOW) } } ```

Can someone tell me why this code fails and whether this is a known issue or do I need to use a specific technique to make it work?

P.S.: I'm fairly new to odin and should probably look into more resources, but I haven't found a working example for this problem yet.

Post P.S.: The above code broke after the May 2026 release of odin. No idea why as of yet.


r/odinlang • • Sep 04 '26

Thinking about learning Odin

13 Upvotes

So what are the reasons/main selling points and philosophies behind Odin and do you think they are implemented well? Because saying something is a design philosophy is easy, actually implementing it, so someone who writes code feels it is the harder part.
I like languages which have something special about them, or a nice eco system, for example the ownership model of rust, the pointer arithmetic in C, C# for web apps and the perfect integration of efcore to load data dynamically without thinking much about it and Python for the fact that basically everything exists there. Odin has first class support for a lot of graphics apis, so developing code which runs well on GPUs should work really great with it? What are your experiences?
My dream project would be to make an AI/ML library, which runs calculations on the gpu and works on most machines (I thought about using wgpu if possible)


r/odinlang • • Sep 03 '26

Physics Engine in Odin from Scratch, Part V

Thumbnail
marianpekar.com
75 Upvotes

r/odinlang • • Aug 31 '26

[Newbie] Cant find installation instruction for fedora

8 Upvotes

I want to install odin on my fedora 44. But on this https://odin-lang.org/docs/install/ I coudnt find any clear linux or ubuntu commands to download and install fedora.

Apologies if this has been answered before, but im only here because i want to rely on official sources


r/odinlang • • Aug 30 '26

Is there any plan to streamline the Windows Install?

15 Upvotes
  • Download a .exe file
  • Open the file and install it
  • Check Add to Path
  • Only Download/Install the things you actually need to run Odin. Not multiple GBs of unnecessary stuff, especially for developers that don't code in C++.

I know it's not part of the plan for the 2027 Jan release, but maybe later in the next year?