Example suggestions
karl-zylinski opened this issue ยท 28 comments
Make suggestions of examples you think are missing by adding a comment to this issue.
The more specific you are, the better.
I will convert those items that I think are good ideas into separate issues and put a link to them in here.
I would be very thankful for any help from experienced Odin programmers who can write idiomatic Odin. See the Issues tab for ideas of examples to implement.
Collected suggestions from discord/twitter/bsky:
SIMD examples (top request, requested by like 4 different people)
Examples of using the various sugar for SOA/AOSOA and SIMD that Odin has, and list of what it doesn't yet have (like 8-wide intrinsics), and examples of the various implicit stuff such as matrix vectorization mentioned in the Overview, with corresponding C intrinsics and/or CPU instructions noted.
And then it would be cool to add links to various examples including this one to the Overview, so that new users can immediately see how the subject works while still keeping the Overview small and intended to be an overview.
My only thing would be that, for example, 'encoding/json' has no documentation in the package docs, but the examples json folder has some good examples, so people going straight to core docs could be signposted. In other words there's a disconnect
I don't know if this really is relevant enough to be in the examples, but when I started out I would have loved to seen how people would structure odin code in multiple files. It might still just be me that likes to do this.
Hey Karl, thank you for your work. I would be very pleased to have a EGL basic example in the repo. I noticed that the vendor/egl package is lacking some things (GetError() and constants) and probably that should be added first, but I'll leave this as a wishlist item ๐
Arena allocators: https://discord.com/channels/568138951836172421/1329079875537080361/1329081332625707051
Small Win32 GUI app
Not sure it's good for the examples repository but a 'getting started' with debugging would be great. e.g. Being able to breakpoint, step through code, and see watch values.
Threading
any
- Code generation / "meta programming": An Odin program that generates Odin code
- When passing slices is good vs passing for example dynamic arrays.
- examples of different allocators in the lib
- example of utilizing temp allocator in a better way, e.g., using
DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD - reading a file line by line, using streams, readers
- launching subprocess, reading stdout/stderr, writing to stdin
There are smaller other things that would be good, but perhaps its better if they are directly documented in the pkgs. For eg., how to use the different containers? How to use stuff from time pkg? How to measure the duration of one function Stopwatch? These things are not hard to figure out, but imo a tiny example attached to a struct is very helpful in quickly understanding how to use this thing. Also, imo, only bigger things should be in this repo.
One suggestion: Put all the examples in one html file and ship it with the compiler.
@karl-zylinski I think math/rand could be a good one, e.g. setting seeds, a few examples
- Working with RegEx
Not sure if there is already but an example usage for time.benchmark() and ^Benchmark_Options. I am currently trying to use this now. I might be able to create my own example and make a PR
Not sure if there is already but an example usage for
time.benchmark()and^Benchmark_Options. I am currently trying to use this now. I might be able to create my own example and make a PR
I wrote it mainly to help benchmark our hash implementations, to check for major regressions, but made it general enough to possibly be useful in other ways.
If you wrote an example for it, I'd be happy to give feedback, and if you have thoughts on how to improve it to be more useful, I'll happily entertain a patch for it as well.
What is the location of this Hash usage? I'd like to check it out for ideas
Examples for core:log usage
What is the location of this Hash usage? I'd like to check it out for ideas
looks like it's here: https://github.com/odin-lang/Odin/blob/master/tests/benchmark/hash/benchmark_hash.odin
I noticed the SDL3 examples can be seen online due to them using wasm: https://examples.libsdl.org/SDL3/
So I think an example of using SLD3 with wasm and microui would be really usefull.
It will give a alternative option to webgpu (and webgpu doesn't run in a lot of browsers).
Also a example of raylib / micrui / wasm would be great.
@clankill3r we will probably not be adding any wasm examples using emscripten, we don't want to support it (emscripten) officially and if we then bring out official examples using it it's gonna blur the lines too much.
Examples for core:math/ease usage
How to use Lua from Odin
Examples for core:testing
How to use Lua from Odin
I did it myself: https://github.com/HVukman/Lua-in-Odin