Odin's coding ideology and compliance of code to such ideology

Hello everyone, I’m a first time dev in Odin and I wanted to get some quick feedback on what I wrote just now to know if I’m missing something about idiomatic Odin or if I’ve made an obvious mistake with my way of structuring code. What I got from the guidelines is “Have fun and code great things”, but I think there still might be untold “best practices” and I would be happy to have feedback on that, even tho I’m not sure I’ll keep everything, after all, I’m here to have fun. Here is the code (Just a cornflower blue window in glfw / OpenGL the way I would write it in C):

package main

import "vendor:OpenGL"
import "core:os"
import "core:fmt"
import "vendor:glfw"

init_window :: proc() -> glfw.WindowHandle {
    if !glfw.Init() {
        fmt.eprintln(os.args[0], ": Unable to initialize GLFW")
        return nil
    }

    window := glfw.CreateWindow(720, 360, "test", nil, nil)
    if window == nil {
        fmt.eprintln(os.args[0], ": Unable to open a GLFW window")
        glfw.Terminate()
        return nil
    }

    glfw.MakeContextCurrent(window)
    OpenGL.load_up_to(3, 3, glfw.gl_set_proc_address)
    OpenGL.ClearColor(0.392, 0.584, 0.929, 1.0)

    return window
}

update_window :: proc(window: glfw.WindowHandle) {
    OpenGL.Clear(OpenGL.COLOR_BUFFER_BIT)
    glfw.SwapBuffers(window)
    glfw.PollEvents()
}

run :: proc() -> int {
    window := init_window()
    if window == nil {
        return 1
    }
    defer glfw.Terminate()
    defer glfw.DestroyWindow(window)

    for !glfw.WindowShouldClose(window) {
        update_window(window)
    }

    return 0
}

main :: proc() {
    os.exit(run())
}

Thanks for reading this brick and thank you even more if you answer this. Have a nice rest of your day.

as far as i understand, it’s better to separate returned value and error: means return windows handle and bool (false for failure)
Or handle and errno
Pros - you don’t need specal values if result as signs of error

Ok, thanks, I wasn’t sure about that and the first version I wrote was returning errors as values, but I was thinking "Odin philosophy is to do simple, so the answer might just be to use the already made error value

Just program. There isn’t anything “idiomatic” nor any “ideology”.

At most, Odin is an imperative procedural programming language, which means if you are trying to program in an OOP or FP style, it will be hard to do in Odin. But otherwise, just program.

4 Likes