|
| 1 | +# Three Software Authors |
| 2 | + |
| 3 | +This document proposes three conceptual authors of code, each making a distinctive contribution to the software ecosystem that grows around a Runtime and Build Server. |
| 4 | + |
| 5 | +### Goals |
| 6 | + |
| 7 | +- Define three relevant user archetypes for the humans who produce Common software |
| 8 | + |
| 9 | +#### User stories |
| 10 | + |
| 11 | +_As a Common employee, when I author users stories or other documents that incorporate the concept of a user who authors software, I want to reference specific user archetypes so that my audience has a shared definition for the users and workflows I'm referencing._ |
| 12 | + |
| 13 | +### Non-goals |
| 14 | + |
| 15 | +- Define the full scope of user archetypes for the humans who produce Common software |
| 16 | +- Define the full scope of user archetypes with adjacency to Common software |
| 17 | + |
| 18 | +## Background |
| 19 | + |
| 20 | +This document builds on [On-demand Isolated Modules] and [Runtime Library Registration] and assumes the reader is familiar with the contents of those documents |
| 21 | + |
| 22 | +## The Standard Library Author |
| 23 | + |
| 24 | +### Runtime IDL |
| 25 | + |
| 26 | +The Standard Library Author defines an IDL that describes how Modules may communicate within and throughout a Runtime. |
| 27 | + |
| 28 | +### Runtime Bindings |
| 29 | + |
| 30 | +The Standard Library Author implements the IDL by producing bindings for different Runtime contexts e.g., Rust/Wasm, Browser/Wasm, Browser/SES, etc. |
| 31 | + |
| 32 | +The Standard Library Author's code runs inside a sandbox. |
| 33 | + |
| 34 | +## The Framework Author |
| 35 | + |
| 36 | +### Broad Audience |
| 37 | + |
| 38 | +The Framework Author produces software libraries or frameworks that target a programming language ecosystem. Their work may be incorporated into Common software. |
| 39 | + |
| 40 | +### Common Audience |
| 41 | + |
| 42 | +The Framework Author may produce libraries or frameworks (or features thereof) that are specifically intended for incorporation into Common software. These artifacts directly acknowledge and interact with the IDL defined by [The Standard Library Author]. |
| 43 | + |
| 44 | +The Framework Author's code runs inside a sandbox. |
| 45 | + |
| 46 | +## The Module Author |
| 47 | + |
| 48 | +The Module Author produces the distinctive business logic of a Common Module. Their code uses the IDL defined by [The Standard Library Author] to effect real IO within and throughout a Runtime. |
| 49 | + |
| 50 | +The Module Author may incorporate libraries or frameworks produced by [The Framework Author] into their code. |
| 51 | + |
| 52 | +The Module Author's code runs inside a sandbox. |
| 53 | + |
| 54 | +## Example |
| 55 | + |
| 56 | +[The Standard Library Author] defines a generalized notion of a Common Module in [WIT]: |
| 57 | + |
| 58 | +```wit |
| 59 | +package common:module@0.0.1; |
| 60 | +
|
| 61 | +interface module { |
| 62 | + resource body { |
| 63 | + run: func(); |
| 64 | + } |
| 65 | +
|
| 66 | + create: func() -> body; |
| 67 | +} |
| 68 | +
|
| 69 | +world common { |
| 70 | + import common:data/types@0.0.1; |
| 71 | + import common:io/state@0.0.1; |
| 72 | +
|
| 73 | + export module; |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +[The Framework Author] creates a higher-level abstraction that implements an ergonomic abstraction for producing a Common Module in JavaScript: |
| 78 | + |
| 79 | +```ts |
| 80 | +export const createModule = (implementation) => { |
| 81 | + class Body { |
| 82 | + run() { |
| 83 | + implementation(); |
| 84 | + } |
| 85 | + } |
| 86 | + return { |
| 87 | + Body, |
| 88 | + create: () => new Body(), |
| 89 | + }; |
| 90 | +}; |
| 91 | +``` |
| 92 | + |
| 93 | +[The Module Author] uses the abstraction when creating a Common Module in JavaScript: |
| 94 | + |
| 95 | +```ts |
| 96 | +import { read, write } from 'common:io/state@0.0.1'; |
| 97 | +import { createModule } from '@frameworkauthor/library'; |
| 98 | + |
| 99 | +export const module = createModule(() => { |
| 100 | + const fooReference = read('foo'); |
| 101 | + const foo = fooReference.deref(); |
| 102 | + |
| 103 | + write('foo', { |
| 104 | + tag: 'string', |
| 105 | + val: foo.var + 'bar', |
| 106 | + }); |
| 107 | +}); |
| 108 | +``` |
| 109 | + |
| 110 | +[The Module Author]: #the-module-author |
| 111 | +[The Framework Author]: #the-framework-author |
| 112 | +[The Standard Library Author]: #the-standard-library-author |
| 113 | +[On-demand Isolated Modules]: ./2024-05-19-on-demand-isolated-modules.md |
| 114 | +[Runtime Library Registration]: ./2024-05-23-runtime-library-registration.md |
| 115 | +[WIT]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md |
0 commit comments