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.
@cycomkid2 күн бұрын
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Күн бұрын
Any update karl?
@karl_zylinski23 сағат бұрын
I'm afraid the steam version does not have source
@cycomkid17 сағат бұрын
@@karl_zylinski bought on Itch
@leonun2 күн бұрын
nice
@ralphstube2 күн бұрын
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 }
@deryilz4 күн бұрын
great feature, i wish more languages had it!
@kencg65665 күн бұрын
Clear explanation, thank you! Looking forward to the book. 👍✌️
@reunionproductions14 күн бұрын
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_zylinski14 күн бұрын
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.
@Sergeeeek12 күн бұрын
Is this something that's worth putting in Odin's implicit context parameter?
@Kai41k16 күн бұрын
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.
@reunionproductions17 күн бұрын
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
@oldteen217 күн бұрын
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_zylinski17 күн бұрын
Thank you!
@tigrux21 күн бұрын
For someone new to Odin, the use of ^ instead of * looks odd.
@karl_zylinski20 күн бұрын
It's a pointy thing 😀
@empathy_monster21 күн бұрын
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_monster21 күн бұрын
Awesome channel! Can't wait for the book!
@buriedbits602722 күн бұрын
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.
@leeroy90023 күн бұрын
Thanks
@karl_zylinski22 күн бұрын
Thank you so much!
@Laurent_GameDev23 күн бұрын
Great explanations about memory leaks and a very clever solution to this problem proposed by the Odin language! Very interesting. Thanks Karl
@efv23 күн бұрын
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_56726 күн бұрын
Starting a C++ project is pain 😢.
@chandragunawan410527 күн бұрын
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 !
@김로로-s4v27 күн бұрын
👍 great. But how do I run it in vs code?
@ItsJustMeJerk27 күн бұрын
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++.
@kunimitanaka107927 күн бұрын
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.
@FranzBrummer27 күн бұрын
Looking forward to your book!
@bachwaregames27 күн бұрын
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_zylinski27 күн бұрын
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".
@FranzBrummer27 күн бұрын
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.
@bachwaregames27 күн бұрын
@@karl_zylinski awesome, that cleared up some confusion. Thanks :)
@bachwaregames27 күн бұрын
@@FranzBrummer Sounds exactly like what Karl says. Thanks! :)
@LeeFry27 күн бұрын
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. 😁
@HairyPixels27 күн бұрын
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_zylinski27 күн бұрын
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