Moving my game project from C to Odin language - AksDev

9 Likes

And he is still not using context allocators, I defer free/delete almost never, I just run "free_all(context.temp_allocator);"at the end of each frame

3 Likes

Hi, author here!

I appreciate the feedback. The current situation of my games Odin codebase is basically “I moved things from C to Odin” and there are still very much “C-isms” like defer delete.

The reason I am not using context allocators is because… I didn’t know how to! I am total C newbie, and I am even more an Odin newbie! I am still learning. :slight_smile:

So yeah, I will definitely look into context allocators and other cool stuff; I want to make the code much more Odin-y. :smile:

The purpose of this post was more to showcase the experience of moving from C to Odin, and less about trying to make the codebase the most best Odin code it is.

But yeah I write down all the feedback I get on this project and I want to make it better and learn more Odin as I work on it. It will take time though, this is just a hobby project for the fun of it.

Edit: Also did not expect to my post be shared here but I am glad haha :smiley:

4 Likes

This isn’t going to be related to Odin per se, but still.

I have ADHD. It’s my excuse for having bad memory. When working with C, I often forgot to edit either the header file or the source file and then I was wondering why something fails to compile or otherwise acts weird… Juggling two files for one “programmatic unit” is stupid. I hate it.

I’m in a similar situation and can kinda relate to it. One thing I that might help you is the understanding that as an ADHD your brain has trouble keeping attention. So you’d have way more things that your brain doesnt pay attention to, compared to a neurotypical person. Thigs that are monotone, like programming cause too little attention, while a distraction can eat almost all of your attention.

The way memory works is that if you don’t pay attention to your actions, you wouldn’t have a chance at remembering it. If you did something without thinking/paying attention, even if you have a very good memory. This is something I had realised this year and this realisation changed how I do certain things.

Pushing things to morning routines and forming habits is one of the greatest tools you have as an ADHD. Learn how to use it and QoL rises by a lot. Good luck, i guess :3

You see, Odin is like taking C and then… Writing it backwards. And remove the unnecessary cruft.

I can relate to this haha. There used to be times I wrote type first, then realised my mistake and typed colon and the name. Took a while to break the habit, but it did haunt me for the first couple weeks.

3 Likes

Oh I agree, I do this nowadays and it definitely helps! But the additional context switching that swapping between header and source file adds will forever be a bit of a bummer to me. I can deal with it, but it makes me work slower.

3 Likes

Yes, I can agree. Context switching is a pain. Especially when you have habits that prevent your workflow. Like imagine you open browser to google something work-related, and instead you start watching news because that’s in your habit. Minutes later you realise “wait why did i open the browser”, and it hits you. At this point I don’t know how to deal with that.

2 Likes

For what it’s worth, functions, procedures, routines, etc. have subtly different definitions… But it depends on who you ask.

A not-that-important difference in definition is an old school differentiation between callable blocks of code that return a value or not. Functions returning values and procedures not.

An actually important difference are side effects, but when people mean this they usually say pure functions. Side effects occur when a procedure modifies data outside their scope, e.g. global data or parameters passed to it.

So I would argue that C made the mistake of calling their callable blocks functions. Calling them procedures would have been less confusing.

1 Like

Oh thats interesting, thanks for sharing. I am really bad with terminology in the first place, and english not being my native language muddies things even further. :sweat_smile:

1 Like