Spinning off a new thread because I really like this comment:

https://cybre.space/@jauntywunderkind420/104956363785764927

<< What I do see as a pure virtue that stood for something clear was 9p. Expose your state. Let it span systems. Use common os tools to manipulate state. >>

I like this because I think "expose state and use common tools" is a key design principle in big systems that work (eg, HTTP / REST) - but it also seems the opposite of OOP's "hide state" mantra.

Do we know why?

@jauntywunderkind420 @enkiv2 @byron

JauntyWunderKind (@[email protected])

@[email protected] @[email protected] @[email protected] I take to think those examples are good but also kind of irrelevant. They had good characteristics but only some aspects, amid a lot of things going on. It's too complicated to be clear. What I do see as a pure virtue that stood for something clear was 9p. Expose your state. Let it span systems. Use common os tools to manipulate state.

cybre.space

@jauntywunderkind420 @enkiv2 @byron

Eg: I think hiding state is important too! There are many secrets we have to keep private, everything would fall apart if we didn't have information hiding as a key abstraction.

But... for getting things working, it feels like "let sealed objects handle everything" just kind of... doesn't work, because programmers always do bad things in their objects and never fix them, and so exposing state seems to be the only way we can route around bad programs?

@jauntywunderkind420 @enkiv2 @byron

Or is it more like "expose all state *that was transmitted to you*, and don't hide any inherited state?" Because that's usually data loss.

I don't know. I really don't know. Nothing much about what actually historically happened with these technologies seems to make sense.

Smalltalk was all about messaging, and was inspired by ARPANET, but the early Web doesn't seem like it was at all Smalltalky, though it was extremely ARPANETty. Do we understand why?

@jauntywunderkind420 @enkiv2 @byron

The Web 1.0 wasn't built on Javascript, but the 2020 Web is built on Javascript over CSS over SGML over HTTP over (webapp server) over SQL - at least six completely separate syntax / semantic layers. This seems non-optimal.

What if we removed everything except the somewhat-Smalltalky Javascript?

Could we rebuild the Web on just JS? Would it be better? It would be reasonably trivial to try, because Node.js would be the webapp server.

@jauntywunderkind420 @enkiv2 @byron

Alternatively, if rebuilding the entire Web on Javascript message sends (modulo maybe a NotUnderstood facility like Smalltalk had, or whatever else might be needed) demonstrably *doesn't* work, maybe because it's true that state needs to be exposed in some reliable manner...

.. could we go the other way, build a full-stack programming language on an analog of HTTP/REST?

Why or why not?

If 'not' to either of these, what are we missing?

@jauntywunderkind420 @enkiv2 @byron

One thing that has always bugged me deeply about OOP is that although it's supposedly all about messages, there is no standard or reliable way to represent 'just a chunk of structured data'.

I mean, you *could* conceivably represent 'a foo with parameters bar, baz' as something like

new foo(bar,baz)

or (something).foo(bar,baz)

but.... those aren't really defined in any sense, and aren't good for large messages (kilobytes to gigabytes).

Do we know why?

@jauntywunderkind420 @enkiv2 @byron

You'd *think* that since constructors are a pretty universal part of OOP, that every conceivable data type or structured message WOULD be an instance (sic) of

new foo(bar,baz)

BUT

that just gives you a local reference to an instance of foo

Once you've got that reference... how do you communicate it to another system? It's not a 'message' in any meaningful sense now. Messages can be 'sent'. Objects... are not designed to be 'sent'.

It feels incomplete.

@natecull @jauntywunderkind420 @enkiv2 @byron Talking about method calls as "messages" is something that came out of Smalltalk, and is in my opinion incredibly misleading.

I've had debates with people online who strongly claim there is a difference between method calls in most Java-style object oriented languages and something like Smalltalk that talks about "messages". Most of the arguments seems to revolve around the idea that you can send messages (i.e. call methods) on instances that have not previously been declared to support such method calls.

