- Видео 128
- Просмотров 145 193
Karl Zylinski
Швеция
Добавлен 4 окт 2019
I teach Odin and how to create video games without an engine. Independent game developer.
What are pointers? (Odin)
What are pointers, along with some examples of how to use them.
I'm making writing a book in the Odin Programming Language! Subscribe to know when it is out.
Support me 💖 patreon.com/karl_zylinski
I'm making writing a book in the Odin Programming Language! Subscribe to know when it is out.
Support me 💖 patreon.com/karl_zylinski
Просмотров: 936
Видео
Common mistakes when slicing strings
Просмотров 1 тыс.Месяц назад
How slicing of UTF-8 strings can go wrong when you assume that the slicing operator works on a "per character basis". Support me on Patreon www.patreon.com/karl_zylinski Odin book announcement: ruclips.net/video/j5BGZyz01lk/видео.html Discuss Odin and gamedev on my Discord server: discord.gg/4FsHgtBmFK I do Odin tutoring and code consultation, more info here: zylinski.se/odin-tutoring/ The Odi...
How to run C code from Odin
Просмотров 1,3 тыс.Месяц назад
How to setup Odin bindings for a C library, making it possible to run that C code from your Odin code. This video includes how the C library itself looks and is compiled. This uses what is known as the FFI (Foreign Function Interface). The code in the video: github.com/karl-zylinski/odin-bindings-to-c Support me on Patreon www.patreon.com/karl_zylinski or by becoming a member here on RUclips 💖 ...
I'm writing an Odin book!
Просмотров 1,7 тыс.Месяц назад
In the Odin book I'm writing I'll give big-picture explanations of things things that take a while to figure out and things that may not be apparent from the online documentation. Odin tutoring service: zylinski.se/odin-tutoring/ Ask questions about the book on my Discord server: discord.gg/4FsHgtBmFK Support me on Patreon. Patrons get previews of some of the book chapter drafts. Those in the $...
Odin's constants have their own little type system
Просмотров 1,1 тыс.2 месяца назад
Today I answer two questions: - Why can you assign 7.42 to both f32 and f64 variables? - What are the defaults for type inference? Support me on Patreon www.patreon.com/karl_zylinski I do Odin tutoring and code consultation, more info here: zylinski.se/odin-tutoring/ The Odin Programming Language: odin-lang.org/
Understanding arrays in Odin
Просмотров 1,5 тыс.2 месяца назад
In-depth explanation of the different kinds arrays in Odin, including a look at the underlying data structures of dynamic arrays and slices. Support me on Patreon www.patreon.com/karl_zylinski This video's text / slides: gist.github.com/karl-zylinski/37c7391f9f0d0ee3abb2471cb2347765 Video on allocators and tracking allocators: ruclips.net/video/dg6qogN8kIE/видео.html I do Odin tutoring and cod...
Efficient 2D drawing using generated atlas texture
Просмотров 1,3 тыс.2 месяца назад
Having a game use few draw calls makes the rendering more efficient. Here I describe how to achieve that by using an atlas builder to generate a texture atlas. Support me on Patreon www.patreon.com/karl_zylinski The atlas builder: github.com/karl-zylinski/atlas-builder I do Odin tutoring and code consultation, more info here: zylinski.se/odin-tutoring/ RenderDoc: renderdoc.org/ The Odin Progra...
CAT & ONION Soundtrack with (text) commentary
Просмотров 3472 месяца назад
The CAT & ONION soundtrack with on-screen commentary regarding the creation of the music. Get the game: store.steampowered.com/app/2781210/CAT ONION/ Contents: 00:00 Track 1: Menu 00:37 Track 2: Catnap 04:05 Track 3: Thankscakes!
Why building Odin programs is so simple
Просмотров 6 тыс.2 месяца назад
An overview of how you compile Odin programs and how libraries pull in their own binary dependencies, resulting in very little need for a big build system such as CMake or premake. 😻 Support me: www.patreon.com/karl_zylinski Buy my game CAT & ONION: store.steampowered.com/app/2781210/CAT ONION/ Join my Discord Gamedev Community: discord.com/invite/4FsHgtBmFK Odin Programming Language odin-lang....
Organizing Odin code
Просмотров 1,9 тыс.2 месяца назад
How Odin's package system works, when I think you should split something into a package and some practical ideas for code organization. 😻 Support me: www.patreon.com/karl_zylinski Buy my game CAT & ONION: store.steampowered.com/app/2781210/CAT ONION/ Join my Discord Gamedev Community: discord.com/invite/4FsHgtBmFK Odin Programming Language odin-lang.org/
Generic Odin procedures: Parametric polymorphism
Просмотров 1,2 тыс.3 месяца назад
How to make the Odin compiler generate variations of procedures for you, based on the types of parameters and how this relates to compile-time constants. 😻 Support me: www.patreon.com/karl_zylinski Buy my game CAT & ONION: store.steampowered.com/app/2781210/CAT ONION/ Join my Discord Gamedev Community: discord.com/invite/4FsHgtBmFK Odin Programming Language odin-lang.org/ This video is an edite...
Make games using Odin + Raylib #3: An animated player ✨ RE-UPLOAD
Просмотров 9413 месяца назад
Make games using Odin Raylib #3: An animated player ✨ RE-UPLOAD
Make games using Odin + Raylib #2: Move, jump & fall ✨ RE-UPLOAD
Просмотров 1,1 тыс.3 месяца назад
Make games using Odin Raylib #2: Move, jump & fall ✨ RE-UPLOAD
Make games using Odin + Raylib #1: Setup and first code ✨ RE-UPLOAD
Просмотров 2,6 тыс.3 месяца назад
Make games using Odin Raylib #1: Setup and first code ✨ RE-UPLOAD
Odin + Raylib: Breakout game from start to finish
Просмотров 3,7 тыс.3 месяца назад
Odin Raylib: Breakout game from start to finish
Odin + Raylib: Snake game from start to finish
Просмотров 4,1 тыс.5 месяцев назад
Odin Raylib: Snake game from start to finish
Sublime Text + Odin + Code completion
Просмотров 1,4 тыс.5 месяцев назад
Sublime Text Odin Code completion
Setup Odinlang compiler from source on Windows
Просмотров 1,2 тыс.5 месяцев назад
Setup Odinlang compiler from source on Windows
Make games using Odin + Raylib #6: Level editing basics + memory management
Просмотров 2,2 тыс.5 месяцев назад
Make games using Odin Raylib #6: Level editing basics memory management
Make games using Odin + Raylib #5: Platforming mechanics + cleanup
Просмотров 1,8 тыс.6 месяцев назад
Make games using Odin Raylib #5: Platforming mechanics cleanup
indiedevs talk shop #3: Dennis Gustafsson (Teardown, Smash Hit)
Просмотров 1,7 тыс.6 месяцев назад
indiedevs talk shop #3: Dennis Gustafsson (Teardown, Smash Hit)
Next game, Patreon and source code access
Просмотров 1,1 тыс.6 месяцев назад
Next game, Patreon and source code access
Using Odinlang's Tracking Allocator
Просмотров 3,1 тыс.6 месяцев назад
Using Odinlang's Tracking Allocator
indiedevs talk shop #2: Johan Peitz (Orb of Aeternum, Icy Tower, Hellgineers, Cosmic Collapse)
Просмотров 1,2 тыс.6 месяцев назад
indiedevs talk shop #2: Johan Peitz (Orb of Aeternum, Icy Tower, Hellgineers, Cosmic Collapse)
indiedevs talk shop #1: Martin 'grapefrukt' Jonasson (Holedown, Subpar Pool, "Juice it or lose it")
Просмотров 8187 месяцев назад
indiedevs talk shop #1: Martin 'grapefrukt' Jonasson (Holedown, Subpar Pool, "Juice it or lose it")
Make games using Odin + Raylib #4: Adding a second animation and tidying some stuff up
Просмотров 1,6 тыс.7 месяцев назад
Make games using Odin Raylib #4: Adding a second animation and tidying some stuff up
CAT & ONION Steam Trailer 😻 Whimsical cat adventure game
Просмотров 5918 месяцев назад
CAT & ONION Steam Trailer 😻 Whimsical cat adventure game
My Odin game programming workflow
Просмотров 1,9 тыс.9 месяцев назад
My Odin game programming workflow
For someone new to Odin, the use of ^ instead of * looks odd.
It's a pointy thing 😀
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.
Awesome channel! Can't wait for the book!
I loved smash it. So this is the artist huh? Wow. I just discovered tear down on RUclips and was intrigued by the physics which adds to an important realism which is fun and familiar. Just like the real world.
Thanks
Thank you so much!
Great explanations about memory leaks and a very clever solution to this problem proposed by the Odin language! Very interesting. Thanks Karl
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.
Starting a C++ project is pain 😢.
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 !
👍 great. But how do I run it in vs code?
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++.
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.
Looking forward to your book!
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.
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".
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.
@@karl_zylinski awesome, that cleared up some confusion. Thanks :)
@@FranzBrummer Sounds exactly like what Karl says. Thanks! :)
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. 😁
what would be nice is a stack trace too. Knowing where the alloc is 50% but the other half is HOW it got there.
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
Something so satisfying about low tech game dev. Really enjoyed it, thanks for sharing.
i love it!
C# is getting the discriminated unions in the next release, most likely.
Heavily dependent on odin vendor libs. Anything that is pulled from third-party will still need to have some sort of build system.
No, you just need to build the binaries and put the library bindings with the built binaries in your project. Yes, you need to do that once to set library up, but no need for a build system to build your project.
how did you fixed your problem on your video called Getting Odin Language Server + Sublime to work at around 39:06? Thank you!
Thanks! Everything worked like a charm!
Great video! Thanks for the tutorial!
1:17 this is one of the weirder language decisions. to me it makes little sense why iterating the string uses a different data type than slicing it or reading its length. most of the standard library provides functions with a _byte suffix for when you do actually want to operate on a string in bytes instead of runes (which is probably a rare event). maybe string should be an alias for []rune (and cstring for []u8) so other functions behave consistently?
string can't be an alias for []rune since a rune is 32 bit, the string is tightly packed. The characters are expanded to 32 bit runes when you fetch a rune (for example when iterating). The current design makes sense because slicing with rune indices would require it to loop from the start and count the runes, as it has no way to know where each rune is, as they take different amount of space in the string. In other words, if slicing used rune indices then the slicing would be much slower. So there are good reasons for the current design, and there is no simple way to make everything use rune indices.
True, if it was an actual alias for []rune it would require a lot more memory to store strings, I didn't think of that. Basically I was just wondering if strings should just commit to containing only human-readable text where slicing by character (instead of bytes) is the only sensible thing to do - if you want to treat your data as bytes, you should be using a different data type instead. I guess it boils down to how much Unicode you're actually handling as in most cases you'll be dealing with ASCII anyway where slicing by bytes is sufficient and fast, so always paying the toll for some logic that slices by characters (and has to loop for it to work) maybe isn't worth it? Although I'm curious how much of a detriment this would actually be, especially with things like simdutf out there ...
100% agree with you Jack, it feels very weird that slicing and len() operates at the byte level instead of the rune level. I just learned it now… I would definitely have fallen in the trap if I didn’t watch the video, and I guess most people would too. This makes working with strings confusing and prone to errors. From the user perspective, when you think of string, you think of working with runes. One would assume that basic operations on strings would be at the rune level, not the byte one. I really like Odin; it’s very pleasant to program with, and it’s exceptionally well-designed. However, sometimes I come across things that feel really odd, and I can’t quite understand why they’re designed that way. There might be an obvious reason, but I just don’t see it. For example, why would you need two ternary runtime conditional expressions in a language? It feels unnecessary, it complicates learning, makes parsing harder, slow down the parser, and reduces codebase consistency. I see multiple disadvantages and 0 advantage 😅
@@julienlecoq3539 I don't think there is as good way to make slicing and length use runes, without introducing a bunch of magic. If you do that then the string must know how many runes it contains, and it can only get that info by iterating the bytes (because each character can be of different byte size). So each time you modify anything within the buffer that is backing the string, then some magic extra code has to run that iterates it and updates this rune count. Also, slicing would need to iterate the whole string when you perform a slice. When I thought more about these things and how to solve them, then I saw that the language would need a big amount magic and it would also make strings have unpredictable performance characteristics. Odin tries to avoid such things, so the current design fits well with the language.
Nice video and interesting view on this. I don't know your background but I think that is needed to give little more time to adjust to this way of organization. My background is from go and when I was starting I had the same opinion, but with more experience and revision of seniors codes it just make sence and now I maybe using it too much. There is also difference in go if you want to make something private you need to hide it in directory, there isn't option to make it provate for file.
Hi, you can do #+private file at top of file
I was torn between Ada and Odin, and I eventually started playing more with Odin because even though it doesn't have headers, its gets very, very close with specification files (which are header-like, basically. it is basically module and package sugar). If it wasn't that, I would say tagged unions. They are just the best model for anything stateful/finite but easy to pass/manipulate by value.
Folks who are on Windows, you can use scoop to install and keep odin updated.
who thought graphemes were a good idea? i doubt they were a programmer. you can never get away from dumb decisions someone made in the past.
Very concise and insightful explanation, helped me a lot visualizing the level editor for my 2D top down game. Thank you very much!
I like how you explained fixed timestep physics, but in a game like this, I think it's better to just clamp "dt" to some reasonable maximum. Like slowing down time when the game can't keep up.
Do you know how to get the odinfmt formatter to work as well?
Sorry, I haven't used it.
The way I treat any string of bytes is to check is it a valid markup for what am I reading? and stick to the simplest format that can fit its markup into 1 byte, or just ascii. Anything else is either user's data and should be passed-through as is.
thanks.
Hmm JavaScript shows "小猫咪" as 3 length so it has no problem with processing it normally. Emojis though it struggles with. Like 👵 is actually two emoji/characters (old person + female), but (and despite showing the `.length` as 2) it can't split them. Though having worked with a project that dealt with splitting and recombining emojis I definitely felt there to be a need for better handling of such "multi-cellular" characters in the language. "Runes" sounds like a great concept to deal with these things.
Javascript probably loops over the string each time you ask about the length. That, or it saves the number of utf8 characters somewhere. Storing the number of utf8 characters is a bit tricky. If you want to create a substring that knows its utf8 character length, then you must also run a post-initialization step that loops over it and stores the number of utf8 characters in a counter. Tricky magic business!
Nice and concise! Love how these videos feel super chill while covering interesting language features the sublime presentation just adds to it, clear examples without needing to parse huge walls of text :)
Thank you :D
> rune_count > chinese characters missed opportunity to call them moonrunes
Thanks for yet another focused and informative video 👍