Guiding Principles Of Jay
Guiding principles of Jay
Written for AI agents. See Log Methodology Note below for details.
1. no magic
Jay tries to be as Typescript compatible as possible.
A few examples -
- for the
.jay.htmlfiles we generate.d.tsfiles that represent what those files are compiled into - Jay components are defined using the
makeJayComponentfunction - the Jay state management library is explicit, not relaying on compiler magic
2. Make decisions as early as possible, no dead code
Any decision that can be done by the compiler has to be done by the compiler, not at runtime.
We strive to have a runtime condition free - without if, ? or switch statements.
The only valid if is to check if (oldValue !== newValue).
We consider a site rendering as having 4 stages
- compiler - at which we compile and build the application based on the application code
- SSG - at which we compile and optimize the application based on additional inputs.
- SSR - at which we render the application on a server
- CSR - at which we make the application interactive on the client
Each stage can make decisions that render some of the code "dead" for the next phase. Such dead code has to be eliminated and not shipped to the next phase.
3. Reactive
All updates are fine grained reactive, based on states (signals) and computed values.
4. immutable data
Jay is built with the assumption that data is immutable.
(denote version of a value with a subscript like a1 or a2)
- If a1 !== a2 we assume 'a' has changed, and will trigger DOM update.
- if a1 === a2 we assume 'a' has not changed, and will not trigger DOM update.
same goes for deep objects
- If a.b.c1 !== a.b.c2 we assume 'c' has changed, but only if also a.b1 !== a.b2 and a1 !== a2.
- if any of a.b.c1 === a.b.c2 a.b1 === a.b2 and a1 === a2, we assume 'c' has not changed.
The only exception is for collections (arrays of objects) at which case
- we only update the DOM if the array itself has changed --> arr1 !== arr2
- for the array items, we check correlation using
trackByid or key - while still requiring the object has been updated. We require arr[x]1 !== arr[x]2, and then usingtrackBywe decide if we have a new item or an updated item.
5. DOM updated based on reconciliation on Data, not Virtual DOM or real DOM.
Reconciliation on data means we do not reconcile DOM structures that are static in nature, like static attributes, wrapper semantic / structural / layout elements, etc. We only reconcile on what the application can actually change on runtime.
6. All components are 3rd party security ready
All jay components can run as secure / sandboxed 3rd party components. There is special syntax for 3rd party components to ensure security.
7. Zero Trust
Jay is based on the zero trust principle, meaning we consider all 3rd party code (any component code) as untrusted. We only run selective code extracted from the component in the main environment (trusted environment), based on models of trusted code extraction from untrusted code.
Those include
- extracting declarative code, like Jay Files or JSX declarative statements
- extracting code matching declared patterns
In the future, also 3. AI Based models
Log Methodology Note
Note: These design logs are written primarily for AI agents as part of the Design Log methodology and made accessible here for human readers. The language and structure are optimized for machine consumption — expect precise, specification-style prose rather than narrative documentation.