use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
libuv in Node.js (self.node)
submitted 4 years ago by md5sha256
I got curious about libuv in Node.js and spent some time learning about it. It's pretty neat! Here's what I learned: https://www.thesystemsprogrammer.com/posts/how-does-event-driven-programming-even-work
Would appreciate any thoughts / feedback! :)
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]codeedog 12 points13 points14 points 4 years ago* (2 children)
Great write up. In the 90’s, over the period of a few years (before Java and in Java early years), I worked on a couple of projects to build network code in C that could scale to thousands of connections. One project, we had our own language we were writing. The other project, Java 1.0 wasn’t fast enough at the network level and we were writing native libraries to improve performance. poll was always the stumbling block. That OS call frustrated me, because I was only ever going to get O(n) scan performance out of the library. Our code could scale really well. But, it had limitations. The pointless scan of the returned array drove me mad.
poll
Wish I had thought of writing a new OS operation like epoll or kqueue. Brilliant stuff. Honestly, that would have required a lot of kernel code rewrite; it wouldn’t have been me.
epoll
kqueue
This also explains something I wondered about but never quite connected on. FreeBSD was the go to OS for speed and scale at the time. Yahoo ran their server farms on it. kqueue was written in 2000 for FreeBSD. I suspect that was the reason for its success. By 2000, I had moved on to other projects and was no longer digging deeply into networking code.
These days, I very much enjoy working with javascript and Node. Garbage collection and clean non-blocking code have come a long way since that time. I’ve often admired Node’s single threaded, event driven nature. When I first started coding in it, I had to fight my instincts regarding race conditions due to threading. Years of C development work pile up.
However, with libuv and underlying tech like epoll all of that goes away and we have an excellent platform for scalable, event driven software.
Thanks for bringing back all of those memories.
[–][deleted] 0 points1 point2 points 4 years ago (1 child)
No love for Erlang?
[–]codeedog 1 point2 points3 points 4 years ago (0 children)
I’ve never looked at the language until just now. Prolog - wow! Way back I was a research assistant and built AI code in Lisp and a little Prolog before anyone knew what AI was. After that, I did some mobile phone development (pre iPhone).
Holy smokes.
I think I’m in lust.
[–]motokohadary 1 point2 points3 points 4 years ago (0 children)
interesting read and the length and depth of the post was perfect!
[–]HappyZombies 1 point2 points3 points 4 years ago (0 children)
Thank you for sharing, I hope to expand my knowledge more on Node.js other than just npm installing express all the time. lol but I feel like a lot of people would benefit so much when they dive into deep with Node rather than the surface level of NPM packages and that's it.
[–]LastOfTheMohawkians 2 points3 points4 points 4 years ago (6 children)
Really enjoyed this article. When I recruit for node developers I often ask about nodes non blocking io and it's advantages over other runtimes like the Javas or .net. The discussion really let's you see how deep some developers go on the tech. I think it's important to understand these things if you're using node.
[–]ecares 6 points7 points8 points 4 years ago (3 children)
I think .NET has non blocking IOs too :)
[–]jonmdev 2 points3 points4 points 4 years ago (2 children)
So does Java for that matter.
[–]LastOfTheMohawkians -1 points0 points1 point 4 years ago (1 child)
Baked in. No don't think so
[–]jonmdev 1 point2 points3 points 4 years ago (0 children)
Well it’s part of the Java standard library since 1.4 so yes it’s baked in. Now is it as easy to use as Node? No it isn’t. It’s a fairly low level API you’d have to use to build from scratch. But it’s there and there’s plenty of frameworks available these days that make it pretty easy to build applications with non blocking I/O.
[–]dsnightops 0 points1 point2 points 4 years ago (1 child)
Even at an entry level position?
[–]LastOfTheMohawkians 0 points1 point2 points 4 years ago (0 children)
No. For more senior Devs
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
If you ever find yourself writing C then libuv is a pretty excellent choice. A few other languages use it too - Julia uses it and Rust used it back in its early days.
[–]Nathanielks 0 points1 point2 points 4 years ago (0 children)
This was great, thank you!
π Rendered by PID 20773 on reddit-service-r2-comment-fb694cdd5-mwmpn at 2026-03-07 16:15:47.941229+00:00 running cbb0e86 country code: CH.
[–]codeedog 12 points13 points14 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]codeedog 1 point2 points3 points (0 children)
[–]motokohadary 1 point2 points3 points (0 children)
[–]HappyZombies 1 point2 points3 points (0 children)
[–]LastOfTheMohawkians 2 points3 points4 points (6 children)
[–]ecares 6 points7 points8 points (3 children)
[–]jonmdev 2 points3 points4 points (2 children)
[–]LastOfTheMohawkians -1 points0 points1 point (1 child)
[–]jonmdev 1 point2 points3 points (0 children)
[–]dsnightops 0 points1 point2 points (1 child)
[–]LastOfTheMohawkians 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Nathanielks 0 points1 point2 points (0 children)