At the end of the day, it all boils down to dynamic vs. static dispatch. But even for dynamic dispatch, referring to method calls as "messages" does nothing but confuse users and make it seem to complex than it actually is.

@loke @natecull @jauntywunderkind420 @enkiv2 @byron C++ and subsequently Java made that mistake in understanding,, as event based gui systems were not widely experienced yet. . messages are more like events than method calls. you can think of it as tthe difference between desugaring to
sendmsg(objectId, methodname, params) : void
vs
methodname(objectpointer, parans) : somevalue

the difference seems subtle but the former, with an extra level of indirection guves the dispatcher more freedom

@zensaiyuki @loke @natecull @jauntywunderkind420 @enkiv2 @byron it makes it really weird that no one's implemented a GUI app in Erlang other than Wings and the integrated debugger

@libc @byron @zensaiyuki @natecull @jauntywunderkind420 @loke

There are TK erlang bindings. About ten years ago, I ported a large prolog project to erlang (though I didn't, and still don't, really know erlang) & wrote a fair amount of gui code related to that.

But, thing is, the GUI toolkit itself was not erlangy. It was a binding to tk, which is C++ and really intended to be embedded in tcl. So, for instance, it wants to be single-threaded with an event loop.

@enkiv2 @byron @zensaiyuki @natecull @jauntywunderkind420 @loke Erlang ships with Wx bindings, and Wx is.... less antiquated looking OOTB than Tk. still, doing Win32 rawdog programming makes me realize "shit, why can't i just receive {paint, Hwnd, Dc} messages?"

@libc @byron @zensaiyuki @natecull @jauntywunderkind420 @loke

Maybe I used Wx rather than Tk. I don't really remember. It's still sort of the same issue.

And, of course, 'antiquated' is kind of funny because the ideal we're reaching for (properly message-based OO GUI toolkit) is... in smalltalk 78.

@enkiv2 @libc @byron @natecull @jauntywunderkind420 @loke i am not sure i understand smalltalk 78 but my understanding is even smalltalk ended up compromising the messages concept, partly because performance of 1979’s conputers, partly because nobody had failed at it enough times yet to know how not to do it.

@zensaiyuki @libc @byron @natecull @jauntywunderkind420 @loke

The underlying implementation of smalltalk for the alto turned messages into method calls for performance reasons. From what I understand, the language itself didn't break the message paradigm despite this, & graphics programming was async-friendly. (But, my familiarity with it is currently mostly second-hand.)

@enkiv2 @libc @byron @natecull @jauntywunderkind420 @loke so then it’s a little ironic to say the web wasn’t smalltalky, since the system it was implemented on was trying very hard to be smalltalky.

@zensaiyuki @enkiv2 @libc @byron @jauntywunderkind420 @loke

Right! That's one the things that fascinates me. Berners-Lee writes WWW on a NeXT, which at least advertised itself as object-oriented, and if this factoid is true then he writes it heavily relying on NeXT's OOP framework...

... But no trace of that framework and its objects extends over the network. Isn't that odd? And interesting?

Naively one would expect WWW pages to have been serialised NeXT object classes. They very weren't.

@zensaiyuki @enkiv2 @libc @byron @jauntywunderkind420 @loke

For comparison: from the same era, Microsoft Word .doc files of early 1990s were *massively* more OOP than the Web. They were literally just collections of objects but *because* they were just RAM dumps of objects they were unsuited to traversing multiple systems.

And MS thought they'd beat the Web because they were OOP and 'modern' and Web wasn't, until around 1995.

@natecull @zensaiyuki @enkiv2 @libc @byron @jauntywunderkind420 @loke but that was obviously a proprietary format, and also worked on systems where objects were second class citizens so to speak
@natecull @zensaiyuki @enkiv2 @libc @byron @jauntywunderkind420 @loke OLE, OpenDoc, etc weren't truly flexible or open enough to really operate as such an alternative
@natecull @zensaiyuki @enkiv2 @libc @byron @jauntywunderkind420 @loke objects were ultimately merely an implementation detail

