Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@12bitfloat You get better at laying out your code. Why are you not using async functions?
-
@BordedDev I am but I'm doing some weird stuff. webrtc channel over which you can open new webrtc channels which get passed to a webworker
just... dont ask -
@BordedDev But it still seems pretty all over the place. Instead of having a tree like hiearchy where you put stuff into lists and poll them, you seem to just create objects which then exist in the background but stay alive via references to other objects
I think I just need to get more experience with js lol -
@12bitfloat yeah you can't do remote ownership in JS, just forget about it. Either there are explicit messages upon which you detach event handlers so things can get collected (which are sent explicitly and not by a destructor), or they stay alive until the channel itself is disconnected. I don't even think the GC works across workers on the same browser. This is a unique advantage of local memory management like Rust's or C++'s.
-
I bet you could make a GC that can serialize the dependency structure of a value and thus negotiate cyclical resource release over the network. It would have to be a very special, very custom GC though.
-
it literally just works
idk after 6 months of callback hell I got used to it. that was what happened before promises, tehe -
@12bitfloat yeah and I had to come from the majestic JavaScript which just lets me do all that to somehow figuring out you can only do tree structures in rust, which nobody even tells you you just have to limit yourself to this strait jacket and if you try anything else you end up in hell, repeat until you learn trees when all your intuition tells you why can't I do a god-damned thing. CAN YOU COMPREHEND THE PAIN?! RAAGHH
-
@jestdotty Talk about differences in experiences :P
The beauty about rust is that it restricts you so you have to write your program in a way that makes sense
The beauty about javascript is that it gives you so much freedom you have to restrict yourself to write a program that makes sense
I honestly like both now. Just different strokes :P -
hjk10155991dUNIX has the "everything is a file" concept. This generally makes things better but Linux (and other modern UNIX variants) make exceptions.
Java suffers from "Everything Is A Class/Object" design. Resulting in similar spaghetti.
JavaScript suffers from "Everything Is An Event" design. This forces even the most linear of workloads to be burdened with asynchronous concepts.
This pain will always be there in any non-trivial JS. Sure new constructs like promises helped a lot to write more like linear looking code (trust me it was far, far worse to keep track with the infinite event callbacks as the only option); but it has the same clunky forced async complexity at heart. -
kiki372471dit's a bummer devrant pics are broken. I would've shown you some of my js that is the opposite of what you're describing
-
retoor84551d@kiki use devrant.molodetz.nl so you can still flex.
It's like python. Everything is allowed so it takes some discipline and yes some experience. It is possible to make beautiful stuff with js. -
@12bitfloat but also quit worrying about memory. A var is a var.
I also recommend keeping just one object with the state and doing a state/reducer pattern -
Ranchonyx1061618hThat's why we use typescript. To lessen the suffering.
Regardless, yes, closures and promises in JS can be a Major pita. -
How are you liking that you can't await async functions on the main ? That you have to call some anonymous async function to await others heh
-
jestdotty640110h@AvatarOfKaine
(async ()=> await whatever())()
I actually don't even remember JavaScript syntax but I probably got that right
Related Rants
Doing some JavaScript right now and holy moly is this one spaghetti ass language
Promises referencing closures referencing local variables referencing message handlers referencing resolve callbacks referencing ... 😵💫
rant
wtf
webdev