Replies: 1 comment 3 replies
-
|
I agree with the general paradigms 1–4. As pointed out by you, however, the limitations of JavaScript and TypeScript might force us to contradict these paradigms. I am wondering if it wouldn't be justifiable to require knowledge about the basic concepts of the DATEX protocol from the developer and reflect them on the JS side. Although not on the same OSI layer, DATEX could be compared to HTTP. In JavaScript, HTTP requires just as much preliminary knowledge from developers as DATEX would (e.g. METHODS, headers, even CORS). HTTP is far less well integrated into JavaScript than DATEX would be. I therefore think that we have a certain "budget of deviation" from paradigms 1 and 3, less so from 2 and 4. This tolerance should probably be limited slightly above what current web development frameworks employ (except for transpiler-heavy frameworks). For now, I would like to only comment on a specific discussion point:
We must indeed not violate paradigm 4 while still ensuring that data doesn't get inadvertently sent with inappropriate permissions. Without thinking about technical implications, I would indeed like to see a restrictive behavior as a default, especially if we are also aiming at more security-critical applications. However, I am not sure if you would actually have to clone the object for this to work. Would it be possible to have the Also, I am not sure whether paradigms 1 and 2 tend to clash. Looking at your "Auto-cloning objects" example, the code is very clean and does not impose any DATEX-specific code on the developer. However, this exported function does not behave at all like one would expect TypeScript imports to work. Even worse, it does perform this "magic" behind the scenes. One possible alternative: @network function getUser(id: string): User {
/* @network: this function can be called over the network and will return read-only values */
return users.get(id); // <- read-only derived pointer
}I am sure that we can agree on the rule that "explicit is better than implicit" while at the same time we aim to minimize code obstructions. I am unsure what to prefer when. Note: When I'm mentioning that I am unsure about an approach, this does not mean that I am against it. It just means that I am seeking for more perspectives. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is the starting point of a (probably very long) discussion about how to integrate DATEX in a JS library with optimal developer experience while still guaranteeing safety (mostly regarding data privacy + read/write permissions, but also thread safety).
Some general paradigms/goals that we should always keep in mind imo:
Before discussing on any further points, we should make sure that we can agree on the points above, or modify them until everyone is happy.
Now, let's first mention some shortcomings that make it hard to work safely with vanilla JS behavior in a DATEX application:
Now, some other concepts that I would not implement in the DATEX JS library due to violation of our paradigms:
Regardless of how we do this, I would also try to avoid to introduce some "magic" behavior implied from the TS return type (like only returning a reference when defining the return type as
Ref<User>. This violates paradigm 4 and can get very confusing for developers (note: we currently have a similar concept with JUSIX, but only for reactive inputs in JSX contexts, which is a different scenario imo - but we also should think about that in the future))@jonasstrehle @asbng @janiejestemja @TeeB3utel @Silauras @lennartstoelting @kha1dx
Feel free to comment if you have any remarks, suggestions etc.
Beta Was this translation helpful? Give feedback.
All reactions