@a_breakin_glass @zensaiyuki @enkiv2 @libc @byron @jauntywunderkind420 @loke

Right. I think that's the part that still niggles at me. Why *did* objects end up just being an implementation detail, when the whole idea of an object was 'here is a small machine that is a thing'?

'An object is a thing' *seems* to make intuitive sense. BUT!

The BIG but is that an object is generally 'a thing you can't give to anyone'.

To 'give' an object you have to radically destructure it. Parse to text etc.

@a_breakin_glass @zensaiyuki @enkiv2 @libc @byron @jauntywunderkind420 @loke

So as a programming paradigm, objects seems.... not to be as universal as it wanted to be.

Something about objects seems to weld them to very specific machine contexts that they can't be easily unwelded.

Data formats that can be easily transmitted, and survive multiple systems, seem to be very non-objecty.

This doesn't seem to be what any of the OOP proponents ever wanted. But why couldn't they see that?

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke i dunno, HATEOAS seems like a very smalltalky objecty idea
@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke like smalltalk, and OOP, people focused in on the wrong idea in REST: thinking REST was about URLs, when really it’s about hyperlinks (and forms) enabling a client (web browser) to interact wirh a server without any prior knowledge of the remote application’s internal structure. a strong contrast with modern “REST” apis that now have an ecosystem thar has reinvented CORBA again but named it OPENAPI/Swagger

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

I really like that idea of inverting the application state into a message-like thing that the client holds as a ticket and sends to the server.

However I wish we weren't trying to do that over a protocol built to transfer and display literal documents, because nothing about a REST application is anything like a document.

Especially if we wanted to scale *down* to the desktop - we'd want a very small, fast protocol.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke well, there’s HAL if you wanna do HATEOS in a more applicationy way
Hypertext Application Language - Wikipedia

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke it says it’s “draft” but it’s what amazon uses for all of its apis.
@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke a somewhat more sophisticated version is JSONAPI that is still HATEOAS style but addesses some of the annoying limitations of HAL.
still stuck with JSON as a wire protocol but there’s worse fates

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

I guess I'm wondering if JSON is too heavyweight to be used as a desktop protocol, even for widgets within a windowl? Or do we all have enough excess CPU cycles now that that's not a problem?

Cos if it is too heavyweight then we gonna need another protocol.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke there’s plenty of binary json-like protocols to choose from, but from what i have seen, the tradeoffs are rarely worth it.
the biggest improvement over json i have seen is json-seq, which addresses a specific issue json has with real time applications
@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke don’t bother looking it up. it has a huge rfc that can be summed up as “linefeed seperated json objects”

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

Man everything would be much nicer if JSON hadn't made commas and quotes mandatory.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke oh, maybe i need to clarify a bit- json-seq doesn’t address that.
it just specifies that in your message channel you are sending multiple seperate json objects, seperated by lines, instead of just one big single json object. this lets a reciever respond incrementally without first having to parse a big monolithic json it receieves as a big chonk

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

It does seem weird that they even needed an RFC to specify that.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke well, you see, three different people had the same idea at the same time, and the different versions are not exactly the same. so the rfcs (and i think all three have them) are to name the variants and pin down exactly what’s different about them
@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke the other problem with json as a desktop ipc mechanism is, from the platform engineer’s perspective, all the needless translation between text and objects that goes on. it’s not an issue for small infrequent calls, but say, send an entire photo library from one app to another and your computer hangs from mostly just doing that needless serialisation and i deserialisation

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

Yep.

I guess that's why I keep coming back to 'at the bottom of the tower of bits, you probably just want something like an array of machine words, a type tag, a length' and even then that gets messy, with bitness, word size, memory allocation, etc.

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

and if you were doing anything approaching JSON over top of that, you'd probably want a symbol table so strings can be integers, a way of searching that table rapidly, strategies in place for when some evil person tries to give you a petabyte-sized string, etc

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

