4 ms·
Awesome! I used to think (well, I still do) that getting a barebones service up and running using the system APIs at the lowest level like this is so satisfying
by theideaofcoffee 2y ago
Awesome! I used to think (well, I still do) that getting a barebones service up and running using the system APIs at the lowest level like this is so satisfying. It's sort of magical, really. And to see it serve real traffic! I'm kind of surprised that the vanilla poll() can put up numbers like you were seeing, but I guess it's been a while since I've had to do anything event related/benchmark at that level.
I love the connection-specific functions and related structs and arrays for your connection bookkeeping, as well as the poll fd arrays. It's very reminiscent of how it's done in lots of other open source packages known for high throughput numbers, like nginx, redis, memcached.
Great work!
- yard2010 2y agoWorking with c/cpp in uni exploded my mind. It's such a specific humbling experience that has a bit of anything I love - engineering, history, culture, linguistics, etc. It made me think that anyone should know and try every possible language (programming or otherwise) - "thinking" in a language is such a unique experience. The different contexts make everything feel different, even though it's more of the same. The perspective change, and changes the subjective experience. For example - to really understand the nature of linux or git, you have to speak its language and understand the nuances that are usually lost in translation. Tangibly, to understand the true subjective meaning of the word "forest" in russian one has to speak and understand russian. The context changes the perspective, so sometimes it changes everything.
- ggliv 2y agoThis is a neat perspective. I’ve heard conversation on how working with different programming languages affects how you code (“learn Haskell, it’ll make you think more functionally!”) but for some reason I never connected it to the linguistic side of things. I remember learning about the effects of language on cognition in a psychology course I took a while ago, it’s interesting to think about how that could apply more broadly.
- ryandrake 2y agoIt’s kind of sad how C has gotten the reputation as this dangerous and scary dark art that only wizards can successfully wield. C was my first love, it’s what we used throughout university, it’s what our operating systems and basic tools are all written in... If you go to your favorite language and step down into the actual implementation of, for example, your network calls, you’re eventually going to get to poll() and write() written in C. It’s useful to know and be fluent in regardless of whether you intend to work on large projects in C.
- theideaofcoffee 2y agoSame, it was my first language that I got real fluent in. And I feel the same when the prevailing sentiment now is that you're 100% guaranteed to shoot your foot off and make your dog sick if you even look at some C code. I think it's harmful, because wielded responsibly it's super powerful. We shouldn't be discouraging something because it's hard to master, we should be encouraging discretion. And that discretion may take you to a memory-safe language, you may stick with C or something similarly low-level, it all depends.
- 01HNNWZ0MV43FF 2y agoBut if the dy/dx gradient is that experts can develop faster in safe languages, and novices make fewer mistakes in safe languages, then C isn't useful day-to-day. It occupies an ever-shrinking ecological niche on the Pareto frontier.
- zppln 2y agoWhat are you on about? C is more useful day-to-day than the vast majority of languages. Learning it is hardly a waste of time.
- the_gorilla 2y agoC is one of the worst designed programming languages still in use. It's a ridiculous, cruel joke on anyone looking to learn unless your actual goal is to learn what a programming language designed 70s computers looks like.
- cozis 2y ago> I used to think (well, I still do) that getting a barebones service up and running using the system APIs at the lowest level like this is so satisfying. It's sort of magical, really Totally agree. And actually using them is even more satisfying. I'm starting to get curious about email protocols.. > I'm kind of surprised that the vanilla poll() can put up numbers like you were seeing Me too. I assumed I was going to go with epoll at some point, but poll() is working great.
- pdp11ty 2y agoPeople seem to forget that all of their amazing, wonderful abstractions are, at their core, doing exactly this: opening sockets, reading from them, writing to them, etc. There is nothing new under the sun.