Hacker News new | ask | show | jobs
by gavinray 1261 days ago
I recently read about this on the Odin monthly news, it was super impressive!

In the section of the interview where you talk about the difficulties you had, you discuss the challenges of making Odin work properly on WASM, and how you needed custom memory-management and allocation strategies.

Could you talk some more about that experience and the general process of working with that sort of low-level bit in Odin? I've been experimenting with using Odin to write a DB from scratch.

2 comments

Sure! So far, Odin has been awesome for doing custom allocation. Everything in the core library that allocates takes an optional allocator parameter, which means that you can use quite a few of the core libraries comfortably even in embedded contexts, and make it all sit on top of an arena in WASM's weird memoryland if you need to without an issue.

Outside of the WASM context where Odin runs into some difficult friction, systems-level work has been reasonable. I wrote a good chunk of a C/DWARF debugger in both C and Odin to compare, and Odin was by far the more pleasant language to write it in, my Odin code was much smaller because I didn't need xmacros, and I had proper namespaced enums, tagged unions, and slices, but still looked/read pretty similarly to well-written C or Go. I did have to wrap a few syscalls myself though, because the core library doesn't quite cover things like ptrace or networking yet.

I've put a fair bit of work into getting cross-platform networking into Odin's core library, hopefully we'll see it show up soon enough, and get some of those common nice-to-haves crossed off.

Awesome, thanks for the reply! Looking forward to seeing those hit core hopefully!
Impressive work! Where is the net package getting worked on? Is it the "core_net" branch or do you have your own fork?
Yep, core_net is the bulk of it, and I have a fork with changes to bring it up to date with master, we're just hashing out final details to get it ready to wrap and ship at this point.
The interview in question, for those interested: https://odin-lang.org/news/newsletter-2022-12/#interview-wit...