But these are all things that I thought would have been solved problems by 1980, and long since become rock solid and built on top of, and it makes me sad that we seem to still be scrabbling around with 'byte' at one end and 'text file / message which is one giant string' at the other end and not much clear in the middle

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke i keep beating this drum but, “structured clone algorithm” is a direct answer to this specific issue. it just, has a really uncatchy name

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

Is there any One True Standard structured clone algorithm, or just a general approach?

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

Ah, it's a Javascript thing?

But I thought you just said that JSON isn't great for desktop use and that we'd need a faster protocol?

Or would W3C Structured Clone allow Javascript objects to be shared outside the world of the Javascript VM?

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

I should definitely read up on this to make sure that I'm not duplicating this functionality, since I started writing a clone algorithm specifically for the purpose of breaking loops in Javascript structure for the Node.js library I'm currently calling 'Termtrees'.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke it’s an html thing, technically. (html standard includes all the browser apis one typically thinks of as “javascript” but are in fact, webidl) and yes, it can technically transfer objects out of a javascript vm to other contexts

here’s the spec https://html.spec.whatwg.org/multipage/structured-data.html

HTML Standard

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

Having read this document, I find myself none the wiser as to what actually has been defined.

It seems to leave quite a lot up to the individual object? What does it serialize *to*?

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke it doesn’t. that’s the point. it pretends to serialise to something but under the covers it’s just passing pointers and doing copy on write

@zensaiyuki @natecull

also, lol, webidl originated with OMGIDL & CORBA. i have no idea how much CORBA legacy lives there.

for the most part WebIDL is abstract, is my impression. it defines what objects & platform stuff will be in the browser, what they will look like in JS. but i don't think it dictates how or what objects, methods, &c look like to the runtime, that they can structure themselves how they want. that said, there ARE language bindings for WebIDL that do just that, but i think the primary consumer of WebIDL is spec authors & browser users using it for reference materials, not for doing CORBA like stuff. i could be mistaken!

https://heycam.github.io/webidl/#introduction

@zensaiyuki @natecull
pardon, chiming in at weird times. ya'll got into this split between the runtime objects & spec pretty shortly on your timelines. i keep jumping in where interested.

i agree it's weird & i really hope we can get webidl typing information more usable & in front of developers. it's weird that we have so many typescript enthusiasts, but so few people who care about types in the runtime??

@jauntywunderkind420 @natecull yes that’s right, WebIDL’s primary consumers are browser vendors. i didn’t realise that wasn’t clear from how i spoke. but i did want it clear that the stuff I was talking about isn’t “javascript stuff”, but stuff that’s intended to be available in any environment WebIDL specs for.
@jauntywunderkind420 @natecull it’s a bit anti-intuitive why i should be excited about a serialisation spec where the serialisarion format is implementation defined, but my point is it addesses the concern about json being ineffecient for local desktop use, by just vaguely pretending the serialisation format is still “JSON”, (and in some implementations it might be!) but since it’s put in places where the wire format is not directly observable, it can be anything, and do any optimisation
@jauntywunderkind420 @natecull and since it’s in webidl that could be between a javascript app and a c++ app. though i haven’t seen any specific examples of this, there’s no weird javascript specific impedence mismatch things standing in the way
@jauntywunderkind420 @natecull as for CORBA vs WebIDL, very similar actually. the original idea of CORBA after all was just to enable a standard way of shuttling function calls between different languages. putting a network in the middle was just an incidental and disasterous afterthought.
@jauntywunderkind420 @natecull aaand, that’s all WebIDL is. a machine readable spec for the interfaces between Javascript and the browser implementation language. or between Java and an html library. or whatever other combinations.

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

Oh.. it serializes object to the "record" type. That's... hmm.

There sure are a lot of exotic new types in Javascript these days.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke or at least, not a thing visible from javascript land. it’s more something you’d run into reading the source code of the v8 engine

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

Oh, I see. ECMAScript "specification types" are not runtime Javascript entities.

That's exceedingly weird and frankly it's everything I dislike about modern programming habits.

