Post 9wLiw1ZfvhSprhR0Ge by c_cube@octodon.social
(DIR) More posts by c_cube@octodon.social
(DIR) Post #9wLFRBOUTPLsfk90dM by sir@cmpwn.com
2020-06-22T12:55:18Z
0 likes, 6 repeats
Introducing the BARE message encodinghttps://drewdevault.com/2020/06/21/BARE-message-encoding.html
(DIR) Post #9wLOHLtRTvzrvW0cJk by c_cube@octodon.social
2020-06-22T14:33:58Z
0 likes, 0 repeats
@sir looks like untagged unions are not playing well with the first rust implementation.
(DIR) Post #9wLOWdIh2nt0G46eeW by sir@cmpwn.com
2020-06-22T14:37:09Z
0 likes, 0 repeats
@c_cube the unions are tagged, not untagged
(DIR) Post #9wLQrbxZQL625cMDDM by c_cube@octodon.social
2020-06-22T15:03:00Z
0 likes, 0 repeats
@sir They're tagged in the wire format, but not in the IDL. Tagged unions would typically take an enum as a parameter and map each case to a message.See for example zig: https://ziglang.org/documentation/master/#Tagged-union
(DIR) Post #9wLRUduk5ikvRde7mq by sir@cmpwn.com
2020-06-22T15:10:24Z
0 likes, 0 repeats
@c_cube they're tagged in both. They don't have to have a separate enum to qualify
(DIR) Post #9wLRpiqgwJ70pYnqQi by c_cube@octodon.social
2020-06-22T15:14:00Z
0 likes, 0 repeats
@sir I don't see a tag in `(a|b|c)`. I see an anonymous union where the order of declarations matters.It's the same thing as removing `struct` (with named fields)` and replacing it with tuple syntax `(string, string, i32, bool, i64)` without names. Still technically a struct, but the code generated from that gives you accessors by position, not name, of fields.
(DIR) Post #9wLWD5g8cmn674GUNM by philipwhite@functional.cafe
2020-06-22T15:29:02Z
0 likes, 0 repeats
@c_cube @sir I think Drew has it right here.By anonymous union, I think you mean that each item in the union is not given a name. This does not mean that the union is untagged. The difference between a tagged an untagged union is that tagged unions carry which item of the union they are, but untagged unions do not. The "tag" refers" to the data which determines the type, and not to the name given to the alternative.In Zig, for example, a plain `union` is untagged, but if you simply add `union(enum)`, it becomes tagged. In both of those cases, each alternative is given a name.
(DIR) Post #9wLWD688wfBzVvMr1k by c_cube@octodon.social
2020-06-22T15:45:00Z
0 likes, 0 repeats
@philipwhite @sir note that in `union(enum)` in Zig, each case of the union has the shape `name: type`, so it has an explicit name for the tag, which is still an enum and not an integer. So I agree that technically, BARE has tagged unions, but they should be tagged with enums, not integers. Again, same as structs having names, not just field numbers.
(DIR) Post #9wLWD6TleGUQazU7jU by sir@cmpwn.com
2020-06-22T16:02:59Z
0 likes, 0 repeats
@c_cube @philipwhite I don't see any reason to tag them with enums. Different tech exists in different circumstances and arrive at different solutions. You were wrong, that's all, and that's fine.
(DIR) Post #9wLWiK5b61Udmf49qK by c_cube@octodon.social
2020-06-22T16:08:40Z
0 likes, 0 repeats
@sir @philipwhite Indeed, they're tagged. They also seem pretty useless to me in that form, since you asked for feedback.
(DIR) Post #9wLX6NNuUn4GxE6KtE by philipwhite@functional.cafe
2020-06-22T16:12:46Z
0 likes, 0 repeats
@sir @c_cube This whole discussion belongs in your public inbox probably, but since it's gone this far, I'll add another related thought.It would seem to me that struct field names have as little use as enum tag names (obviously, I'm on the opposite side of @c_cube here) since all the names are stripped away anyway. We can get by with just tuples and unions.
(DIR) Post #9wLXEH3zsiHxfMYLse by sir@cmpwn.com
2020-06-22T16:13:33Z
0 likes, 0 repeats
@philipwhite @c_cube the field names and enum names are used in the schema DSL, from which code generators can utilize them to assign field names to language-native representations
(DIR) Post #9wLXKTSkh6FxrL5XmK by sir@cmpwn.com
2020-06-22T16:14:18Z
0 likes, 0 repeats
@philipwhite @c_cube here is the generated Go code for the example schema:https://git.sr.ht/~sircmpwn/go-bare/tree/master/example/schema.goAnd its usage:https://git.sr.ht/~sircmpwn/go-bare/tree/master/example/main.go
(DIR) Post #9wLXRuuh21Wb1Uhrpg by sir@cmpwn.com
2020-06-22T16:14:49Z
0 likes, 0 repeats
@c_cube @philipwhite I assure you they're useful. You just haven't encountered tagged unions outside of the context with which you are familiar.
(DIR) Post #9wLXcxmugVJh7jKpJA by philipwhite@functional.cafe
2020-06-22T16:18:50Z
0 likes, 0 repeats
@sir @c_cube Oh! Duh. I wasn't even considering the possibility of code generation. I've been just assuming that language has enough metaprogramming to allow encoding the schema itself, though not every language has that.
(DIR) Post #9wLXlRVO51pzbhBG1A by c_cube@octodon.social
2020-06-22T16:19:49Z
0 likes, 0 repeats
@sir @philipwhite I think you might not have encountered tagged unions or sum types outside the context with which you are familiar either.What does codegen for encoding/decoding such a union look like?`type person = Zero(user) | One(admin)`? I'd rather have names for each case.
(DIR) Post #9wLXyWmRmKMjjSOphg by lucky@pleroma.mouse.services
2020-06-22T16:23:58.439012Z
0 likes, 0 repeats
@sir Reminds me of https://github.com/real-logic/simple-binary-encoding
(DIR) Post #9wLYG6FV9zfgevMugK by sir@cmpwn.com
2020-06-22T16:26:02Z
0 likes, 0 repeats
@c_cube @philipwhite the names of the tagged types are the names for each case
(DIR) Post #9wLYfCOVRvQExRY4kC by c_cube@octodon.social
2020-06-22T16:29:43Z
0 likes, 0 repeats
@sir @philipwhite what are the names for `(i16 | i16 | i16 | i16)`?
(DIR) Post #9wLYsZulJSnjfY12cC by sir@cmpwn.com
2020-06-22T16:33:03Z
0 likes, 0 repeats
@c_cube @philipwhite tagged unions are a set, you are not allowed to do this
(DIR) Post #9wLZhvTut3CjKJwYoy by c_cube@octodon.social
2020-06-22T16:42:05Z
0 likes, 0 repeats
@sir @philipwhite is there a `void` type that takes 0 bytes on the wire?Usage is as follows:```type Tag1 voidtype Tag2 voidtype Tag3 SomeOtherStufftype Foo (Tag1 | Tag2 | Tag3)```this is useful if some cases of the union don't have any interesting payload.
(DIR) Post #9wLZp7s7DbZBmWhBSa by sir@cmpwn.com
2020-06-22T16:42:49Z
0 likes, 0 repeats
@c_cube @philipwhite no, you should use enums for this purpose
(DIR) Post #9wLZwzCVLEF7CmyqLw by sir@cmpwn.com
2020-06-22T16:43:06Z
0 likes, 0 repeats
@c_cube @philipwhite I understand the enum/union system you're familiar with and deliberately did not design it this way
(DIR) Post #9wLddN29Q9aL9B2W7E by c_cube@octodon.social
2020-06-22T17:26:04Z
0 likes, 0 repeats
@sir @philipwhite that's sad, but well, everyone has their own taste I guess. Have you ever written on why you hate sum types so much? I can understand not liking FP, but I do struggle with the idea of not liking sum types.
(DIR) Post #9wLdxgHxXbJ2en7Q36 by sir@cmpwn.com
2020-06-22T17:30:03Z
0 likes, 0 repeats
@c_cube @philipwhite if I hated sum types I would not have added them to BARE lol
(DIR) Post #9wLeBBUepjnJCYUsXw by philipwhite@functional.cafe
2020-06-22T17:32:28Z
0 likes, 0 repeats
@sir @c_cube Well, you haven't quit computers yet, so that type of argument doesn't hold all the time.
(DIR) Post #9wLeIvgzSuroVnxVPU by c_cube@octodon.social
2020-06-22T17:33:23Z
0 likes, 0 repeats
@sir @philipwhite you added unions.What does `type foo = A | B | C of string` look like in BARE, if you can't mix cases with and without arguments?
(DIR) Post #9wLeTsfj2GIyKVaaCu by sir@cmpwn.com
2020-06-22T17:35:54Z
0 likes, 0 repeats
@c_cube @philipwhite they're TAGGED UNIONS jesus dude
(DIR) Post #9wLeZvCyWD7rvw1PxQ by sir@cmpwn.com
2020-06-22T17:36:31Z
0 likes, 0 repeats
@c_cube @philipwhite I take it back, I do hate sum types, because they teach people to be thick as hell when understanding other forms of tagged unions
(DIR) Post #9wLegSRrqSgMlP6Wtk by sir@cmpwn.com
2020-06-22T17:37:07Z
0 likes, 0 repeats
@c_cube @philipwhite you don't need a zero-length type in order to have tagged unions for fuck's sake
(DIR) Post #9wLf5CLAs4nw2rlqRE by c_cube@octodon.social
2020-06-22T17:42:33Z
0 likes, 0 repeats
@sir @philipwhite Well I'm interested in seeing how else you represent the type snippet from below.
(DIR) Post #9wLfaPTa5EGvlHaNge by sir@cmpwn.com
2020-06-22T17:48:17Z
0 likes, 0 repeats
@c_cube @philipwhite you don't. We don't have zero sized types.
(DIR) Post #9wLfkfbMz2P0fc7a7s by c_cube@octodon.social
2020-06-22T17:49:50Z
0 likes, 0 repeats
@sir @philipwhite and that's why you had to cheat, Go-style, and bake in the option type because this "universal" language can't represent it.
(DIR) Post #9wLgAler5aZsyyCDC4 by sir@cmpwn.com
2020-06-22T17:54:50Z
0 likes, 0 repeats
@c_cube @philipwhite oh bugger off already. No, it's not a perfect representation your functional paradise's ivory tower type system. Too fucking bad. It was never meant to be.
(DIR) Post #9wLgQ11uDfWD07FSoy by nipos@social.avareborn.de
2020-06-22T17:58:34Z
0 likes, 0 repeats
@sir That looks very interesting 👍 Maybe I'll replace JSON with it some day but then I'll need a implementation in Javascript and PHP.
(DIR) Post #9wLgwmbEtJZBnqOrMu by c_cube@octodon.social
2020-06-22T18:03:19Z
0 likes, 0 repeats
@sir @philipwhite I suppose Pascal, Ada, Nim, Zig, Rust, and Kotlin are all "ivory tower type system" and all die-hard functional languages.My only horse in this race is that BARE looks quite nice, except for this, and that means that generated code will never be nice in any language I like. Call me "ivory tower" if you like, although I don't see what called for that. Sum types, or tagged unions (à la zig/pascal/ada, etc.), or whatever you call them, are useful in the real world.
(DIR) Post #9wLh5Wy0Nnp9vPDh6O by sir@cmpwn.com
2020-06-22T18:05:14Z
0 likes, 0 repeats
@c_cube @philipwhite it fucking has tagged unions you insufferable moron
(DIR) Post #9wLhDVNcAPprJt07bU by c_cube@octodon.social
2020-06-22T18:06:24Z
0 likes, 0 repeats
@sir @philipwhite it either has unions of structures, all of which have non-zero size, or enums without arguments. It doesn't have the mix of both that is what all these languages feature.
(DIR) Post #9wLhPZT8n0hjTdL648 by c_cube@octodon.social
2020-06-22T18:07:40Z
0 likes, 0 repeats
@sir @philipwhite a simple example is `type option_i16 = (void | i16)`. It's so obvious that you baked that one in, but you can't deny this is useful, surely?
(DIR) Post #9wLhPat3W91nsITJ68 by sir@cmpwn.com
2020-06-22T18:08:38Z
0 likes, 0 repeats
@c_cube @philipwhite I reckon that ONE CASE is useful, but not as a generic type that you can reapply elsewhere. Why don't we just make the language fucking haskell and the encoding the raw memory dumps of its types
(DIR) Post #9wLhfoNz63vCNFfhKq by sir@cmpwn.com
2020-06-22T18:11:43Z
0 likes, 0 repeats
@c_cube @philipwhite consider the following: you're miffed because my tagged unions don't map perfectly into your language's concept of tagged unions for lack of zero-bit types (and as a matter of fact, they do fit, just not exactly the way you want)However, consider that zero-bit types don't exist in many programming languages. So the same hacks or worse would have to be applied to languages without them, or maybe even make BARE messages unrepresentable in them! Every language has types >0 bits, not every language has zero-bit types.
(DIR) Post #9wLhoixWduL89KXsMy by sir@cmpwn.com
2020-06-22T18:13:23Z
0 likes, 0 repeats
@c_cube @philipwhite and for the love of god, get it into your head that we're talking about zero-bit types here - NOT tagged unions, NOT sum types.
(DIR) Post #9wLhvrCiO17PkR3FPU by c_cube@octodon.social
2020-06-22T18:14:03Z
0 likes, 0 repeats
@sir @philipwhite why don't you add `void` and remove optional, it'll simplify the whole thing.(btw I don't even like haskell, well tried)
(DIR) Post #9wLi322qTkdROgr9JA by sir@cmpwn.com
2020-06-22T18:15:37Z
0 likes, 0 repeats
@c_cube @philipwhite it would not simplify it, it would just make it look the way you want it to and detach the schema from the reality of the encoded messages. "Detached from reality" is a pretty good summarization of functional programming ideals in general, actually
(DIR) Post #9wLifn5m0TnWJdhuzY by c_cube@octodon.social
2020-06-22T18:22:32Z
0 likes, 0 repeats
@sir @philipwhite It's about as detached from the reality of the encoded message as your current `optional` is. I agree zero sized types are not necessary, because I want one-byte things, not zero bytes. There's the union tag already, I just don't want to waste another one with a dummy u8 or whatever just because it's all-items-have-an-arguments-or-none-have (aka enums).And please stop ad hominem at your strawman idea of "functional programming". It runs on computers, just like Go and C.
(DIR) Post #9wLinrcL48wEfQmzAW by epi@ihatebeinga.live
2020-06-22T18:16:02.112695Z
0 likes, 0 repeats
@c_cube @sir @philipwhite can't you represent void as [0]data or data<0>?
(DIR) Post #9wLinro2MeIPFiGKP2 by sir@cmpwn.com
2020-06-22T18:23:56Z
0 likes, 0 repeats
@epi @philipwhite @c_cube because zero-length types are not permitted
(DIR) Post #9wLiw1ZfvhSprhR0Ge by c_cube@octodon.social
2020-06-22T18:23:49Z
0 likes, 0 repeats
@epi @sir @philipwhite or empty struct, I suppose, but I'm sure the spec will be fixed to forbid that.
(DIR) Post #9wLiw1sSnqUcnyE0YK by sir@cmpwn.com
2020-06-22T18:24:27Z
0 likes, 0 repeats
@c_cube @epi @philipwhite the spec already prohibits empty strucks, fuck's sake
(DIR) Post #9wLv8V0bWBl44xkGES by Ark@linuxrocks.online
2020-06-22T20:41:13Z
0 likes, 0 repeats
@sir is it me or is the publicKey optional's type not specified in the example schema ? I assume it's supposed to be optional<PublicKey> ?
(DIR) Post #9wLvHzRtiAyB5t2MPQ by sir@cmpwn.com
2020-06-22T20:44:14Z
0 likes, 0 repeats
@Ark error of translation to HTML, it's being interpreted as a tag. I'll fix it, thanks
(DIR) Post #9wLxdJbKBK5vaGk70K by Ark@linuxrocks.online
2020-06-22T21:10:16Z
0 likes, 0 repeats
@sir ah, ok. No problem.
(DIR) Post #9wi13mM53zRzPrfPOa by deavmi@mstdn.io
2020-07-03T12:33:00Z
0 likes, 0 repeats
@sir I finally got to reading what #Protobuff was. That was cool.Now for BARE!