Hacker Newsnew | past | comments | ask | show | jobs | submit | bocahtie's commentslogin

When the deserializing half of the protobuf definitions encounter an unknown value, it gets deserialized as the zero value. When that client updates, it will then be able to deserialize the new value appropriately (in this case, "Mint"). The advice on that page also specifies to not make the value semantically meaningful, which I take to mean to never set it to that value explicitly.


> it gets deserialized as the zero value

It’s more complicated:

https://protobuf.dev/programming-guides/enum/

>> What happens when a program parses binary data that contains field 1 with the value 2?

>- Open enums will parse the value 2 and store it directly in the field. Accessor will report the field as being set and will return something that represents 2.

>- Closed enums will parse the value 2 and store it in the message’s unknown field set. Accessors will report the field as being unset and will return the enum’s default value.


Ugh. I hate how we (Google) launched proto editions.

It used to be that we broadly had two sets of semantics (modulo additional customizations): proto2 and proto3. Proto editions was supposed to unify the two versions, but instead now we have the option to mix and match all of the quirks of each of the versions.

And, to make matters worse, you also have language-dependent implementations that don't conform to the spec (in fact, very few implementations are conformant). C++ and Java treat everything imported by a proto2 file as closed; C#, Golang, and JS treat everything as open.

I don't see a path forward for removing these custom deprecated field features, or else we'd have already begun that effort during the initial adoption of editions.


> The advice on that page also specifies to not make the value semantically meaningful, which I take to mean to never set it to that value explicitly.

I've taken to coding my C enums with the first value being "Invalid", indicating it is never intended to be created. If one is encountered, it's a bug.


I'm always reminded of Gary Bernhardt's "the birth and death of javascript" when wasm gets discussed. While it's a bit tongue-in-cheek, I think it really drives home that it's really just another layer of abstraction that may or may not be useful for a given problem, and might not be the silver bullet that anyone is looking for. I recon that whether or not wasm will take over everything will mostly be about trade offs between it and the other solutions.


That is what I was thinking of too! From 2014: https://www.destroyallsoftware.com/talks/the-birth-and-death....


Yes! I was trying to search for this but I couldn't remember the name.


This for sure, eg it will never be commonplace to run posgres compiled to wasm.

Most instances of "X will eat the world" and "X will be used anywhere" will be false even for very successful technologies


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: