Skip to content

Instantly share code, notes, and snippets.

Some preliminary thoughts about Odin

(After trying it for one day!)

It's very similar to Zig but:

  • a little bit less verbose to write
    • a := 3 for variables, a :: 3 for constants, instead of in zig var a = 3;, const a = 3;
    • struct init does not require members myStruct : MyStruct = { 1, 2 }, vs in zig you must have members var myStruct = MyStruct{ .field1 = 1, .field2 = 2};
    • no semicolons at end of statements, no parenthesis around conditionals
  • heap allocations are sometimes unclear

Intro

Before we start:

  • might be running slow - streaming + old laptop
  • no slides, just text
  • live coding demo
  • will try to cover most cool things
    • but no multithreading/async/atomics and C interop details in talk

Who am I?:

@nothke
nothke / zig_check_step.md
Last active August 9, 2024 14:41
Zig check step - how to enable live compile errors

Make sure ZLS is installed.

In build.zig, add a check step after exe:

const exe_check = b.addExecutable(.{
    .name = "YOUR_PROJECT",
    .root_source_file = b.path("src/main.zig"),
    .target = target,
 .optimize = optimize,

Pros

  • Entering play mode is instant!
  • Has very intuitive coding style.
    • Very Unity-like, but even when it's not identical to Unity, it's very intuitive
  • Gives you an option to install daily master branch editor in the launcher
  • Profiling with Tracy!
  • Unlike Godot:
    • Prefabs (scenes) don't hide children
    • Can apply prefab from scene
  • Input is not a separate function, but it happens in update (like in Unity)

Preface

I'm comparing Godot mostly to Unity due to my ~10 years of Unity experience. I'm also primarily working in 3D and C# and that is what I want to use Godot for.

Terms:

  • by "export" I mean a variable exposed in the inspector, that's how Godot calls them
  • I use the word "prefab" to mean a scene that is intended to be instantiated multiple times, unlike a "level"
  • Godot's Resources == Unity's ScriptableObjects
  • Godot's collision shapes == Unity's colliders

Pros

Hello reader. This post is just for throwing ideas in the air, there is no implementation, it's all just in my head, and I don't know if this would even work in practice. It's incomplete as well.

INSERTNAMELANG is yet another embeddable scripting language! It's imperative, optionally-typed with write first optimize later philosophy.

It borrows elements from all languages so I'm not claiming any inovations.

I'll try to use as few words as possible in explaining. Here we go:

Variables are mutable

@nothke
nothke / tasks.json
Created October 20, 2023 19:06
zig tasks for VSCode
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "zig build-exe",
"type": "process",
"command": "zig",
"args": [
@nothke
nothke / cool-zig-features.zig
Last active October 20, 2023 19:05
Zig code I wrote on stream to show some cool features
const std = @import("std");
const DivisionError = error{
DivisionByZero,
OperandIsNan,
};
fn divide(a: f32, b: f32) DivisionError!f32 {
if (b == 0) {
return DivisionError.DivisionByZero;
[Shortcuts]
KisToolSelectOutline=S
KisToolSelectRectangular=B
KisToolTransform=W
KritaSelected/KisToolColorSampler=P; Z
KritaShape/KisToolBrush=Q
KritaShape/KisToolMultiBrush=none
clear=Del; X
deselect=A
duplicatelayer=Ctrl+D