5 reasons why Odinlang is great for gamedev ✨
ฝัง
- เผยแพร่เมื่อ 1 พ.ย. 2023
- Why I think Odin Programming Language is a good fit for game development! Follow me on Twitter: / karl_zylinski or join my Discord server: / discord
Timestamps:
00:11 -- 1. Built-in bindings for gamedev libs that just work
02:12 -- 2. Like C, but less annoying and easier to learn
03:43 -- 3. Support for custom allocators and tracking allocators
05:35 -- 4. Low level with "high level feeling"
07:36 -- 5. A non-precompiled and readable standard library
Software I use:
Odin Programming Language: odin-lang.org/
Raylib: www.raylib.com/ (Odin comes with bindings)
Sublime Text: www.sublimetext.com
OBS studio (for recording this video): obsproject.com/ - เกม
Holy shit this is amazing. I had Odinlang recommended to me before, but I didn't thing it was THAT good. I'll definitely use it on my next project.
It really is C with everything I dislike about C fixed ♥
@@karl_zylinskithis should be the quote on the odin home page lol, cheers, love the vid, subbing now
I’m glad raylib is getting traction. Really good library
NOTES:
00:50 -- When I say "compile and link raylib" I mean that when your code compiles it will compile the raylib bindings along with it. The stuff in raylib.odin dictates how it will link raylib. I do not mean that it actually compiles the raylib source, that stuff is precompiled inside the .lib and .dll files you find in vendor/raylib.
Outline with timestamps:
00:11 -- 1. Built-in bindings for gamedev libs that just work
02:12 -- 2. Like C, but less annoying and easier to learn
03:43 -- 3. Support for custom allocators and tracking allocators
05:35 -- 4. Low level with "high level feeling"
07:36 -- 5. A non-precompiled and readable standard library
The reason why I use Odin is definitely the fast compile times (even compiling the source code of the compiler is very fast)
Although, the compiler is still written in C++. But I guess it's written in a way that makes the compilation very fast (it uses "unity builds" and no modern C++)
Planning to try this out with raylib to port some demos I’ve made. Hearing normal devs tak about it is a bit less intimidating than hearing gb talk about it lol
Good to know ✨ cheers!
That was very instructive, thank you
Thanks for watching!
I've been so busy with work for the past few months. I miss tinkering little stuffs with Odin.
Hope you find some time!
Thanks for review! I wonder if Jonathan Blow saw this language before inventing his own.
I think this language got started in 2016, Blows language got started in 2014-2015 I think. A few things in Odin have been inspired from Jai, and the syntax has similarities, but they are also quite different in other ways.
Hey, a gamedev question. So how did you do your animations because when I was trying to get it on my game with raylib and Odin I couldn't get it.
Hi,
My animation files are sprite sheets, i.e. a horizontal image containing all the frames.
In my code the animations work like 'flip books', i.e. it uses a rectangle to look into one of the frames of the sprite sheet a time. It uses a timer to know when to switch frame, when it switches frame it moves the rectangle to the next frame in the sprite sheet. In Raylib I would use rl.DrawTexturePro to do this, since it lets me specify both a source rectangle (where in the sprite sheet to look) and a dest rectangle (where in the world to put my sprite).
does odin have interop with C or C++ or compiler built in for C++ as long as you dont have either of these then no other lang can really be great for gamedev
It has interop with C. You can call C functions using C calling convention and easily bind to C libraries. The Raylib bindings show how to interop with C quite nicely: github.com/odin-lang/Odin/blob/master/vendor/raylib/raylib.odin (there are also a bunch of other C library bindings in the vendor folder)
It does not interop with C++, but many C++ libs have a C wrapper / expose functions with C linkage for the purpose of interoping with other languages.
Hi there, thanks for the video! What's the debugging situation like with Odin? I see you use Sublime, are you able to attach to debugger, put breakpoints etc?
Hi! Thanks for watching
I use Windows, but this is what works for me: If you compile with -debug option, then it generates .pdb files. With that you can debug from within Visual Studio, VS Code or RemedyBG. Breakpoints also work. VS Code seems most popular for doing the debugging.
A year back I wanted to make use of xorg instead of SDL abstraction layer and Odin made it painful to work with
That's unfortunate. What was the issue?
Have you also tried zig ? What's your opinion on the differences ?
Only tried it a tiny bit. It seems like a good language and the differences are not that big. Odin is a bit more minimalistic.
is there file-level visibility scopes or if you import file it will leak every function inside of it?
There are only package-level visibility scopes.
If you write
import "renderer" then all those things in renderer will live under renderer.blabla
if you write
import ren "renderer" then all those things in renderer will live under ren.blabla (i.e. you can give local aliases to imported packages)
This is also how you import standard library things:
import "core:strings" -> you can use all the strings stuff by typing strings.blabla
Packages are essentially folders, all files within a folder/package will see all code in that folder. The main reason to split things into separate files within a package is for keeping things organized, but it does not introduce any named scopes. You never have to write code to import code from separate files within the same package, so organization within a package tends to be quite painless.
It is similar to how one writes code in a C project, with the very important difference that imported libraries (packages) won't litter your program's global namespace.
@@karl_zylinski in C if it's not defined in headers its accesible only within C file. How does it work in Odin? What if I want some functions to stay hidden? Should I build some private library then to make them out of export scope?
Yes, sorry, I thought of how I used to code C with "unity builds" , I got so used to doing that.
You can put @(private="file") in front of things if you want to hide them inside the file. But in my experience there is little need to explicitly hide things from oneself.
Is there an SFML binding yet?
Doesn't seem like it. If you want something similar I recommend trying Raylib or SDL2. Raylib is a nice fit together with Odin
@@karl_zylinski cool! I love your videos btw. Odin seems like a cool language. But you should go back to your old nickname "slim shadegren" i think ;)
@@daikenkaiMusic ahhh, haha, its you!! it only showed the channel name lol
Thanks a lot :D
Wow this is cool
Could you please create more tutorials on Odin programming?. I wish you could make a simple game engine without using third party libraries.
Hi. I have these tutorials studio.th-cam.com/users/playlistPLxE7SoPYTef1jYHJ6NxNgocVjQKkq7eEa/videos
However, they use Raylib, which is a third party library. I don't think I will be doing any tutorials on general engine development. I think its better to just make a game and only write the code the game needs, rather than write general engine code and then write a game on top of it.
Care to make a video about your Sublime Text setup for Odin? How to set things up to actually start deving?
I have actually planned to exactly that! Stay tuned
Hello again. I have made a video about this here: th-cam.com/video/7KASj2v4iRk/w-d-xo.html I will also soon make more basic beginner videos that will show the whole process of downloading the compiler.
@@karl_zylinski Fast as light. Thanks. Going to check it out right away/
Odin is a great language for games. I use c++ in my day job and have been looking for a language with the power of c but with less of a setup time for quickly prototyping or making tools. I tried zig - too verbose. I also couldn't be bothered to learn the build system. Go is a great language but lacks the speed and is a little too high level for my purposes. Rust is just not practical for my purposes as it required way too much thinking and being careful with the way you code. So far Odin seems to be the perfect fit for my needs. Easy to pick up and get work done quickly, but with everything you need.
The only problem for me would be if I wanted to release a game for consoles. I'm not sure of how difficult it would be. If at all possible. I suppose if we were to output the game as a library it could be linked to the console libraries. Something worth looking into at some point.
Congratulations on the release of Cat & Onion. I will check it out properly soon.
Thank you! I agree with you completely on why it's so good for games.
As for consoles, there tends to be problems on playstation or xbox (I can't remember which) with that they want you to use their own compilers... I think Odin in theory needs to be translated to C and then compiled. Which might happen in the future if Odin gets a new backend that has been in the works. That backend might support outputting C. We'll see!
Yeah. Technically a library output for the correct target should work. But as you say there are restrictions on what you are allowed to do. Also Sony used to have proprietary graphics libraries which would be a hurdle. It's been a few years since I wrote a game for consoles so I have no idea of the state of play now. I miss the old days when we wrote games in pure assembler. That was fun. Nim style C output would be very cool. Though if someone really wanted to publish on console then converting a game from Odin to C by hand wouldn't be too difficult.
🧙♂👍
Odin is god tier
Is a tracking allocator the same as an arena allocation?
Hello! No, the tracking allocator can wrap any other allocator. It tracks when the allocation happened, so it can tell you that you forgot to release that memory. An arena allocator is an allocator that has a set arena or area in memory within which the allocator can take memory from, and you can also deallocate the whole arena in one go.
@@karl_zylinski Got it it. Thanks!
but I love fighting the linker!
friday night
crack open a beer
time to fight the linker
I don't know how I feel about the "batteries included" in a language. It's like C is beautiful, C++ is a "monstrosity". I kinda fear Odin might end up in the C++ camp at some point. What are your thoughts on that?
The 'batteries included' are bindings to popular libs. Those bindings live in the 'vendor' folder, which is totally separate from the 'core' folder. The 'core' folder contains the standard library. The standard library does not have any dependencies on anything inside the vendor folder. You can remove the whole vendor folder (removing all those included batteries), and the language works fine anyways.
So therefore, I say that it does not matter. The reason C++ is such a monster is because they add lots of weird things to the core language and also add too complicated things to the standard library. Odin does none of those two, and the creator is very conservative on extending the core language.
Having these batteries included is great for making the first impression for new users very straight forward, without polluting the standard library.
@@karl_zylinski Okay. That sounds good. I absolutely agree that it's a great way to get some people over to try it out. I have been playing with Raylib in Nim and it's a good experience but could be better so I do get the marketing aspect of it.. Thanks for explaining
Null string are not a "design mistake of c", design of c is simplicity - it gives all the fundamental things, rest is up to the programmer. Just make a string that does know it's size, you have all the tools needed.
It depends on the perspective you look at it from. Your perspective makes sense within a C codebase. Mine is more from the angle of using libraries written in C from other languages. And in those cases the null termination character means that you often have to allocate strings when interfacing with C libraries, just to put a null at the end. From that perspective C is putting metadata at the end of a block of data instead of just having it as a number next to the block of the data.
@@karl_zylinski I just don't think it's a design flaw of C itself, rather that of the standard C library. Life would be much easier if the standard library included a proper string type, then other libraries would just use it. It's a shame it doesn't
I was loving it until I heard "dynamic generic array". I don't like anything that has magic underneath.
I agree that \0 strings are annoying in C.
have you tried zig?
I don't like magic either. But with this, there's no magic. The dynamic array says which type it contains items of and all the code for how items are appended to the array is clearly readable in the standard library. Also you can use custom allocators to decide from where the dynamic array gets its memory. It's all very convenient, while you still have total control.
I've used zig very little. I might give it another evaluation after my current project is done.
@@karl_zylinski Thanks for that in depth reply. i think you will like zig too.
I think you need to do better and say why would I choose it for gaming, instead or Zig or Nim or V.
Fair enough! I think how interesting this video is depends on who watches it. For people who had problems in other languages with the things I listed, I think the video makes sense. But for people who haven't had my experiences in other languages, it is not a very informative video.
I actually think he does very well in pointing out why to use it for games, and it seems to be directly made for that. The comparison there I think would be Jai (if it ever releases). I would be more interested in hearing about what it feels like outside games where both Nim and Zig are amazing (don't know V so no comment on that)
@@ViaConDias While it is convenient, the "includes graphics libraries" is not actually a very compelling selling point, and I wish Odin would advertise its other strengths instead of that nonsense. Writing a script to generate the same bindings for pretty much any language can easily be accomplished. The bindings that are included are nothing special, just a clone of someone's project that was included in the vendor directory of the main Odin project. They aren't "built into the language" like some envision, nor even given any extra attention to make them more idiomatic for the language. I feel like Odin is trying to market itself too hard as a "game development language", when it actually has other strengths that are more noteworthy and set it apart from others.
@@ForeverZer0I agree and actually made another comment about this.
Marketing it as including these graphics libs only puts extra work on the developer. How will it even work? Will Odin have a minor version update when one of the libs makes a new release? If I am told it includes these libs I expect it to be ready with the newest version the same day as the libs release. But then I can't update my language if I'm working on a project that is using an older version of the graphics libs? I am not a language developer so it might just be me, but I don't know how this would be managed.
With Nim or Zig I know it is up to me to update my graphics libs when a new version is released.
This has made me not look at Odin for now. It is not as fast to develop in as Nim and it is not as small and concise as Zig and if I really want a language specifically made for gave dev I will probably beg JB for beta access to Jai.
Then again, I might very well be wrong about all of this 🙂
If it hasn't classes, to proper hide variables in C++ style, it's not proper for games, in my opinion.
I used to think so too. But in recent years I have coded using just structs where everything is public. If I truly want to hide how something works, then I make an API where it is not possible to fetch the internal structs.
I've never understood that idea of having private variables made unavailable by choice or using API or getters/setters, it's bad for performance and doesn't make sense has you could easily set a naming convention for private stuff, for example i always start the identifier of variables i don't want to touch with _var. Maybe i'm missing something for the reason why to use such a patern.
And majority of code that uses private variables in classes are simple getters and setters that do nothing more than simple equal sign, but you have your fancy encapsulation.
@@wiktorwektor123This is OO bad practice.
@@wiktorwektor123 yeah I honestly don't get it either. like your adding ton of boilerplate and unnecessary overhead, where you can just do __my_var or _pvar or whatever naming convention you want and achieve the same result, hell you could even do a special Macro if you really want it to look like a function call.
Nice shill video.
This must be a joke of sorts, or you don't know what shill means
@@RealAliens-fw4nq So, the video author is only pretending to like Odin and stands to gain from tricking us into liking it? Haha, hard to believe you're a real person.
@@RealAliens-fw4nq If that's not what you wanted to imply then you clearly don't know what shill means, which is strange since you think you can tell me what it means.
@@RealAliens-fw4nq You're not keeping track of what leaves your mouth much less understanding what you're reading and attempting to respond to. It's fine, we can leave it there.