#i really need to learn how to code
Explore tagged Tumblr posts
captainjonnitkessler · 2 years ago
Text
I truly, TRULY do not know how to say this, because the fact that I have to say it makes me feel like I am losing my grip on reality. But no, in the post-capitalistic anarchist utopia, I will not be relying on “autistic minecraft girlies” to be building inspectors because - and this may shock you - one of those occupations takes years of education in how to read and interpret hundreds of thousands of lines of regulations based on complicated math and physics that were the result of decades of tragedy and death, and the other one involves playing a children’s video game.
18K notes · View notes
poorly-drawn-mdzs · 11 months ago
Text
Tumblr media
Dungeon Meshi: Delicious in RPG!
(Sprites + bonus art here!)
834 notes · View notes
misterbenzadrine · 27 days ago
Text
!!binary bfs ghosts au!!
this is mainly based on school spirits (specifically charley and yuri) but it's just not technically the main plot of school spirits so they're just ghosts :3
demetri alexopoulos (1951-1967)
Tumblr media
died of anaphylaxis in the school cafeteria
relentlessly bullied for being gay (though he obviously never came out or even accepted that he was gay)
also bullied for being a nerd who couldn't physically do much
the gay kid that died from a nut allergy; that went over well with his reputation at school /s
in death, he kinda just sits in on stem classes or computer classes bc he's always really excited to see how much has evolved or changed through the years
he's secretly sad he never got the chance to explore the world of science and math and make his own discoveries
eli moskowitz (1973-1990)
Tumblr media
died of asphyxiation after a panic attack in the greenhouse triggered his asthma
largely outcast bc of his scar and his "intimidating" energy (he has resting bitch face and is really trying not to have a panic attack every five seconds) (all of this is still true, even in death)
spent a lot of his time in hs skipping class due to anxiety and smoking to calm himself down
in death, he spends his time sitting in the band room playing a guitar
the other ghosts avoid him and think he only speaks hebrew and he lets them bc he wants them to leave him alone
he forces himself to only focus on smoking and playing his guitar, since anything else would force him to confront the reality that he's dead and a ghost for eternity
Tumblr media Tumblr media
when they first meet, demetri makes a few bad science puns, thinking eli won't understand it anyway
eli corrects him since he said one wrong, and demetri has a totally normal reaction (he flinches and falls into the percussion section)
demetri comes back every day to figure out how much eli knows about science/math/engineering (a lot, he finds out) (it's just like a whole week or two of him going to the band room and yapping with him about stem stuff then wandering about the school every single day)
eli ignores everyone but demetri, even though they now all know he knows english
demetri indirectly convinces him to leave the band room ("the chemistry teacher on the second floor is pretty good but she sometimes forgets the formulas. you'd probably know more about that than me, though. it'd be nice for you to fact-check her when i sit there. but anyways-")
eli feels like he's exploding with nerves when he steps out of the band room for the first time in actual decades but the excited smile on demetri's face when he sits next to him in the chemistry classroom makes it worth it
they reverse-engineer some old computers together, do some experiments, practice balancing some chemical equations with leftover worksheets, etc.
they also figure out how to use a computer together ("i think i saw someone click this icon one time" "do i have to click here to type a question too?" "you literally know as much as i do. more, even. computers were barely being installed at nasa when i was alive.")
~~internalized homophobia~~ hits demetri hard and when eli makes the first move (for once !), demetri immediately shoots him down and runs off to the roof while eli retreats back to the band room
the other ghosts grow frustrated with them over the following week when demetri mopes in the basement hunched over the same telephone he keeps deconstructing and resetting day in and day out, and eli plays the same sad song over and over again (he also destroys his guitar and lets it reset on one of the days)
one of the other ghosts, miguel, coaxes demetri out of his burrow in the basement and has a LONG talk with him about what happened ("demetri, you've been here longer than most of us. you've seen how things changed. i know stuff was hard in your time but none of us are like that; eli really likes you, dude, and i know he makes you happy. what's stopping you from being happy?")
demetri visits the band room and nervously talks things out with eli, who stays quiet the whole time while he tries to control his breathing
they agree to take things slowly so demetri doesn't freak out about how other people will react
eli teaches him how to play some songs on his guitar (namely "sweet child o mine" bc that's one of my all-time favs) but demetri always prefers to hear it from eli
Tumblr media Tumblr media
we need more binary bfs au's
32 notes · View notes
sadlynotthevoid · 3 months ago
Note
Why can't nii give Sakura interesting layers to his character outside " traumatized socially awkward teen" like any interesting new revelation about him? Give him close or special person " relative, friend" anything!
His distant and closed off personality is boring icl
From where? All the people who discriminate him?
If he had actually had people who had accepted him before, why would had him gone to try to gain a sense of self-worth by beating people up in the middle of who knows where?
Sakura's character goes taking shape as he gets to experience things beyond reject. Like how his favorite food is omurice, probably because it was (I suppose) the first meal someone has gave him because they wanted.
But if we're talking about something he is that can't be linked downright to his trauma and the shitty life he had, then that be his kindness. Bro doesn't have a single reason to be kind, he just is. Despite how people took that kindness coming from him.
There's also how bad at technology he is. You can't blame that on his lack of bonds. Suzuri has only just started playing games (finally) and he's already better at it than him. Meanwhile, Sakura has had his phone since before joining Furin and boy can't type a single message. Yeah, you could say he didn't have no one to text to, but has he never used internet? Google or whatever search engine Japanese people use?
To be honest, that only makes me wonder what did he do in his free time. I mean, teenagers without friends tend to spend their free time reading or online. Did he seriously just sleep? Did bro spent all day sleeping or fighting?
Bro, is this how you got so good at parkour? Did you go up in any given chance to avoid people to the point you can compete with cats?
This kinda just made his character funnier to me. Here there's a teenager with no friends nor social life, with an avaible phone, who never thought on using internet to waste time.
I got sidetracked. Anyways, yeah Sakura's trauma is a big part of his character. No, he probably doesn't have any positive bonds linking to anyone of his past. (If he had, then probably something bad would had happened for him to move away of them so...) Well, I don't think he has. And about the last part—
"Distant and closed off" is really just how he starts. He's defensive, yes. But he's terrible at keeping people away and literally can't reject their kindness. Just on the first chapters bro ended up carrying a mountain of food because he couldn't say no. He also finished it all.
There's also that funny scene when he carries granny Sato on his back all the way to Pothos— only for her to jump off his back and land in a superhero pose (we love granny Sato).
He also goes to Anzai's childhood friend (the girl one)— I don't remember if he went to know what was going on with Anzai or he asked because she was crying— and listened silently to her story. That's kinda why he followed Anzai and all that.
And then in the Noroshi arc, after getting his ass beat and finally winning Endo (in whatever sense you prefer), he still helped him to get to the roof to watch the Umemiya vs Chika (almost typed Chiaki— whoops, wrong fandom) fight.
He's not distant (despite his name), he's defensive (hence the tsundere behaviour), mostly when he's embarrased, and silent. He's also really naive ("Oh, you're foreigner?!" and literally every interaction with Suo, lol).
He also seems to be a fast learner when it comes to fighting (he literally uses Tsubaki's way of kicking after the gravel arc, has used one of Choji's move before, and then there's whatever he did in the bridge), seems to have strong morals, and he also hates hats and glasses. Though that last one is most likely related to his trauma (i think it was referenced before, but I could be wrong).
A pity you find him boring, I guess. You don't have to read it if you don't want. You can also read it because of someone else besides the main character.
15 notes · View notes
puppppppppy · 1 year ago
Text
Tumblr media
I CANT USE CSS ON ARTFIGHT...............
#I WAS REALLY HOPING TO FIX THE FUCKING. PARAGRAPH WIDTH. SIGH#idk why but it stretches across the ENTIRE page like. it takes up the full width of the browser and it BOTHERS ME. ON ALL THE PAGES#i could try manually putting shift breaks but im worried it might not look so good on mobile. ugghh... auyggghhh.....#im already learning CSS and API so i thought i could put it to good use but. AUGH#this whole time ive had to go into the inspect panel myself and change the padding so i dont have to read the length of the screen#like a fucking typewriter... i would have also loved to use custom fonts and animations......#i did find a guide for BBCode which the site uses on default and it covers basic styling but its not the same. sniffle#you CAN unlock CSS if you donate $25 to the page which seems fair. and if i could do it i would but. i do not have any way of#sending or receiving money online </3 i really need to figure out how to do that so i can set up comms like i said i would last summer#but it intimidates me.... and im already kept on a short leash when it comes to that so it feels like a lot of things could go wrong#i think toyhouse allows CSS or some sort of code...?? i remember seeing some oc pages with custom layouts#if thats the case i'll try fiddling with it but im not very familiar with using toyhouse so thatll take a while#(thanks again for the code sal ^_^ ill put it on my pin once its ready but im trying to learn my way around the site heh ;;)#at least i can use my pixel dividers.. ive been digging around for pixels to use and found some really cute ones#yapping
49 notes · View notes
angy-grrr · 3 months ago
Note
I don’t get why ppl keep saying bkdk is dead or Horikoshi broke off bkdk. If that were true, this extra would look very different as you pointed out multiple times. The extra was still heavily focused on them and I hate how ppl are letting one no dictate the entire relationship. Izuku asks him to be a special lecturer too. I think the no just needs more clarification but other than that it is mostly fine. If a ship were to be shut down by the creator, it would look very different. Same logic for if a ship were to be canon, it would look different than what we got in the end for izu///ocha. This extra was bad in different ways from ships. It was just a whole lot of nothing that doesn’t meaningfully add anything to the story but I guess we shouldn’t be surprised since it is an extra. It is still an ambiguous ending that can be pretty fixable by one shots by Horikoshi in the future or even better by fanfiction lol. Except for the Toga part. That is just inexcusable
himiko-chan :(
and yeah! like even tho 431 is terrible not only for pairs but also for the whole story, it only confirmed Katsuki feels something really strong for deku and he doesnt notice bc he doesnt consider himself to be that great; they keep talking, and they keep being in each other's lives with no problem -they also imply they will work on communicating their feelings, as the special lecture is about this topic and deku also thinks katsuki doesnt see himself in a high regard. This is actually something that could be used in the future, as their relationship and arc isnt completely finished -in the way that they arent at a point of no miscommunication, no yearning, etc. They still need something to work with in regards to themselves and each other in the process. When it comes to midoriya and uraraka, idk what exactly could develop from what 431 tell us -seems to be mostly about paying attention to the ppl in your life instead of just letting life happen I guess? But idk what conversation or arc they could have together that wasn't resolved already, it was a really weird choice to focus on them as if there needs to be more explored -which is why choosing to not make them talk to each other nor think of the other in these years is potentially interesting, like the only way they could actually need to talk things up or have a separated special moment is if they just stop being friends and want to talk more from now on. Like, if they kept their friendship these years and were part of the other's life, there wouldnt be a moment like this at all.
I think it hurt mostly ochako -and deku if we interpret it as "deku just wants to be teacher, he is super happy about it, and loveeees so much his ex bestie after 8 years of no contact and never thinking about her"-, more than the bkdk relationship.
It would be interesting to see those one shots, if he does them -I know he said he wanted to do more things and little drawings and content for it, but idk if he will do something elaborate or just one page of something silly. I think he still has to opportunity of working with the material and make something at least not this bad -or completely ignore 431 and just continue with their adventures like 430 implies lol If he wants to double down with the "romance" I have no idea how he could do it with what he has tbh, unless he just ignores the plot and their personalities.
#grrr talking#thanks bc I was getting a little crazy like wowowowow am I just making things up in my head???#I think bkdk keep having romantic connotation even if deku is so clueless#and while is sad to see them be insecure about themselves I think they do have reasons to do this more than ochako#she did learn her lesson with 429 and talked things with deku already -which is why you had to make them go no contact for them to even#have a “moment” -there was no need for them to develop anything with their friendship. and it still ended in a friendly note#while katsuki and deku never got to actually talk about their feelings alone#nor discussed all the trauma related to each other -the quirklessness the war shigaraki killing him the guilt over so many things#deku on another hand doesnt really have much to tell uraraka that would fit them as there wasn't a moment the war actually involved them tr#truly besides the himiko moment -which would lead to himiko's love for ochako and while this could be used to make her confess#its really... bad honestly considering thats the only thing that relates them -another girl who loves both#there wasn't a moment of him paying special attention to her in a romantic coded way and everything was just... pretty friendly honestly#while the war directly involved katsuki being targeted for being the closest to deku of them all#I makes sense for them to need to talk about this in comparison#what deku as a character needs is to consider why he doesnt see himself as important and why isnt he allowed to accept more for him than#what he got#and I just dont see how this could work with her considering they dont have a real friendship anymore#I cant see neither trying to push the other into being honest about hidden feelings for the other bc... why would they have that?#and why wouldnt they just talk about it before? as I said their arc was really done before the extra#which is why you had to make them lose their friendship and want to talk more from now on -bc if they keep being friends there wouldnt be#any moment that could be ambiguous enough#but with katsuki there are things left unsaid even when keeping in contact that involve each other and their self esteem#meaning they need to work in their communication#with 431 deku “going for” uraraka doesnt come off as “him choosing himself” and “living his life”#bc it was a decision that didnt involve any internal discussion about why he is the way he is#its not framed as him finally choosing for himself or being selfish -he just found her in his way home and wanted to talk more after no con#contact#he is still insecure about his needs and doesnt understand what katsuki means when he talks in such abstract ways#its not like he understood “oh I have to choose someone” or “I have to find my special person” bc he wasn't embarrassed about wanting to t#talk to her -he loves everyone yeah but he wants to talk to her more (they haven't talked to each other in so many years!)
7 notes · View notes
empressofthewind · 6 months ago
Text
It’s Mello’s birthday next month 👀‼️
11 notes · View notes
airs-headspace · 3 months ago
Text
Guys I'm such a silly goose... I realized half the reason I am not really playing Abi's Stardew run is because she is a crop, flower, fruit, and bee girl... I need to plan her farm appropriately 😭😭🩷
And for Dante THE REVERSE... he's an animal guy through and through 🖤 he'll obviously have some crops too but EUGHHU
They're both fishers cuz I love fishing... Dante is more heavy on Mining than Abi is but she's also pretty into mining.
ALSO OMG!!! I WAS SO STRESSED ABOUT WHO DANTE WAS GOING TO MARRY THAT I FORGOT I CAN GET KROBUS AS A PLATONIC HOUSEMATE!!!! DANTE'S ACE SELF IS COMING FOR YOU, BESTIE KROBUS!!!
AUUGH!!
5 notes · View notes
adore-gregor · 1 month ago
Text
i'm back on tumblr (again)
#exams are over mostly#for now at least until may altough i might have one next week let's see#but so far so good#i did postpone a few unfortunately thought but it is what it is i'll still have to do them this semester#it's gonna be tough but i'll pull through and i want to prepare even better i can do this#the one's i did though i die exceptionally well on which makes me kinda proud ig#i got an a on two really difficult one's as the only person :oo lol ig i did something here#feels like i cracked some code for studying and ngl it feels so good i want more results like these#not sure it will work on all exams though but i feel like my studying techniques were pretty spot on and i actually studied more than usual#i feel like i'm getting addicted to this lol like actually being good at uni feels so good so rewarding#i mean i always wanted it and i have been good at uni for some time now but like i did even better this semester - i finished with no c#and lots of a's#but then also i wish i could just study for the enjoyment of it 🥹#don't get me wrong i love learning and being at uni most of the time is actually enjoyable :)#and i like learning the materials because it's interesting to but actually sitting down to study - the anxiety takes so much away from that#when i sit down and study it's usually with so much anxiety ... how do you study without those negative thoughts in your head constantly#i'm always convinced i'm gonna fail anyway and also when i don't meet my study goals on a day i get stressed because i'm behind schedule#and disappointed whenever i don't study as much as i planned or even not at all#like i tell you before i wrote that exam i got an a on i thought oh i might fail i'm gonna need a bit of luck to get a d#altough i thought i could also get a better grade but i have no judgment#part of me still thinks i got a bit lucky with the questions and i still cannot fathom how i did that ngl#i'm trying to stop these thoughts to make studying more enjoyable and i try to tell myself it's not a linear process#and sometimes it takes longer than expected but then your knowledge increases exponentially at one point#or i also feel like i set myself such unattainable study goals i'm bound to not meet them#and i should really prioritize my sleep more and not study in terribly sleep deprived states sometimes#i did get better with that but still it's so bad how i'd sacrifize my mental health for my grades 🥲#but if i'd fail an exam or do badly on it i'm also always so disapointed in myself so it's like i can't win 😅#i just want better balance with good grades and having a life and being in a better mental state#i do have some internal motivation like i want this for my future still i wish i could be more internally motivated#i also don't want my parents to worry and want to make them proud altough that's not a bad one
3 notes · View notes
the-potato-beeper · 3 months ago
Text
i've almost finished with the coding on my first game! now i just need to finish making allll the sprites
2 notes · View notes
thedeadthree · 8 months ago
Note
🎶✨when u get this, list 5 songs u like to listen to, publish. then, send this ask to 10 of your favorite followers (positivity is cool)🎶✨
AIRIKA HI TY TYY DEAR this is the cutest thank youu and i hope ur well!! i adore yelling about tunes EEEK 🥀💌☺️
𝐁𝐋𝐎𝐎𝐃 𝐔𝐏𝐎𝐍 𝐓𝐇𝐄 𝐒𝐍𝐎𝐖 — hozier, bear mcreary.
𝐒𝐘𝐌𝐏𝐀𝐓𝐇𝐘 𝐈𝐒 𝐀 𝐊𝐍𝐈𝐅𝐄 — charli xcx.
𝐇𝐄𝐀𝐕𝐄𝐍 𝐎𝐑 𝐋𝐀𝐒 𝐕𝐄𝐆𝐀𝐒 — cocteau twins.
𝐀𝐋𝐋𝐈𝐄𝐒 𝐎𝐑 𝐄𝐍𝐄𝐌𝐈𝐄𝐒 — the crane wives.
𝐓𝐇𝐄 𝐖𝐇𝐈𝐒𝐏𝐄𝐑 𝐍𝐄𝐓𝐖𝐎𝐑𝐊 — ramin djawadi.
#🦇: airika#carrionsflower#leg.asks#YOU SWEETEST SOUL YOUU ty tyy so much for the ask this was the cutest to do!! 🥀🥹#THE FIRSTT is soooo s/olas coded dragon game really YANKED me back in to thinking about it all the time 🥀🤡☺️#teehee 3 is for a new clown for x*men HEHE 🥀☺️#2 and 3 are also h*elaena hawke vibes too 🥀👁️#i mean i have yelled about the fourth for cy but *screams* ITS SOO VELAENE AND VELAENGWAYNE UGHH it makes me crazy kdjxhxh 🥀💀#i need to give her a formal introduction and her and her beloved (🥀🙄🥴) so soon !!!!!!#and lastly!! the fifth is the closest i think so far to what i think a theme song for irulanne would be?#raised a city elf until found by the sisters (a subset of the mourners!!)#she lost her network of fellow orphans and spies around but as she had magic she gained a new whisper network in the undead as her ‘birds’#its how i would say she learned of v*arric and feanorians interest in taking her on as the rook!!#she snuck out to the rendezvous sooo fast kxjxhxh#i mean they were preparing her to be the next arcane advisor/spymaster (she’s a two for one we love a multitalented girliee)#and maybe even to marry and or have a ‘legitimate’ heir with a monarch#or at least very close by to a/the throne yk? mourner mage with close ties to a throne was their goal 🥀💀😵‍💫#they were VERY into the idea of having a mage on a throne one way or another and so her leaving#is going to be SOO interesting for her to go back 🥀💀#i mean if they try to throw it in her face they gave her a life so many dreamed or something ->#they can take it up with her crow husband or something 🥀🥴☺️ good for her i think!!#but after things went sideways with the ritual i think she had begun to reconsider ditching the sisters oxjxjxh#that’s remedied when she meets luca though HEHE 🥀😌#prodigy orphan with gifted kid burnout meets scion of family prodigy with gifted kid burnout THEYRE SOO <3#ANYWAY LZJXJXH i missed yelling in the tags so i took the opportunity if yall read that im baking u cookies rn 🥀🤧🥹!!!!!#also this almost would be just c*harli bc the way her album has been on a loop for me 🥀☺️😌
2 notes · View notes
pizzahutchan124 · 9 months ago
Text
on god tho
I just want this disability check to go through so that i can spend my limited spoons on cleaning my house and drawing shitty fanart of ships and self insert drawings
2 notes · View notes
vegley · 10 months ago
Text
hi guys i am pretty bored
2 notes · View notes
raskies456 · 1 year ago
Text
learning python rn and nothing boosts your confidence like finding the bug while the person teaching you is coding live
3 notes · View notes
paradoxiii · 2 years ago
Text
Tumblr media Tumblr media Tumblr media
The first version of Ebony was made way back before HeroForge even had coloring, I had to do that in CSP lol.
The second was done not long after they started implementing colors (for free users)
And now, even though that campaign was just a two-shot & I don't intend to reuse her, HeroForge has come a long way so I decided to update her model today! They don't have anything like a cardigan, but I think the blazer suits her quite well!
3 notes · View notes
quietmarie · 2 years ago
Text
What is Async Anyway?
Explaining async/await and general concurrency concepts in programming languages.
A lot of modern languages have async/await syntax built directly into them, and the construct can be extremely useful. Examples of languages that include these concepts are JavaScript, C#, Python, and Swift, and even modern relatively low-level languages like Rust have this syntax. Even though it's usually thought of as a more advanced feature, I think it is really not that hard to use once you get the hang of it, and it is super useful and rewarding when you really understand it.
This is going to be a bit of a long and pretty technical post, but I hope it can give you some confidence to know what async/await really does when you use it, and maybe it can help you use it more effectively. Keep in mind that I will not be able to go over everything in super deep detail, and that I am going to simplify stuff, but it should give you an idea how these systems work.
I am a little curious about eventually following this up with a post looking at how these systems compare under the hood in different programming languages, so let me know if you'd be interested in that.
Big post under the cut.
Parallelism and Concurrency
Computers today can do many things at the same time. And I mean that literally: in one instant, a modern CPU can be working on multiple instructions. That's because a single CPU has multiple cores that can all execute code (mostly) independent from each other. This is called parallelism, and the way we as programmers interact with that is through threads. Most programming languages, especially "lower level" ones, have a way for programmers to create a thread that will run some part of your code. Creating a thread is telling the computer that it can, and should, run the code in your threads in parallel (although various systems such as the OS still have discretion over when and if that actually happens).
Parallelism is not quite concurrency tho. Where parallelism is about your computer literally doing multiple things at once, concurrency is about your computer doing multiple things, but not at once. With concurrency, you kind of pretend you're doing a parallelism. But in reality, stuff doesn't happen at the same time. Instead, your system (runtime) does some work on task A a bit, then on task B, then maybe again on task A, etc., but doesn't work on the two at the same time. So, in a concurrent system it might look like task A and B are progressing simultaneously from the outside, but work actually only happens in sequence.
Let's Talk About I/O
I/O stands for input/output and describes data in your program that comes from elsewhere, or that gets sent elsewhere. So for example, user input is I/O. And similarly, a web request can be I/O, whether you send it or receive it. So let's use that as an example: you send a web request to some API to fetch you the cutest bunny images and facts:
Tumblr media
But the service is taking its sweet time to respond.
Tumblr media
Fact: Loading bunny fact…
With how we did it here, we halt execution of the entire thread until the response comes in (at least in most languages, more on that later). In this case, we call get a blocking method because it, well, blocks the thread without actively doing useful work.
What if we could instead use the thread for other tasks instead of just sitting there, twiddling our thumbs and waiting on the server? This smells of concurrency…
Callbacks
Callbacks are a way for programmers to avoid that period of thumb twiddling. The new getWithCallback function now returns immediately, but it doesn't return a value. Instead, we have to register the code we want to run once the server responds with the function:
Tumblr media
The function we pass to getWithCallback is called the callback, and it gets called by the client* only once the response arrives. Oh look, here it is:
Tumblr media
Fact: A rabbit's life span is about 8 years, though sterilized rabbits (those who are spayed/neutered) can live as long as 10-12 years.
*"The client calls it" is a big simplification, there might be a lot more stuff happening here. But the important bit is that the client magically does not need to block to wait for the response.
Promises and Futures
What JavaScript calls Promises and what a lot of the other languages call Futures is essentially sugar sprinkled on callbacks - it makes our callback code a little nicer. Callbacks can commonly create a concept called "callback hell", where you have to call a function that takes a callback inside the function that takes a callback inside the function that takes a callback…
Tumblr media
(Code modified from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises)
To avoid this, functions now can return a Promise instead of taking a callback. Promises represent the promise that, while a concrete value might not exist right now, it will in the future. Once the value exists, we say the Promise resolves. The code above with Promises would then look like this:
Tumblr media
It still doesn't look perfect, and there are things you can do to make it look a little nicer, but it's so much less nested. The callback in the then function will be called once the value is ready, and the callback itself can also return a Promise. The then function then returns a Promise which will get resolved once the future from the callback is resolved. Many other languages have a concept similar to JavaScript's Promise, and it's often called something like Future or Task (because it would be too easy to have consistent naming across languages).
Now keep in mind neither of those solutions above are really "concurrency" in the definition we used above. This is because the thread we call, for example, getWithCallback on still completely belongs to us. We could keep using it, and we would not get interrupted to execute the callback. Depending on the language and runtime, the callback might get executed on a different thread, or the runtime might have to wait until we are completely done with what we were doing to then use our thread to call it. The same thing goes for the callbacks in the then method of promises.
Async/Await
And async/await is just some sugar and magic fairy dust on top of Promises (or Futures or whatever). It makes our code look like it should be blocking, but in reality it isn't. Here's what our bunny image code looks like with async/await:
Tumblr media
So here, a couple things happen. First, the Promise is created and the web request is initiated. Then, the Promise is awaited. For that, (if the Promise is not resolved at this point already,) the task first yields, meaning it tells the runtime that it is not doing any useful work at the moment, and that the thread it ran on can be used for other tasks. The runtime then makes a note of where to continue execution when that Promise resolves, and looks around for other tasks that currently need executing to put them on that thread. After a while passes, the Promise resolves, and once the runtime has some resources available for us (maybe because another task just yielded), execution on our original task is continued with the API response.
Tumblr media
Fact: A rabbit's teeth never stop growing! Many people believe they need to chew to keep their teeth short. While they do enjoy chewing, it's the normal wear from where their top and bottom teeth meet that keeps a rabbit's teeth short.
This is more in line with the concurrency we sought out above. We can interleave other computations while our task is still running, but during times where it is not doing any useful work. (Still, because you may have multiple threads your tasks can run on and move between, it might not always be 100% technically accurate to call this system concurrent.) This is also why it is important to not block for long in async contexts: if you're hogging the thread for too long, you're stopping other tasks from progressing and throwing a lot of the benefits you gained from doing it concurrently in the bin. Most async runtimes will give you some option to run expensive or blocking code elsewhere, so that you can keep the benefits you gain from async.
So that's the explanation what async/await does, and the broad strokes of how it works. If you have any more questions regarding the topic, feel free to ask! I think it'll be fun to occasionally write a longer post on interesting things I've learned, so if you have topic suggestions, don't be afraid to tell me!
Further links and sources
Don't Block The Event Loop! - Why you should avoid blocking in Node.js, and what pitfalls to look out for.
I got the bnuuy images and facts from the animality API. The licenses on the images are not super clear, but I'll assume it's okay for me to use them here with credit because it's an open API.
I lifted the definitions and some of the explanation for parallelism and concurrency from Steve Klabnik's talk on Rust's Journey to Async/Await. The talk is more technical and very focused on Rust, but it's a great talk.
I referenced the mdn web docs at various points, they're a great resource.
I created the code screenshots using the carbon app.
2 notes · View notes