Not just multiple types but multiple *types of types* that only exist at the VM level. Just.... ugh.

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

I mean at least one thing OOP got right was the idea that "everything is one kind of thing"

because if you have things that aren't things, that's just.... asking for trouble really. Or at least it means you end up with this big segmented tower of incompatible languages and systems and shouldn't we, really, know better than that, by now?

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke look, specs are undeniably weird to read because they’re not written for you or me. they’re for people writing browsers and operating systems. the MDN page on structured clone algorithm is the user’s point of view.
the whole point of it from my perspective *is* how vague it is about how exactly it should work. it’s only specific about how it should appear to work, leaving the implementations free to innovate optimisations
@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke from a user’s point of view, it looks exactly like sending a json message. it just very sneakily doesn’t actially convert anythibg to json or even copy anything. it only needs to look like it’s copied the object in certain contexts
Deep cloning in JavaScript with "structured serialization"

HTML defines a built-in cloning algorithm for JavaScript, and you can use it from Node.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke it’s not implemented natively in node, but you and i have had a previous conversation where i investigated and found the best available polyfills for node.js, which implement the interfaces but don’t really do the optimisation bit.

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

It doesn't quite look like the level of polish I expect from a "solved problem" though, I guess.

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke it’s a problem that is solved in browsers, fairly thoroughly and, may i add, invisibly! i think aside from brenden eich i am the only cheerleader for this feature.

to everyone else it’s just invisible and unimportant plumbing.

but- what can you already do with it? compile a c++ program to web assembly and let it draw to a binary canvas and transfer large objects in and out of javascript land without seriali overhead

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke as for browser implementations, yeah, they all have it, they just don’t really loudly trumpet its pressnce like i do. it’s really a shared implementarion detail between a bunch of other apis where you would normally expect to be storing or sending a json object
@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke there are a number of “native webassembly” run times, i would be surprised if they didn’t have it. i’d also be surprised if they bother to mention it anywhere.
maybe deno has it built in.

@natecull ah, my eyes have been fucked up all day, i have finally read that page properly. it’s talking about the state of implementations allowing you to access the structured clone function directly, not the internal version used by various APIs.

being able to access it directly would be handy, but unneeded if the idea is just json-like messaging with something lighter weight than json.

@natecull it’s basically like “just send the message, i don’t care how” and then the underlying browser or operating system or whatever can do whatever is most efficient.
Transferable Objects: Lightning Fast!  |  Web  |  Google Developers

@zensaiyuki @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

If it's not a Javascript thing, why is it defined in terms of Javascript objects and Javascript types....?

or do you mean it's not a "Javascript thing" because it's technically ECMAScript?

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke it’s an abstraction used in the spec, like a “call object” representing the collection of scope variables that get carried along with a closure.
it’s not directly visible from javascript, and might not even actually be in the implementation either. it’s just a way of talking about how it should look like it’s acting

@natecull @zensaiyuki Hmmm, seeing this discussion, I'm wandering if DBus's (de)serialization format is a better example...

GNOME's implementation at least is very lightweight...

@a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke

@natecull @a_breakin_glass @enkiv2 @libc @byron @jauntywunderkind420 @loke the easily googleable explanations of WebIDL suck but in essence it’s a DSL for specifying browser apis designed to be compiled to wrappers usable from javascript, java, and c++ and potentially other languages. so anything in webidl is usable at least from those three

@natecull @zensaiyuki

well there's a lot of ways to do it! json-seq, ndjson, jsonlines! everyone has different ideas for how to stream json-like data. :)

https://github.com/ndjson/ndjson-spec/issues/25 mentions a bunch of these & has some discussion. having read it i think i might switch ndjson->json-seq. also anything with an rfc ftw. #rfc7464!

Relation to JSON Text Sequences standard · Issue #25 · ndjson/ndjson-spec

What is the relation to the JSON Text Sequences RFC? Seems that it is being picked up by some projects, e.g. GeoJSON.