dedbox
2017-11-29 01:22:01

@notjack working on protocols. It looks like this API is also a stack.


dedbox
2017-11-29 01:24:07

dedbox
2017-11-29 01:25:35

The codec layer is pretty messy.


dedbox
2017-11-29 01:26:32

I don’t think a driver-style API will work.


dedbox
2017-11-29 01:26:57

Not like it did with the Agent API.


dedbox
2017-11-29 01:27:37

encode : * -> * decode : * -> * These signatures are too generic to reason about usefully.


dedbox
2017-11-29 01:29:20

So instead, we can devise a “primitive” set of codecs and prescribe rules for making new ones. I’ll call this an axiomatic approach.


dedbox
2017-11-29 01:31:04

The roadmap suggests restructuring and serialization


dedbox
2017-11-29 01:31:26

That’s still pretty generic.


dedbox
2017-11-29 01:34:17

The restructuring side can be axiomatic as well


dedbox
2017-11-29 01:34:49

Same for serialization.


dedbox
2017-11-29 01:36:32

In some sense, serialization is more “universal” than restructuring


dedbox
2017-11-29 01:41:56

If net2 can serialize Racket data structures, we can model and analyze those behaviors.


dedbox
2017-11-29 01:42:43

Then future protocol implementers will get a practical foundation (the code) as well as a theoretical one (the model).


dedbox
2017-11-29 01:45:50

But I can’t find anything that general to say about restructuring.


dedbox
2017-11-29 01:51:20

I can say interesting protocol-specific things about restructuring.


dedbox
2017-11-29 01:52:49

Suppose I have a messenger that prints alists by joining keys and values with a fixed string.


dedbox
2017-11-29 01:54:34

Say I’m building an HTTP protocol that presents requests as http-request objects.


dedbox
2017-11-29 01:58:27

Then I can say the protocol restructures http-request objects as alists.


dedbox
2017-11-29 01:59:12

But that’s not generally useful.


dedbox
2017-11-29 01:59:48

I mean, restructuring http-request objects into alists is not generally useful.


dedbox
2017-11-29 02:00:15

It wouldn’t belong in a standard library.


dedbox
2017-11-29 02:02:08

Maybe if we included codecs for converting between Racket data structures, but that smells like scope creep.


dedbox
2017-11-29 02:02:55

Or, we could just catalog the collection of restructuring codecs used in whatever protocols net2 ships with.


dedbox
2017-11-29 03:15:32

So codecs must be composable. Must they also be invertible?


dedbox
2017-11-29 03:30:49

The theory is simpler if codecs are composable and invertible. That means a simpler API, stronger theoretical guarantees, and less bugs.


notjack
2017-11-29 04:11:09

@dedbox That API stack diagram looks great, that’s just precisely what I’ve been shooting for. Wonderful job :)


notjack
2017-11-29 04:11:23

and I’m thinking along the same lines with codecs


notjack
2017-11-29 04:11:49

composable and defined in a way that’s somehow “symmetric” seems ideal and makes things much simpler


notjack
2017-11-29 04:12:24

also, keep in mind this is for byte-level serialization protocols not parsing user-written source code, so error messages are less of a concern than things like a way to guarantee an upper bound on memory consumption


notjack
2017-11-29 04:13:23

I agree with you about not being 100% sure where structs and (de)serializers for http types should go


notjack
2017-11-29 04:17:18

I’m thinking maybe a net2/codec module that defines a whole pile of generic ways to extend and compose codecs? like, a generic way to do “message framing” where you turn a Codec A B value (meaning a codec with high-level format of type A and low-level (e.g. binary) format of type B) and a function telling you the size of values of type A into a Codec A (Frame B) value, where the Frame type prefixes each unit with size information. Or something like that. Basically, something that generalizes over how Ethernet frames, IP packets, TCP packets, and HTTP messages all have a size header that tells you how far to read for more input. That sort of thing would belong in net2/codec


notjack
2017-11-29 04:18:26

and then ideally, http codecs should require relatively little code to implement and just be glueing together various generic bits of net2/codec. That sort of stuff seems alright in a net2/http module