How to run C code from Odin
16:44
2 ай бұрын
I'm writing an Odin book!
3:59
2 ай бұрын
Understanding arrays in Odin
29:37
Organizing Odin code
19:02
3 ай бұрын
How I made my game's camera nice
1:02
My Odin game programming workflow
10:00
Пікірлер
@cycomkid
@cycomkid 2 күн бұрын
Which audio software in background?
@karl_zylinski
@karl_zylinski 23 сағат бұрын
It's Reaper
@channel11121
@channel11121 2 күн бұрын
I think you shouldn't use type-inference in the examples, because it hinders being able to pick up the same concept in multiple places to reinforce it. Especially in the first example, there was an opportunity to clearly show that there's an int, then right below it, is how you declare a pointer to it.
@cycomkid
@cycomkid 2 күн бұрын
I wanted to purchase your game on steam with source code. But i am not sure steam is providing source code or not. I can see that it's available on itch, but i don't want to use itch. Can you confirm if source code will be available in steam or not?
@cycomkid
@cycomkid Күн бұрын
Any update karl?
@karl_zylinski
@karl_zylinski 23 сағат бұрын
I'm afraid the steam version does not have source
@cycomkid
@cycomkid 17 сағат бұрын
@@karl_zylinski bought on Itch
@leonun
@leonun 2 күн бұрын
nice
@ralphstube
@ralphstube 2 күн бұрын
Great lesson - playing around with the code and I see the passing by reference changes the value implicitly where as passing by value requires an explicit update to change the value - Being a real beginner to lower level is this something that is in your book and please can you do a video as it is a bit of a 'mind bender' for me: package pointers import "core:fmt" main :: proc() { number := 7 number_pointer := &number increment_number_point(number_pointer) fmt.println(number) fmt.println(number)// holds value number = increment_number_value(number) fmt.println(number) fmt.println(number)// holds value fmt.println(increment_number_value(number)) fmt.println(number) fmt.println(number) // doesn't hold value increment_number_value(number) // doesn't change value fmt.println(number) } increment_number_point :: proc(num: ^int) { num^ = num^ + 1 } increment_number_value :: proc(numb: int) -> int { return numb + 1 }
@deryilz
@deryilz 4 күн бұрын
great feature, i wish more languages had it!
@kencg6566
@kencg6566 5 күн бұрын
Clear explanation, thank you! Looking forward to the book. 👍✌️
@reunionproductions
@reunionproductions 14 күн бұрын
If you don't mind, I have a follow up question: I see in C&O you have a World struct, I have similar for my project. Currently I initialize World in one of the "highest" scopes and then I pass a pointer to it down into pretty much every procedure since most procedures need access to some part of it, and making it global doesn't seem at all right. Does this pattern seem OK to you, how do you pass all your world state and display state about the program? My concern is that for a sufficiently complex world, I've got a huge world struct with all kinds of nested fields of various complex types that I'm passing down through every procedure. The knee jerk solution feels to just split the world up into several separate structs, but then you start having quite bloated function signatures as every part of the world will still be needed deep in the function stack. So either way it seems unwieldy as the complexity of the program grows. Is there perhaps a pattern where I can effectively "summon" parts of the world state I need on demand in any procedure without passing down a pointer to some massive struct, or avoiding the need to have every function sig's argument list get increasingly long in an attempt to chop the world state up? Thanks for the Q&A, and cannot wait to buy the book!
@karl_zylinski
@karl_zylinski 14 күн бұрын
I have a global pointer to the current world. It was the most convenient solution for me. I don't always use the global everywhere however, since there are some procs that are used both while the game is running but also at "world creation". When loading a level there might be a new world being created, but the previous one is still held by the global pointer, so some procs still take an explicit world pointer to operate on. In general whenever gameplay wants to talk about the current world they can just grab the global world pointer and use that with procs that need a world. So the world doesn't have to be passed around everywhere anymore, which is convenient, but when I do need it I tend to fetch the current value of the world pointer and send it off to some proc that needs it.
@Sergeeeek
@Sergeeeek 12 күн бұрын
Is this something that's worth putting in Odin's implicit context parameter?
@Kai41k
@Kai41k 16 күн бұрын
In my opinion, platformers or similar simple games should be released only on mobile devices, and complex games or games with complex mechanics should be released on PCs.
@reunionproductions
@reunionproductions 17 күн бұрын
Cannot wait for this. The current Odin documentation just tells me nothing about memory management, it's only for people who are familiar with allocators and management strategies. I really want to move into a non-GC language but there's just zero understandable and practical introduction to the concept
@oldteen2
@oldteen2 17 күн бұрын
Great tutorial ! I just want to discover Odin and this video is a good start. Thanks ! I just bought your game on steam, I'm looking forward to playing
@karl_zylinski
@karl_zylinski 17 күн бұрын
Thank you!
@tigrux
@tigrux 21 күн бұрын
For someone new to Odin, the use of ^ instead of * looks odd.
@karl_zylinski
@karl_zylinski 20 күн бұрын
It's a pointy thing 😀
@empathy_monster
@empathy_monster 21 күн бұрын
I'm going through core:io but I'm pretty lost with getting user input from stdin. Maybe you could please consider putting a section in your book.
@empathy_monster
@empathy_monster 21 күн бұрын
Awesome channel! Can't wait for the book!
@buriedbits6027
@buriedbits6027 22 күн бұрын
I loved smash it. So this is the artist huh? Wow. I just discovered tear down on KZbin and was intrigued by the physics which adds to an important realism which is fun and familiar. Just like the real world.
@leeroy900
@leeroy900 23 күн бұрын
Thanks
@karl_zylinski
@karl_zylinski 22 күн бұрын
Thank you so much!
@Laurent_GameDev
@Laurent_GameDev 23 күн бұрын
Great explanations about memory leaks and a very clever solution to this problem proposed by the Odin language! Very interesting. Thanks Karl
@efv
@efv 23 күн бұрын
Thanks Karl for the excellent video series. However I have to offer some alternative advice. There are many languages that disallow cyclic dependencies between packages (or modules, or namespaces depending on what the languages call their organizing concepts). Go, Rust, and Haskell, for example strictly disallow cycles, Java and Scala I believe may allow them but it's problematic. Same with the .NET family of languages. The problem of code organization and dependency management is mostly independent of language. What it takes is planning, forethought, and conscious, intentional design. If you're learning a language, working in a new / unfamiliar domain, or are simply not very experienced, you are probably not in a position to plan a large complex project very well, so you will have problems organizing (via packages) your code correctly right out of the gate. This is one of the most obvious advantages highly experienced engineers bring to a project - experience around large project code organization. Dropping everything in a single package/namespace is an easy "solution" because it effectively ignores the primary mechanism for code organization and relies on globally unique naming instead. This non-organization method of organizing code is useful for everything from toy projects, demos, and learning examples to smaller production projects run primarily by one person or a small team. Small games, command line utilities, wrapping existing libs from other languages, things like this are small enough that you may not really need to organize (via package/namespace) the code. Once you get into larger projects involving large / multiple teams and hundreds of thousands or millions of lines of code, you better have a well developed philosophy about code organization, and it will involve multiple packages with carefully considered interdependencies, which allows for sub-teams to work more independently (which means quickly), work to a "contract" (or interface, or API), isolate the impact of code changes, make it easier to build discreet and focused tests, and many other benefits. It's good do introduce these concepts early in a software engineer's growth, so that these concepts and practices become engrained early. Because you're right that code organization done wrong is worse that no code organization. But no organization (or minimal, ad-hoc, unplanned organization) is limiting in proportion to the size of the project and team.
@surajmandal_567
@surajmandal_567 26 күн бұрын
Starting a C++ project is pain 😢.
@chandragunawan4105
@chandragunawan4105 27 күн бұрын
Your contents makes Odin and low level programming in general less scary. Thanks a lot Karl ! Ill buy your book once it comes out for sure !
@김로로-s4v
@김로로-s4v 27 күн бұрын
👍 great. But how do I run it in vs code?
@ItsJustMeJerk
@ItsJustMeJerk 27 күн бұрын
One thing I recently learned the hard way while using pointers for the first time: if you accidentally let the memory that your pointer refers to get freed, then your pointer becomes bad (a dangling pointer), and now points to some random memory. The code might crash, or it might do something weird that drives you crazy. This confused me because I didn't understand the difference between a nil pointer and a bad pointer. At least Odin initializes the pointer as nil so it isn't bad to begin with (a wild pointer), unlike C/C++.
@kunimitanaka1079
@kunimitanaka1079 27 күн бұрын
Thanks Karl. These short single subject videos are great. They are easily digestible which is especially important for subjects like pointers that are notorious for tripping up people new to programming. Keep up the good work.
@FranzBrummer
@FranzBrummer 27 күн бұрын
Looking forward to your book!
@bachwaregames
@bachwaregames 27 күн бұрын
Thanks for the video! :) Looking forward to your book. Quick question. With my understanding, if you pass a struct to a function (not as a pointer) it will make a copy of that struct, like a value type, yes? So should we always be aware to pass it as a reference, even though we might not want modify the struct inside the function itself? Or is it fine to pass copies around, if we're not modifying it. Hope it makes sense.
@karl_zylinski
@karl_zylinski 27 күн бұрын
It will not copy it if the struct is bigger than pointer size. Odin automatically sends it as immutable reference. I.e. a reference that you cannot modify. So you only need to pass by pointer when you want to modify it. Otherwise just pass by "value".
@FranzBrummer
@FranzBrummer 27 күн бұрын
I might be wrong, but I think you're not supposed to change a function argument. So if you pass by value and change the struct in the function it is regarded as an error. The Odin compiler asks you if you wanted to pass a pointer instead. So I think technicall Odin doesn't make a copy for use in the function but a read only pointer or something like that.
@bachwaregames
@bachwaregames 27 күн бұрын
@@karl_zylinski awesome, that cleared up some confusion. Thanks :)
@bachwaregames
@bachwaregames 27 күн бұрын
@@FranzBrummer Sounds exactly like what Karl says. Thanks! :)
@LeeFry
@LeeFry 27 күн бұрын
I just want to say a big thank you to you! You've really helped with me getting into and understanding Odin. I'm a go dev by default but have been having a blast with Odin, especially with raylib. Looking forward to reading your web book. 😁
@HairyPixels
@HairyPixels 27 күн бұрын
what would be nice is a stack trace too. Knowing where the alloc is 50% but the other half is HOW it got there.
@karl_zylinski
@karl_zylinski 27 күн бұрын
You can get a backtrace using this, it has an example of how to setup a tracking allocator that gets back traces github.com/laytan/back