![sphaerophoria](/img/default-banner.jpg)
- 227
- 244 977
sphaerophoria
เข้าร่วมเมื่อ 16 ต.ค. 2011
Building square wheels to better appreciate the round ones.
Our chambers are finally connected
Stream from July 2, 2024 at twitch.tv/sphaerophoria
Pre-stream available at patreon.com/sphaerophoria
00:00 Intro
02:20 1 simulation, many chambers
43:20 Balls should only be in 1 chamber at a time
48:00 Moving balls between chambers
Pre-stream available at patreon.com/sphaerophoria
00:00 Intro
02:20 1 simulation, many chambers
43:20 Balls should only be in 1 chamber at a time
48:00 Moving balls between chambers
มุมมอง: 4
วีดีโอ
zig on the client, wasm on the server, what am i doing
มุมมอง 1.1K4 ชั่วโมงที่ผ่านมา
Stream from June 29, 2024 at twitch.tv/sphaerophoria June 29 pre stream available at patreon.com/sphaerophoria 00:00 Intro 06:10 Compile simulation to wasm 46:50 Interfacing with the browser
Who needs malloc anyways?
มุมมอง 2.4K7 ชั่วโมงที่ผ่านมา
Stream from June 28, 2024 at twitch.tv/sphaerophoria Pre-stream content available on patreon at patreon.com/sphaerophoria 00:00 Intro 07:22 Implement bump allocator 01:02:15 Only allocate on module init 01:27:20 Update other modules
Shoving too much data into an sqlite database
มุมมอง 9549 ชั่วโมงที่ผ่านมา
Stream from June 27, 2024 at twitch.tv/sphaerophoria 00:00 Intro 02:45 Add uploaded modules to DB 57:08 Load chambers from database on init
Hello sqlite my old friend
มุมมอง 1.1K12 ชั่วโมงที่ผ่านมา
Stream from June 26, 2024 at twitch.tv/sphaerophoria 00:00 Intro 03:25 Get sqlite up and running 15:50 Add users to the DB 01:28:45 Add session ids to the database 01:40:15 Always hit DB for user and session data
What happens when upload a file
มุมมอง 1K14 ชั่วโมงที่ผ่านมา
Stream from June 25, 2024 at twitch.tv/sphaerophoria 00:00 Intro 04:15 A dummy upload page 11:40 Receive the data 01:39:15 Do something with the data
We finally implemented login with twitch account
มุมมอง 1K21 ชั่วโมงที่ผ่านมา
Stream from June 22, 2024 at twitch.tv/sphaerophoria 00:00 Intro 04:00 Dummy login page 15:20 Redirect and cookies 57:00 Fetch ID token from twitch 01:23:30 Libcurl http client 01:45:35 Extracting result from JWT
Async event signaling in zig
มุมมอง 778วันที่ผ่านมา
Stream from June 21, 2024 at twitch.tv/sphaerophoria 00:00 Intro 06:40 Http connection reference counting 38:15 Http connection wait state 47:20 Wake http connection up on event
Validating json web tokens in zig w/ openssl
มุมมอง 955วันที่ผ่านมา
Stream from June 20, 2024 at twitch.tv/sphaerophoria 00:00 Intro 15:00 Parse the monstrosity 01:17:50 Signature verification 01:49:00 Reduce hard coding
OpenID connect melted my brain
มุมมอง 967วันที่ผ่านมา
Stream from June 20, 2024 at twitch.tv/sphaerophoria
Async HTTP server in Zig
มุมมอง 1.2Kวันที่ผ่านมา
Stream from June 18, 2024 at twitch.tv/sphaerophoria 00:00 Intro 06:06 HTTP event handler stub 21:10 HTTP request parsing 59:40 Send a response 01:18:00 Simple interactive website
Async TCP with epoll in zig
มุมมอง 1K14 วันที่ผ่านมา
Stream from June 17, 2024 at twitch.tv/sphaerophoria 00:00 Intro 04:55 Prove async send is necessary 17:00 Async TCP send setup 35:00 Event loop refactor to support multiple items per fd 01:28:15 Async TCP send again
Who needs async when you have epoll
มุมมอง 1.8K14 วันที่ผ่านมา
Stream from June 16, 2024 at twitch.tv/sphaerophoria 00:00 Intro 05:30 Demo failure case 09:00 Epoll tcp echo server 58:15 Event loop abstraction
Trying Zig to C bindings generator on real library
มุมมอง 84914 วันที่ผ่านมา
Stream from June 14, 2024 at twitch.tv/sphaerophoria 00:00 Intro 10:00 Fix pointer type resolution 43:45 Fix missing function exports 01:20:50 Figure out which structs need bindings
Using Zig's AST to auto generate C bindings
มุมมอง 1.2K14 วันที่ผ่านมา
Stream from June 13, 2024 at twitch.tv/sphaerophoria 00:00 Intro 07:40 Parsing our first line 57:15 Extracting a function 01:38:15 Extracting a nested function
This really complicates our physics engine
มุมมอง 99021 วันที่ผ่านมา
This really complicates our physics engine
First chamber of our wasm based rube goldberg machine
มุมมอง 77321 วันที่ผ่านมา
First chamber of our wasm based rube goldberg machine
WASM: The safety of C, the ergonomics of JS
มุมมอง 1.4K21 วันที่ผ่านมา
WASM: The safety of C, the ergonomics of JS
Adding collision to our physics engine
มุมมอง 99921 วันที่ผ่านมา
Adding collision to our physics engine
Making the worlds worst physics system
มุมมอง 2.4K21 วันที่ผ่านมา
Making the worlds worst physics system
String manipulation from wasm is weirdly difficult
มุมมอง 1.7K28 วันที่ผ่านมา
String manipulation from wasm is weirdly difficult
Poorly implementing ieee754 floats from scratch
มุมมอง 2.6Kหลายเดือนก่อน
Poorly implementing ieee754 floats from scratch
Synchronizing text view and timeline view in my video editor
มุมมอง 1.4Kหลายเดือนก่อน
Synchronizing text view and timeline view in my video editor
Saving audio files with ffmpeg to debug my video editor
มุมมอง 1.1Kหลายเดือนก่อน
Saving audio files with ffmpeg to debug my video editor
Splitting up long chunks of automatically transcribed text
มุมมอง 1.4Kหลายเดือนก่อน
Splitting up long chunks of automatically transcribed text
Script generation takes a long time...
มุมมอง 1.7Kหลายเดือนก่อน
Script generation takes a long time...
Navigating video with auto-generated text
มุมมอง 1.7Kหลายเดือนก่อน
Navigating video with auto-generated text
I'm loving your videos man
are the stack devs really so full?
I really enjoyed watching the epiphanies you encountered and was amazed at the speed at which you pick up the language. I think watching you figuring out the neat parts of the language was more satisfying then learning it myself, because you have a deeper understanding of the implications of the language features.
Love your video's but I have stopped watching them because the constant moving maze above your head really triggers my Asperger and ADHD to a point where I can't follow along or I have to concentrate so hard that I tire out on these long videos. I wonder if you would consider removing it?
if you watch in fullscreen on a computer you can put maybe a small notepad over it, or move the youtube window to the side so the part with the maze and stufd goes offscreen
I'm forced to hide it with my fingers on mobile 😅
Mind giving me the skinny on the "Zig on the client" part? Are you somehow transforming Zig to JS, or to whatever JS is being transformed(compiled/interpreted, whatever) when Firefox is executing that?...
It's being compiled to webassembly, but that doesn't make as good of a title
To clarify further, "wasm on the client, wasm on the server" doesn't really capture the mental model of the project. It isn't entirely clickbait we're writing a server that loads user submitted webassembly modules. Server is mostly written in zig, we want to run some of the server side code that we've written in the browser. So from our perspective we don't care what language the wasm modules we consume are written in, but we do care that our zig code can run on both the client and server. The wasm there is an implementation detail
@@sphaerophoria aha, that's what I was hoping for, and if I understand correctly, that's what's going on... you can essentially execute non-JS in Firefox. Warms my heart :D
what’s up what’s up
What libraries are being used in your terminal? Especially for the file handling?
ranger file manager is what i use for directory navigation. I have it bound to ctrl-o to cd to whatever directory I exit in. Other than that it's just tmux and nvim
dead beef is a funny address... you got my clickthrough just based on that.
Sometimes when people read that as your username they seem subtly offended.
@@0xCAFEF00Di've not seen 0xcafef00d anywhere somehow i wonder how many words like that there actually are
What is this thumbnail. LOL
Sqlite is hungry for yummy data
I like it
Thank you and a wonderful zig series
02:12:55 Using last_insert_rowid() is a mistake I think. In some cases there is no row inserted and it doesn't return something sane. This resulted in us saying "hey I have this session ID and it belongs to this user", but the user was invalid, which made the join invalid, etc. I've adjusted off screen to use the RETURNING clause in sqlite and parse the id out of it
Sweet!!
What happens when write a comment
Well now i can't fix it
@@sphaerophoria I think YT only lets the biggest channels edit that stuff )-:
Oh sorry, I can re-title the video no problem but then the comment wouldn't make sense anymore
@@sphaerophoria You are a man of honour!
failable is the new fallible
Seconding a comment I saw on an earlier video-I would absolutely love to watch a 20 minute summary of your projects, either as a single final summary or as intermittent updates. Your projects are really awesome to see! The 2 hour long videos are challenging to keep up with, though.
I did look into it, but I struggled to find a cut that I liked. Maybe some day I'll try again
Cool stuff
This is perhaps the most complex way to integrate OAuth nowadays. I love it.
What am I missing? I'm actually trying to just do the minimal amount that follows spec
No, your implementation is correct. I just mean the overhead of doing it in zig, while there are multiple existing JavaScript packages. Don’t get me wrong, I know why you are doing it this way (because you want to) and I respect it.
Oh i see, no libraries allowed! That's cheating!
Haha somebody has to build the library right. Maybe he can even package it into a library for Zig so other people can use it.
hell yeah
Thanks!
Thanks!
01:38:15 It's actually possible to fix this by just inverting the dependency order. E.g. instead of HttpConnection owning something that gives it responses to write, have a specific connection own an HttpConnection and forward polls to it. See github.com/sphaerophoria/ball-machine/blob/dcc4ec5b03435d00b190dfbfbff2be55195419eb/src/http_test.zig#L8 as an example (WIP commit, will probably get garbage collected at some point)
crazy man. been watching your videos recently. mad respect
it really is terrible, but that's web dev
I've implemented OpenID in work settings like 4-5 times and I'm still just as confused as you are to be honest
only one whats up, the whats up are decreasing per video
I think it's because my I frames are pretty far apart and recordings only start on the next . So I don't know when the recording _actually_ starts relative to when I click the button. I actually say "yoooo, 3x what's up" or "3x yo, 3x what's up" every time
@@sphaerophoria Maybe you could start recording and then just wait a bit. Maybe someone could build an editor, that has a transcription, that would allow you to cut it right at the first whatsup. JK btw...
This channel is a blessing for learning more than just the basics of zig. Youre a legend @sphaerophoria
Hello, I like your videos and I learn by watching you program and explain things, I love your content. I wanted to ask you a favor, which is to zoom in on the code, there is a lot of empty space and I don't see the code close enough... You can take a look at how a guy does it with content similar to yours, called "tsoding", if it's not a bother, put the code in the largest terminal, that is, zoom in. Thank you! Sorry if I wrote something wrong, English is not my first language and I translated it with the translator. Thank you so much!
i haven't watched the streams in entirety so might have missed it, but i'm curious why you're not using websockets for this? the epoll implementation would still be a cool learning experience, but the protocol itself would be better suited for the task than HTTP (as i understand it). love the series (and your videos in general) btw, keep it up :)
Great video! happy to find someone doing interesting things in Zig
I had a couple post-stream realizations... 1. We can give callback data directly to an epoll instance if the handler has a stable memory location. We can create a item pool that is basically a std.ArrayList with a list of IDs that can be reused and that simplifies a lot of the code 2. It makes a lot more sense to just register a single handler that handles both input and output for a given socket. Again this simplifies a lot because we no longer need the double indirection of file descriptor -> list of callbacks. This also means that each individual callback does not need a specific id 3. If we return a value from our epoll callback that says "I am finished, please delete me", that simplifies a lot of stuff as well. We can just buffer all deletions until we aren't iterating anymore which is pretty nice 4. Epoll links to files are automatically closed if the file descriptor is closed, we don't actually have to unregister connections if we're careful Latest and greatest at github.com/sphaerophoria/ball-machine/blob/526a78fe5aa027e366c6897002313b7438e665db/src/event_loop.zig (note may disappear after some future git gcs, but by that point there should be something in master)
Amazing video, currently watching still. I'm pretty new to this stuff but I think node.js uses libuv which is a library that uses epoll/an event loop. When there isn't any work left to do, the loop ends and the node process exits. My question is...when you start a web server, does it add a file descriptor to the list of fds and that fd stays there indefinitely until you close it when doing ctrl-c or something in the terminal? In other words, how does a web server keep the event loop indefinitely running?
It's probably easier to explain if we think about it without the event loop first. A typical server will look like (pseudo code) socket = make_socket(); listen(socket); while (true) { connection = accept(socket); read_or_write_connection(connection); } So we have one socket that sits there listening, and over time new connections come in when people connect to the socket The event loop case isn't any different, except for instead of doing connection = accept(socket) in the main loop, we set up a function callback that accepts the connection and shoves the new connection into our list of events to handle Specific event loops may end up handling this differently. You could shove a wants_shutdown bool in the while condition, you could wait until there is nothing left to poll, and have someone explicitly deregister the socket that is accepting new connections, i'm sure there are other options but I don't want to think about them :P
Thank you for such consistency in creating this quality content. Though new to zig, these are super helpful.
01:25:35 Is ``` var connection = try self.server.accept(); var echoer = TcpEchoer.init(self.alloc, connection) catch |e| { connection.stream.close(); return e; }; ``` equivalent to ``` var connection = try self.server.accept(); errdefer connection.stream.close(); var echoer = try TcpEchoer.init(self.alloc, connection); ``` or am I misunderstanding `errdefer`? On a side note, `errdefer ` can capture error. Might be useful for lazy catch all error logging.
It's a super subtle difference. I am trying to hand off ownership of the connection to the TcpEchoer. In TcpEchoer.deinit I close the connection, but also do some other stuff. Say we fail to register with the event loop at line 30, if we did the errdefer you're speaking of, we would close the connection once through echoer.deinit at line 25, then again at the errdefer that would be inserted at line 20. I'm actually not sure if double closing is a problem, but double freeing definitely is so I have the habit of ensuring cleanup is only issued one time per object
Oh I see. Thank you for the explanation.
Bro can you share the github repo of the project
WIP commit (that may end up deleted in the future) that really slims down the interface and fixes some of the uglyness around the registration stuff github.com/sphaerophoria/ball-machine/commit/fb995b3db2ae66eccde001dd25577479346e157e
Spending more than an hour learning how to traverse a tree in Zig. 🙄
What a rude and reductive comment, just a reminder that you get to choose if you want to be an ass hole or not I don't think in any part of this video we were struggling with "walking a tree" or with the fact that we were doing it in zig. The time comes from trying to find the data we care about, understand it's representation, and do what we want to do with it. There was a 20 min segment around 55:00 where we had to adjust our walking logic to account for a change in expectations about the tree layout, but I don't think that's an unreasonable amount of time to spend on something. Even if we were spending a lot of time on something, and you're wayyyyy smarter and could do it faster, there's no reason to try to make others feel bad about learning
There is a lot of good knowledge here. Zig to wasm, rust to zig, zig to rust, zig to C. But all of it is 2 hours plus 😢😢😢.
whats up whats up whats up
I played with an alternative method today and it worked really well. * Copy paste structs from zig to C header, mark structs as extern in zig * Write C bindings API by hand * Write a comptime function that asserts that structs are the same. Struct size, field offsets, struct alignment, etc. * Write a comptime function that asserts that all exported functions have parameters and return types that match according to previous bullet * Use the zig types in the bindings impl file
Guru programmer at work! Amazing!
You know you could also run :LspRestart to restart the language server.
i’m so glad i found this channel
so crazy that that zig searches for dependency loops with DFS(basically a stack) but doesn't tell you either the stack or the duplicated value when it reports errors
I remember zig having -femit-h at one time.
I love your videos man, thanks for making them
I can't read anything when you scroll around so fast like you do. Just FYI
@sphaerophoria There is a great talk done by a core maintainer on Zig exactly about the memory layout optimizations for the compiler. I highly recommend it. Andrew Kelley - Practical DOD. Its on Vimeo, I don't think youtube lets me link it
That was a great watch!
Significant code cleanup (wip branch, git garbage collection may delete in the far future): github.com/sphaerophoria/ball-machine/commit/2ae83498847120d120952917a78e14231307dfcd
whats up whats up
That was fast, the stream just happened