Azure / opendigitaltwins-dtdl

Digital Twins Definition Language
Creative Commons Attribution 4.0 International
481 stars 164 forks source link

Why "integer" instead of "int" in the primitive schemas? #173

Open jbkoh opened 1 year ago

jbkoh commented 1 year ago

Hi there,

In my understanding of the context file, it seems DTDL adopts XSD vocabularies. However, the definition of "integer" is mismatched between the DTDL's documentation vs XSD's definition.

DTDL v3:

XSD

like the hierarchy below image

Basically, xsd:integer is unbounded and xsd:int is the 32bits integer as in your definition

I know I'm a bit pedantic, but wonder if there can be a chance to deprecate integer and start using int for long term alignment with one of the common standards.

jrdouceur commented 1 year ago

I don't know the history or the specific considerations that went into DTDL's choices for primitive schema terms, but I can make a few observations. First, DTDL prefers full words such as "integer" and "boolean" over truncations like "int" and "bool", but this is a lexical preference that does not drive the definition of the terms. Second, although the DTDL schemas make reference to XSD for some definitional aspects, they also refer directly to other standards including IEEE 754, ISO 8601, and IETF RFC 3339. Third, "integer" is not the only schema for which DTDL and XSD are not in alignment:

Some current and upcoming applications of DTDL relate to other standards, such as AVRO and Protobuf. I expect that if there are any future changes to DTDL schema definitions, these will be driven mainly by interop issues rather than by lexical alignment with XSD or the nomenclature of any other standard.

koppor commented 12 months ago

I miss the relation to related work.

Especially, currently, I miss the physical unit. A temperature of 40.0°C is different from 40.0°F - even though the double value is the same...


SenML encodes temparature like that:

[
  {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","v":23.1}
]

Using QUDT, a measurement would be encoded as follows in JSON:

{
  "value": 40,
  "unit": "http://qudt.org/vocab/unit/Celsius",
  "quantityKind": "http://qudt.org/vocab/quantitykind/Temperature",
  "description": "Measurement of temperature"
}

Reads nice.


Historical note. A decade ago, "everyone" talked about IoT. See for instance https://www.postscapes.com/internet-of-things-protocols/. Most of the lings are dead now... Nevertheless, I think, should be no re-invention of the wheel.

koppor commented 12 months ago

Another thing to consider is "Eclipse Vorto", which is a language for digital twins - governede by the Eclipse Foundation, where Microsoft is also involved: https://eclipse.dev/vorto/