squint

m3tti 2024-09-11T07:05:46.773499Z

if i want to use bun should i consider squint or nbb?

borkdude 2024-09-11T07:39:04.950269Z

both should work

m3tti 2024-09-11T07:39:19.037269Z

question is is there any diffrence 😄

m3tti 2024-09-11T07:39:30.423429Z

i have the feeling that using squint would make more sense

m3tti 2024-09-11T07:39:48.914509Z

since nbb is an app that leverages node in the back right and squint is "just" a transpiler

borkdude 2024-09-11T07:40:25.014539Z

yeah but bun now has enough Node.js compatibility to be usable with nbb

borkdude 2024-09-11T07:40:51.841469Z

$ bunx --bun nbb -e '(+ 1 2 3)'
6

m3tti 2024-09-11T07:41:20.744669Z

but isn't nbb wrapping node ?

borkdude 2024-09-11T07:41:21.934539Z

$ bunx --bun nbb
Welcome to nbb v1.2.179!
user=> js/Bun.version
"1.1.24"

borkdude 2024-09-11T07:41:32.367289Z

no

borkdude 2024-09-11T07:41:35.877079Z

it's just a library

m3tti 2024-09-11T07:41:39.791899Z

aaaaaah ok

m3tti 2024-09-11T07:41:46.498449Z

i thought its like babashka

m3tti 2024-09-11T07:41:51.024549Z

and squint is just the library 😄

borkdude 2024-09-11T07:42:14.138489Z

nbb is just a thing on npm that you can load :)

m3tti 2024-09-11T07:42:39.859189Z

yeah a node executable i guess

borkdude 2024-09-11T07:42:47.228279Z

just a blob of JavaScript

👍 1
borkdude 2024-09-11T07:43:01.376829Z

and yeah, a CLI that has a node.js shebang

borkdude 2024-09-11T07:43:09.938079Z

this is why you need the --bun flag with bun, else it will still invoke node.js

m3tti 2024-09-11T07:43:25.530409Z

ok makes sense

m3tti 2024-09-11T07:43:33.958869Z

just asking for a friend ;D

m3tti 2024-09-11T07:44:16.565679Z

i'm doing some video streaming stuff and i've figured out that the webtorrent stuff just works with webrtc and there is no cool library afaik for java / clojure

m3tti 2024-09-11T07:44:54.368359Z

so i'm considering bun cause its the new kid and should handle js stuff even faster

borkdude 2024-09-11T07:46:55.148179Z

I'd benchmark real life scenario's because sometimes the Bun benchmarks are a little specific and artificial

pez 2024-09-11T08:11:01.788889Z

Awesome reading, this thread!

m3tti 2024-09-11T12:10:34.620769Z

Yeah guess i have to benchmark it anyways. Btw if nbb is "just" a lib will i gain performance when i transpile stuff to js first?

borkdude 2024-09-11T12:17:14.526649Z

it depends. nbb isn't a compiler but an interpreter, so code runs slower, but it depends what the overhead of interpretation vs the actual video streaming stuff is.

m3tti 2024-09-11T12:18:30.453639Z

In general afaik the webtorrent works like that that it generates the torrent file magnet link and than offers the video over webrtc. So wss.

m3tti 2024-09-11T12:19:19.499669Z

I thinik it just offers the bytes from the torrent without invoking to much code

Chris McCormick 2024-09-11T12:32:48.196819Z

Last time I was tinkering with Webtorrent the WebRTC part was native compiled code so I don't think you will run into performance issues using nbb. Maybe if you were handling 10k's of connections joining and leaving it could become and issue but I'd guess not.

🎉 1
Chris McCormick 2024-09-11T12:34:52.260279Z

If by "wss" you mean websocket protocol then it's a completely different thing to WebRTC. Webtorrent uses both - the websocket connection is for "signaling" (e.g. introducing browsers to each other) and the WebRTC is used for the direct p2p connection and streaming of data between browsers. So in this architecture nbb would probably just be running the webtorrent tracker server which is all JS code anyway and handling the websockets part. The actual streaming happens p2p away from your own server.

m3tti 2024-09-11T12:34:55.119189Z

i guess if i'm at that scale 😄 i have diffrent problems to 😄

Chris McCormick 2024-09-11T12:35:47.288899Z

One good thing about WebRTC is you mostly don't have to worry about scale because the data goes directly without hitting your own infrastructure (usually, with some caveats depending on how you handle TURN).

Chris McCormick 2024-09-11T12:36:43.388639Z

Oh wait, if you are running the WebRTC node and streaming from the server then you will be running that (native compiled) part on your own infrastructure.