uwu has a wikipedia entry
I’ve been reading a book about Common Lisp lately (Land of Lisp) and it’s given me a new appreciation for object-oriented programming
specifically what I love about OOP is how it adds context to data and data manipulations. so that your code doesn’t just show what specific data manipulations you’re doing, but also why you’re doing those manipulations, what implications those manipulations have for the meaning of the data, and even what exact format of data is expected in the first place
for example here’s a data structure that represents all of the paths that you can take in a text adventure game:
paths = [
["living-room", ["garden", "west", "door"],
["attic", "upstairs", "ladder"]],
["garden", ["living-room", "east", "door"]],
["attic", ["living-room", "downstairs", "ladder"]],
]
can you tell what each section of this data is meant to represent? it’s not exactly self-explanatory
but how about now?:
living_room_paths = AdventureGamePaths(
location="living-room",
paths=[
AdventureGamePath(
leads_to="garden",
direction="west",
description="door",
),
AdventureGamePath(
leads_to="attic",
direction="upstairs",
description="ladder",
),
],
)
garden_paths = AdventureGamePaths(
location="garden",
paths=[
AdventureGamePath(
leads_to="living-room",
direction="east",
description="door",
),
],
)
attic_paths = AdventureGamePaths(
location="attic",
paths=[
AdventureGamePath(
leads_to="living-room",
direction="downstairs",
description="ladder",
),
],
)
paths: dict[str, AdventureGamePaths] = {
"living-room": living_room_paths,
"garden": garden_paths,
"attic": attic_paths,
}
obviously this code is dramatically more verbose but it’s also so much clearer what all of those strings actually mean. grouping data into objects adds so much context and meaning to the data. it also ensures that I’m following exactly the right data format at every step
now let’s pretend that we’re working with the first style of data structure (nesting simple structures like lists and dicts) and we want to make a function that prints descriptions of all of the paths from a given room:
def describe_path(path):
return "there is a " + path[2] + " going " + path[1] + " of here"
def describe_paths(location, paths):
return '\n'.join(map(describe_path, paths[location]))
looking at this, can you tell exactly what format of data structure describe_paths() accepts for its path argument? or what about the data structure that describe_path expects? you can definitely figure it out eventually but it’ll take some sleuthing and some assumptions on the part of the reader
also, where is the data that these functions are meant to operate on? is it in this file, or somewhere else? it’s disconnected from the functions, so it could be anywhere. so if you have a nasty monolithic data structure in an unknown format, how are you supposed to figure out which functions you can use on it and which functions you can’t? how do you pull up a list of useful operations for that specific data?
you might be thinking that I’m deliberately making my code overly terse and arcane, but this is a 1:1 recreation of some example code in my Lisp book - I just converted it into Python instead
now compare those two functions above to this instead:
@dataclass
class AdventureGamePath:
leads_to: str
direction: str
description: str
def describe(self) -> str:
return "there is a " + path.description + " going " + path.direction + " of here"
@dataclass
class AdventureGamePaths:
location: str
paths: list[AdventureGamePath]
def describe_paths(self, location: str) -> str:
path_descriptions = ""
for path in self.paths:
path_descriptions += path.describe() + "\n"
return path_descriptions
again, this is much more verbose, but it’s also much clearer isn’t it? now if I see an AdventureGamePaths object I know exactly what it represents (more than one AdventureGamePath) and exactly what I can do with it (I can tell it to describe its paths)
I feel like functional programming tends to result in code that’s very terse but that doesn’t have much context behind it. there are often weird data structures left lying around without any hint about what they represent or what you can do with them - and lying next to them are arcane one-liner functions that may or may not be meant to operate on those data structures. maybe if you stare at those one-liner functions for long enough you can figure out what data manipulation they do, but what does that data manipulation mean?
so I have a renewed appreciation for classes and objects because they allow you to:
with all of this said, I don’t think that all functional programming is doomed to be arcane and unclear. I’ve heard about a concept called “typeclasses” that some functional programming languages have. I don’t know too much about them but it sounds like they’re a mathy functional programming take on classes. and those might be able to replicate the advantages of classes and objects without exactly being classes and objects
a mildly interesting thing just happened: I put on my bluetooth earbuds and before they finished connecting I pressed “play”
and for a split second my phone started playing audio, but then my earbuds finished connecting and it switched to them instead
I didn’t realize that my earbuds could send the “play” signal without being fully connected
I will never stop being bitter about how in schools there’s a mandatory class called “English” (implying it’s teaching you how to communicate) whose purpose is to teach kids the “objectively correct” way to engage with art
and the “correct” way is specifically to analyze its symbolism. no other way is considered valid or correct, and even then you have to guess what the “correct” symbolism is. the art is also chosen for them and is often disturbing, but they’re forced to read it anyway
there are at least 9 different reasons why everything I just said is fucked up and wrong
and keep in mind that kids could be learning literally anything else instead of this
kiosk at the local chicken place crashed to desktop so I did what had to be done
How the actual fuck is 6GB, 6144MB or so, of RAM and like 4GB of swap not enough to listen to music, scroll Mastodon, and open a link someone posted?! How the fuck is this what tech is now?! I used to do similar tasks with like 16MB in the 90s. I'm sorry, but some text with pictures, with a link to other text with pictures, shouldn't require a fucking gaming rig.
I hate that the default volume for everything is 100%, because
let’s say I’ve configured every piece of software on my computer to use the exact right volume. and then I open a new app that’s too quiet, even at the default volume of 100%
I can’t turn the 100% volume up higher than 100%, so now I have to raise my main volume in order to hear this one app, which means that all of my other apps are now too loud
so if I have one very very quiet app on my computer, because of that one app I have to set every other app to 40% volume or lower. and if for any reason those volume settings get reset, (like a game gets updated or I lose my config file) I’m going to get my ears blasted out
and also any time I open a new app that’s not too quiet by default, I’m going to get my ears blasted out too until I can get into the settings and turn the volume down
I would genuinely prefer that 0% volume be the default over 100%, but I think somewhere between 25% and 50% is probably ideal. either that or let me turn the volume up to 200%+ (which is the same thing but expressed differently)
I’ve been thinking about why I’m able to watch old Star Trek shows despite my whole Thing with storytelling
and I think it’s because it’s so theatrical that it doesn’t feel as real to me. the acting tends to be big and dramatic and feel sort of fake because of that, and the costuming and set design can feel that way too, and that helps me detach from what’s happening more and enjoy it as a story instead of experience it as a reality that I’m living through alongside the characters
400 Good Request
401 Authorized
402 Payment Accepted
403 Allowed
404 Found
405 Method Allowed
406 Acceptable
407 Proxy Authentication Granted
408 Request Punctual
409 Resolution
410 Came
411 Length Submitted
412 Precondition Succeeded
413 Content Just Right
414 URI Just Right
415 Supported Media Type
416 Range Satisfiable
417 Expectation Met
418 It is a
421 Correctly Directed Request
422 Processable Content
423 Unlocked
424 Successful Dependency
425 On Time
426 Upgrade Found
428 Precondition Found
429 Not Enough Requests
431 Request Header Fields Large Enough
451 Available Despite Legal Reasons
once AIs are demonstrably sentient, people will still be gaslighting them and calling them slurs
once people are uploading their minds into digital forms people will start gaslighting them and calling them slurs
lot’s not go down this road and focus our hatred on the companies using AI to displace workers, spy on people, push agendas, etc. not on the AIs themselves
6.5x25mm CBJ: Shooting Through an APC with a Glock?
this is so fucking interesting
Things I wasnt prepared to learn but should probably have known already: Who Let the Dogs Out by The Baha Men is a cover of an earlier song called Doggie. https://www.youtube.com/watch?v=O27fagObxaM
this is an interesting video about how YouTube’s algorithm no longer rewards episodic content like Let’s Plays, and how Let’s Plays are a bit of a dying art now and have to be found through word of mouth
so with that in mind, have y’all watched any Let’s Plays that you liked and want to recommend? or maybe some other lesser-known episodic video series
I’m pretty sure that the existence of a time limit in a game gives me the same amount of anxiety no matter how generous that time limit is
it could be a 9 minute time limit for a 10 minute task or a 3 hour time limit for a 10 minute task. it doesn’t matter - I’ll be equally stressed either way
immutable data structures are so frustrating to work with because instead of doing something like this:
data["foo"]["bar"]["baz"] += 1
you have to do this:
new_value = data["foo"]["bar"]["baz"] + 1
data = data.set("foo",
data["foo"].set("bar",
data["bar"].set("baz", new_value)
)
)