Regarding null
#1348
Replies: 4 comments
-
Collection of comments prior to opening this discussion: From @mattdailis regarding #1347:
From @cartermak:
|
Beta Was this translation helpful? Give feedback.
-
There are a couple of avenues of inquiry that I think are relevant here: 1) what kinds of static guarantees do we wish to provide about the structure of data? and 2) what do we do about clients that use the value schema without the presence of a value? What should they do about the nullability of all values? 1. Static vs dynamic errorsRegarding (1) I'm referring to how much we want to try to leverage the typescript type system to ensure the type-safety of command expansion logic. Our stance could be that unit testing is sufficient (that's the usual approach taken by dynamic language proponents), but if we could rely on the type system to prove certain safety properties to us, that would reduce the burden on testing. (I'd love to hear from you whether you're finding the fact that expansions are defined in typescript to be valuable, or if you see it as getting in the way of just letting you write javascript) Now: there are limitations to what type systems can express, and there are tradeoffs to ease-of-use if your type system is too restrictive. The question under consideration is whether it would be valuable to leverage typescript's
One more consideration around the possible benefits of static type checking has to do with mission model updates. If a previously non-nullable type becomes nullable as a result of a new mission version, it may be desirable to catch that during expansion set creation. 2. Generic data consumersFor avenue (2), I want to consider that the stance we take on nullability of values extends beyond command expansion, to things like the UI input form, or timeline renderer. I agree on some level with the end-to-end argument. There is the data producer, and the data consumer - the two need to agree on the shape of the data. When these are one-to-one, and owned by the same person, that is fairly straightforward. There are cases where a data consumer and data producer may be written without knowledge of each other - the language they use to communicate with each other is "value schema". The most fleshed out example of this is the UI parameter-editing form. I don't believe there is currently a way to enter Other cases could be gathering statistics on a numeric profile - what should the "average" be for a profile declared as type integer that contains
Unfortunately there is no cross-language consistency when it comes to what
Aerie's general philosophy around null so far has been to try to avoid it, where possible. Now, I acknowledge that it is useful in certain scenarios, but I think those are the minority of scenarios, and most of the time it's much more valuable to be able to assume that a value is not null. I want to emphasize that I write all this not because I think you don't know these things - I'm just trying to think through the design space together. Thanks for taking the time to think through this with me 👍 |
Beta Was this translation helpful? Give feedback.
-
Regarding 1, definitely see value in (c) as it provides a mechanism for ensuring our interfaces rather than relying on documentation and developer intent. Part of the beauty of our codegen is we can metaprogram out a bunch of this, so we have a lot of power in closing these interface gaps. Regarding 2, we are talking about what kind of semantics to we want to use and support. Like you mentioned, To elaborate, we can have keys that are non-existent in JSON that is different from a key that is existent and My anecdotal experience has taught me that there is value to being able to differentiate from "this thing doesn't exist, or doesn't exist yet" and "this thing exists and is explicitly naught", especially when it comes to UIs and APIs. My position is that we should exercise the mechanisms at our disposal to the maximum practical ability. Reduction in cognitive overhead for users and developers by exercising these tools has a largely immeasurable value, but I generally believe it to be significant in long term maintainability. Our type systems across the system are generally expressive enough to improve on our current behavior if we take the time and care to use them well. |
Beta Was this translation helpful? Give feedback.
-
We had a chat with @dandelany and @goetzrrGit , and we all agreed on the following two things:
@dandelany also commented that it could be valuable to go further and differentiate between I started jotting down notes from our discussions, but I realized that I think we're solving two separate problems:
The latter is the driving use case, but the former also deserves consideration. It may be possible, but not necessary, for one solution to address both problems. Notes in collapsible for now, until I have some more time to flesh them out: NotesWe explored some ideas for how exactly it could be represented in the value schema. (i) focuses on encoding null, while (ii) focuses on removing the need for
An advantage of Option (i) is that the value schema concise and it directly represents @Twisol had a few comments as well (paraphrasing):
@Twisol suggested a hybrid approach to make (ii) more concise, by treating
An advantage of (iii) is that it allows the "empty" case to simply by |
Beta Was this translation helpful? Give feedback.
-
I'm opening up this discussion about how
null
values are/should be treated in Aerie's ValueSchemas and SerializedValues.This discussion was prompted by #1346 , where the sequencing server would crash when an processing an optional struct value such as
{ "present": false, "value": null }
, with value schema (in typescript type shorthand):{ "present": boolean, "value": { "foo": "bar } }
.This discussion shouldn't be a blocker for #1347 ; avoiding the sequencing server crash is definitely desirable, and urgent.
The purpose of this discussion is to explore the use cases and pros/cons of different ways of handling null, and to establish what the status quo is, as well as what a desirable future could be.
Beta Was this translation helpful? Give feedback.
All reactions