Oh no, he's writing about Durable Objects. I know only the high level on that one. Thanks for nothing.
This is the first of (hopefully) 30 posts that respond to Sunil Pai's (threepointohrighthatguy) 31 "DecemberDumps" blog post series he's doing this December. Take these posts with a grain of salt, please. They're quick write-ups and a bit tongue-in-cheek like youtube vids of people watchin youtube vids. If you don't like it or my humor you can turn away now. Unless you're Sunil; then you gotta stay. Them's the rules bud. (I dunno if this format works at all but let's give it a shot)Day 1 (ehh),
Durable Objects are Computers.
Day one and he's already one day late. And he starts about Erlang. Unfortunately that's not my escape hatch cause I know zero about Erlang so I gotta go do this.
I'm somewhat humored at the notion that a computer would still be a "beige box" for some people. I mean, aren't all macbooks pretty much silver/iron/whatever? Unless they're stickered up, but even then, not beige right? Especially people that would read his blog would be more prone to using a mac. I'm just there to skew the results
(I'm on linux pc, not mac). And even for pc users, does anyone still have that mini-midi-big tower model anymore? I've been on micro NUC builds for so long now that I kinda forgot about those towers at all. Desktops are just so much more stylish these days. And I think that's been the case for me for the past two decades at least. And I'm not even a case modder.
(Okay Sunil, you gotta run at least a light spell check over your posts :p)General computer
The description of his "general computer" first pops a Turing machine in my head. But when he goes onto virtual devices I'm just in virtual machine land. Well, I may be a bit elsewhere with humans-are-computers too in a Matrix-style thought experiment. Your brain is a computer after all. But that's my uni speaking and I digress.
Classes
Ooooh, classes. Soooo, fun fact (you're allowed to hate it): I've come to dislike classes in JS. It's funny right? We used to implore the tc39 to implement class syntax way back. And they ultimately did. And now it sucks and I don't ever use it.
I guess it doesn't help that we used almost no classes at Vercel when I was there. Yeah one or two (in-house) libraries did but almost all of the code revolved around flat objects. And that worked fine. Otoh, I think classes are heavily used in the React world? I wouldn't know.
I'm pretty sure their demise is on TypeScript types. Since TS types all these objects and you can still figure out what the type of a certain object is across multiple files/funcs, it kiiiind of moots a big reason for using classes at all. I know that's a very contentious thing to claim. And I'm well aware of various use cases the class syntax has in JS. But at the same time, most ordinary code might just be better of using regular objects (or maps/sets). Class syntax would increase the burden of maintenance and requirement of understanding the language? I've grown fond of the simple JS code style.
Heh, I'm actually not sure if this is an extremely popular or unpopular opinion to hold :p But there you have it: JS class syntax is obsoleted by types.
One advantage of classes is organisation. But these days we use modules (one per file) for that so that already chunks up the code, perhaps even better than classes due to the mandatory one-per-file nature. Another is mental model of the data types. That's pretty much the point of TS :p
And then there's encapsulation. That one is harder to gauge. I'd say for NodeJS (etc) server side envs encapsulation is a bit of a moot point. You might argue that it's not and I'd respond with that this is not Java and shrug it away. Unless, of course, you're building a sandbox. In that case encapsulate away. In front-end the need to encapsulate may have more relevant use cases. And while you could still encapsulate easily with closures, I'll concede that classes do make this easier. Although, I wonder how many people actually know how the private properties work in JS today or how/when to use the hash sign in JS code.
If you have to educate people on your code every time you have to onboard them, that's a pretty big tax, no? Especially when there's easier avenues with the same outcome. Maybe that's simply a question of time and in due time people will get used to private property syntax. At the same time, if I'm right and people stop using class syntax mostly then they won't learn about private properties either and it goes the way of the
dodo generator
(Sorry, but ask your most senior JS devs to explain generators to you and I'll bet most fail anyways).
Durable Objects
Wait what were we talking about? Oh right. So Durable Objects is cloud state that you can interface with more easily? But... still with cloud "functions", right?
Ok, did a quick search on that. Here's
Cloudflare's page on them. So yeah, looks like they're like "serverless functions" (I _hate_ that term) but with the persistent state part of it also solved. Well that's interesting. I wonder if it runs Rust code.