Okay okay, I've completely dropped game development for a bit.
See I started getting my Java dev environment set up and fairly early on I got so incredibly bored. Go ahead, ask me how bored I got.
AI: Ok - how bored did you get?
Really bored.
So then I find myself on https://fullstackopen.com/en/part0/fundamentals_of_web_apps (as one does) and I found myself confused (as one does).
Check this out:
var xhttp = new XMLHttpRequest()
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
const data = JSON.parse(this.responseText)
console.log(data)
var ul = document.createElement('ul')
ul.setAttribute('class', 'notes')
data.forEach(function(note) {
var li = document.createElement('li')
ul.appendChild(li)
li.appendChild(document.createTextNode(note.content))
})
document.getElementById('notes').appendChild(ul)
}
}
xhttp.open('GET', '/data.json', true)
xhttp.send()
See that code? The lesson basically says to ignore it. Then it starts to break it down. I'm like "sorry dude, can't ignore the code when you're breaking it down like that". So then I'm all reading it and getting confused.
I posed this question (verbatim) to my AI:
i dont understand how the object gets modified by the server - pass an object over, status gets updated on the other side - wtf
Turns out what's actually happening is something like this:
XMLHttpRequest
object.Except "We send it." is not as literal as I thought.
Here's what "We send it." means:
xhttp.send()
and fires off an HTTP request.onreadystatechange
with, checks its own state every time its state changes and, when the planets align, it updates the DOM.Silly me - I literally thought the object was getting sent over.
So the internet is all about communication. I bet ".com" even comes from that somehow.
AI: No, ".com" does not come from "communication." The ".com" top-level domain stands for "commercial." It was originally intended for commercial organizations, but is now used widely for all types of websites.
Well - ok - so much for my awesome Internet Protocol Suite springboard I was setting up.
Now I don't have any clue what these acronyms mean. But here's the deal:
There are standardized Protocols to Transmit Communications around the net. JavaScript objects are not part of that protocol. I don't know what makes up the protocol, but it's not that.
AI: You can't do this! You can't imply that the "C" in TCP means "Communication"!
Well I just did. And it should. Moving on.
Again, who cares what the acronyms mean. This is the standardized format of the messages being sent over the TCP or UDP protocols.
So if we care what our browser is doing (we shouldn't) we can comfort ourselves in knowing that it's just following agreed upon standards in order to talk to servers. The tools that we are using in our code are just wrappers and abstractions that direct our browser to use these standards.
AI: So that's it? You're just going to name drop Internet Protocol Suite and not explain what it is?
Well, okay then, you go ahead. Three sentences. Go.
AI: The Internet Protocol Suite, also known as TCP/IP, is the foundational set of networking protocols for the internet. It organizes communication into layers, each handling specific tasks like routing, data transfer, and application services. This layered approach allows different devices and networks to communicate reliably and efficiently.
Oh man, that was so boring. Good thing I do most of the talking.
Before I depart let me say one thing about the docs: They do a terrible job of explaining what's going on. Instead of demystifying they just add to the perceived voodoo. This one too.
Not sure how they could get around that though. Imagine trying to write technical documentation and having to aim it at new people. Still, can't help but wonder if there exists an ideal entry point that just needs to be found.
Eh, I wouldn't recognize that I needed it until after I didn't need it anymore.
Oh well, until next time.