10 ms·
uWebSockets
- londons_explore 4y agoSeeing the example[1], I suddenly realised how nodejs and C++, which started so far apart, are slowly merging into one language... [1]: https://github.com/uNetworking/uWebSockets#battery-batteries-included https://github.com/uNetworking/uWebSockets#battery-batteries...
- stevefan1999 4y ago
- ly3xqhl8g9 4y agoAny sufficiently advanced programming language is indistinguishable from JavaScript... for the better and for the worse.
- musingsole 4y agoEh, I think you picked the wrong side of that comparison. JavaScript looks like C by virtue of age and influence. It's common to remark on a language being "C-like"; not so much that a language is "JavaScript-like".
- AlmostAnyone 4y agoThis is not about the syntax (indeed that's C-like), but much more about the style of API. This style of API was basically invented in Node.js land and then carried over to other languages. And lots of JS-style syntax sugar has been added to the other languages to make it possible. If someone made a web app in C++, it used to be OOP heavy. There's no class declaration in sight here.
- TeMPOraL 4y ago> This style of API was basically invented in Node.js land and then carried over to other languages. You mean Lisp, and no surprise there, since JavaScript was supposed to be Scheme, except the commercial interests forced it to have Java-like syntax :).
- AlmostAnyone 4y agoI write some Common Lisp and while it's alike, this C++ API is much more similar to the JS API than to anything I've written in CL or Clojure. But yeah, I guess the basic idea is from Lisp.
- TeMPOraL 4y agoYes, I meant that in the sense of underlying idea, not the surface-level syntax.
- ly3xqhl8g9 4y agoIt was more or less a tongue-in-cheek snowclone based on the famous Arthur C. Clarke adage [1]. [1] https://en.wikipedia.org/wiki/Clarke%27s_three_laws#Variants_of_the_third_law https://en.wikipedia.org/wiki/Clarke%27s_three_laws#Variants...
- 323 4y agoCool little library, I'm using it, but author has an ego the size of Wolfram's. This is just one snippet, there are many if you rummage through the docs and issues: > In the 1970s, programming was an elite's task. Today programming is done by uneducated "farmers" and as a result, the care for smart algorithms, memory usage, CPU-time usage and the like has dwindled in comparison. https://github.com/uNetworking/uWebSockets/blob/master/misc/READMORE.md#compression https://github.com/uNetworking/uWebSockets/blob/master/misc/...
- c7DJTLrn 4y agoI used to vehemently agree with stuff like this, but now I just cringe. Yeah software today sucks, but comparing it with the 70s/80s/90s is just stupid. We don't ship software for one piece of incredibly simple hardware and a few thousand customers anymore. Elitism isn't going to make the situation any better and frankly unproductive whining like this is just getting exhausting.
- MisterTea 4y agoI "vehemently agree" but I don't insult farmers or other blue collar workers because that's a shitty thing to do. The author is just an asshole and should be punched in the face by a farmer.
- zmxz 4y agoWhy is the author asshole? You don't insult farmers but you won't stoop before insulting the author of microwebsockets. At what point does one assume moral high ground with 100% certainty? It's as if all this hate comes from the inability to read text carefully, without isolating malicious intent first.
- girvo 4y agoInsulting an entire group of people, by directly implying that farmers are not skilful or educated, is worse than insulting the person who made the insult in the first place.
- matesz 4y agoFor those who didn’t know, uWebSockets is one of the reasons for Bun’s high performance in server benchmarks [1], not just JavaScriptCore. [1] https://github.com/uNetworking/uWebSockets/discussions/1466#discussioncomment-3114410 https://github.com/uNetworking/uWebSockets/discussions/1466#...
- commitpizza 4y agoLike so many developer facing products or services, this one also fails to tell me what it is and what problem it solves and leaves me guessing. I guess that it is a backend library for doing websocket communication for node and perhaps also bun?
- Deukhoofd 4y agoThe first link on the page explains exactly what it is, and what the motivations are. https://github.com/uNetworking/uWebSockets/blob/master/misc/READMORE.md https://github.com/uNetworking/uWebSockets/blob/master/misc/...
- 323 4y agoIt's an extremely fast library for creating websocket servers. It's used by some crypto exchanges for it's high performance and low latency.
- hcayless 4y agoTitle needs correction: that’s a Greek letter mu, μ, not a u. Addendum: though it is clearly a u in the URL. Someone may be confused...
- wccrawford 4y agoIt's pretty common to use a u instead of mu in situations that need just plain ascii. I don't think anyone's confused. uTorrent comes to mind, too.
- pcthrowaway 4y agowhat do people use for Ypsilon (υ) then?
- anecdotal1 4y agoI've never seen a software project choose a Ypsilon in their name before. Have any examples? μ provides a good contextual clue about the project. What would the ε character tell me?
- jraph 4y ago> What would the ε character tell me? Smaller than μ. Still strictly positive but as small as you want. Nothing possibly smaller.
- rwl4 4y agoI wonder why they wrote the whole thing in header files...
- Matthias247 4y agoHeader-only libraries are a common thing in C++. They allow pretty easy consumption, because the consumer only needs to specify the include path. That's fairly easy with any build system (and C++ has a lot of them). Any binary library would also require building the library itself using the same toolchain and then linking to it - which requires a lot more configuration on the consuming side. It might be easy if both projects use the same build system (e.g. cmake), but that's far from guaranteed in C++.
- ChrisMarshallNY 4y agoI think things have changed, but back when I was doing C++, templates (generics) were implemented in header files, so it was not unusual to have entire programs written in .h files.
- white_dragon88 4y agoDeveloper appears to be a pretentious dork. For that reason I’ll not use this library
- sirsinsalot 4y agoI'll upvote you. That's a fine reason not to use a library.
- 314 4y agoThis is a valid choice. I doubt that the developer will lose any sleep over it.
- deleted 4y ago[deleted]
- arthurcolle 4y agois this an inside joke that I'm too cool to understand?
- RedShift1 4y agoI too would like a captain to step in please
- alexhultman 4y agoThanks
- truetraveller 4y agoHey, thanks for uWebSockets!
- GiffertonThe3rd 4y agoHere here, my dear fellow! Doubly so, for that awful logo.
- alexhultman 4y ago
- Tepix 4y agoThe project description: µWebSockets is a simple to use yet thoroughly optimized, standards compliant and secure implementation of WebSockets (and HTTP). It comes with built-in pub/sub support, URL routing, TLS 1.3, SNI, IPv6, permessage-deflate
- cphoover 4y agoThis is perhaps only tangentially related... but I'm trying to do something to support sharding of websocket connections based on a user_id.... I want the connections to be distributed to separate instances of a WS server based on modulo-based or consistent hashing algorithm... above that in the stack we have a message broker or queue partitioned using the same sharding algorithm for the number of websocket servers running. This queue/message broker sends publishes messages to each web socket service which in-turn pushes the message to the client. This is how I want to handle horizontally scalable web socket connections... The question I have is the best way to do this and the best way to migrate connections. From one service to another when/if the replication factor of web socket servers changes (we add/remove servers)... One way I would think would be to send a disconnect message to the websocket service when this event happens and it would disconnect it's clients and then have a random delay for when re-connection happens... so as to avoid trying to reinitialize all of those connections at once. This seems sub-optimal as with consistent-hashing many of the connections will stay on the same server, and terminating those connections would be unnecessary. What is the best way to migrate an open TCP from one server to another? Or if the connection must be closed... how can we minimize the number of connections that are to be closed. BTW: I know I can broadcasts to all instances of the websocket server, and then unless that server holds the connection it is no-op... if the server does have a connection then send the message back... This also seems it would have a limit to how far this scaling-strategy would grow before running into limitations.
- vanviegen 4y agoCan you just store the shard id for each user in a database? Each server could check if it is authorative for each incoming connection, and redirect if not. That way, you can migrate users one by one (sending a 'redirectUserConnections(userId)' to the original server, and even pick a shard that is geographically close to the user. (If you care about race conditions during migrations, you need to be really careful though.)
- cphoover 4y agoYea something like this makes sense... race conditions during migrations are the biggest concern.... You do not want a client with a connection to server they will never receive a message on.
- lloydatkinson 4y agoHaving dealt only a tiny bit with Node, GYP (it's garbage C++ interop layer) and the inexplicable dependency on Python (???) being installed on the devs machine in order to build the C++ code that got copied into node_modules, I know better than to ever try another library making use of that.
- mmis1000 4y agoI don't think you have less dep when building other c++ projects. People also use automake, autoconf or whatever to generate makefiles. It is just that the author choose python here. I never see anybody writes makefile manually and build moderate or big size project. There are always tons of tools used.
- alexhultman 4y agoThat's why the library ships prebuilt binaries with no dependencies at all. No compiler is even needed.
- adamrezich 4y agoI like the CODE_OF_CONDUCT.md
- deleted 4y ago[deleted]
- alexhultman 4y agoMe 2
- chrisweekly 4y ago"Besides this Node.js integration, you can also use Bun where µWebSockets is the built-in web server." Interesting. Bun keeps getting more compelling.
- the_optimist 4y agoWould be great to have the C and Rust APIs built out.
- pkrumins 4y agoLooks like Bun and uWebSockets are the next two technologies I’ll be exploring. Very exciting!