Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example suggestions #73

Open
karl-zylinski opened this issue Jan 14, 2025 · 12 comments
Open

Example suggestions #73

karl-zylinski opened this issue Jan 14, 2025 · 12 comments

Comments

@karl-zylinski
Copy link
Collaborator

karl-zylinski commented Jan 14, 2025

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.

@karl-zylinski karl-zylinski pinned this issue Jan 14, 2025
@karl-zylinski
Copy link
Collaborator Author

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

@karl-zylinski
Copy link
Collaborator Author

  • Code generation / "meta programming": An Odin program that generates Odin code
  • When passing slices is good vs passing for example dynamic arrays.

@Waqar144
Copy link

  • 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.

@red-moss2
Copy link
Contributor

@karl-zylinski I think math/rand could be a good one, e.g. setting seeds, a few examples

@mazetmx
Copy link

mazetmx commented Jan 23, 2025

  • Working with RegEx

@SchoolyB
Copy link

SchoolyB commented Feb 1, 2025

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

@Kelimion
Copy link
Member

Kelimion commented Feb 1, 2025

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.

@SchoolyB
Copy link

SchoolyB commented Feb 1, 2025

What is the location of this Hash usage? I'd like to check it out for ideas

@Apis035
Copy link

Apis035 commented Feb 2, 2025

Examples for core:log usage

@erjohnson
Copy link
Contributor

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

@clankill3r
Copy link
Contributor

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.

@laytan
Copy link
Collaborator

laytan commented Feb 12, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants