Difference between revisions of "Code"
| Line 4: | Line 4: | ||
There are two kinds of Code that Run supports: | There are two kinds of Code that Run supports: | ||
| − | |||
| − | |||
#'''Jig classes:''' Jig classes are classes that extend from Jig and behave like jigs. You already know these. You can use them to create jig objects as we've already seen, but you can also call methods on them to update their properties over time. Jig classes evolve according to same [https://run.network/docs/#how-it-works-ownership-rules Ownership Rules] as jig objects. | #'''Jig classes:''' Jig classes are classes that extend from Jig and behave like jigs. You already know these. You can use them to create jig objects as we've already seen, but you can also call methods on them to update their properties over time. Jig classes evolve according to same [https://run.network/docs/#how-it-works-ownership-rules Ownership Rules] as jig objects. | ||
| − | |||
#'''Sidekicks:''' Sidekicks are your helpers. They are your classes or functions that don't extend from <code>Jig</code> which you use more for supporting roles. You might use sidekicks to create a [https://run.network/docs/#advanced-usage-locks custom lock], to define a [https://run.network/docs/#advanced-usage-berries berry], to make a shared helper like [https://run.network/docs/#api-reference-extras-expect expect], or even to store your server code on-chain. When you call a method on a sidekick, nothing gets recorded to Bitcoin. But you can call sidekicks from inside jigs and even from your own app. There are no restrictions on what kinds of parameters can be passed into or returned from sidekicks. | #'''Sidekicks:''' Sidekicks are your helpers. They are your classes or functions that don't extend from <code>Jig</code> which you use more for supporting roles. You might use sidekicks to create a [https://run.network/docs/#advanced-usage-locks custom lock], to define a [https://run.network/docs/#advanced-usage-berries berry], to make a shared helper like [https://run.network/docs/#api-reference-extras-expect expect], or even to store your server code on-chain. When you call a method on a sidekick, nothing gets recorded to Bitcoin. But you can call sidekicks from inside jigs and even from your own app. There are no restrictions on what kinds of parameters can be passed into or returned from sidekicks. | ||
| + | Using jig classes and sidekicks, you have a powerful repertoire to build extensible apps. | ||
| − | + | Deploying<br>Loading<br>Linking<br>Extending<br>Syncing<br>Updating<br>Upgrading<br>Trusting<br> | |
Revision as of 21:12, 15 December 2022
With Run, you can own code, like classes and functions, just as easily as you can own objects. This may sound a little meta at first, but don't worry — you've been doing it all along! Every jig you created was linked to a jig class which you owned too. That jig class lived in its own output and had its own location.
When you own a piece of code, it means you have control over that behavior. For example, if you own a jig class, you get to decide what its jig instances are able to do. You can update or destroy that class and even call methods on it. Run calls classes and functions that people own Code with a capital C. Using Code, you can define new kinds of jigs, create reusable helper functions, share your server logic for auditability, discover algorithms from other apps, and much more.
There are two kinds of Code that Run supports:
- Jig classes: Jig classes are classes that extend from Jig and behave like jigs. You already know these. You can use them to create jig objects as we've already seen, but you can also call methods on them to update their properties over time. Jig classes evolve according to same Ownership Rules as jig objects.
- Sidekicks: Sidekicks are your helpers. They are your classes or functions that don't extend from
Jigwhich you use more for supporting roles. You might use sidekicks to create a custom lock, to define a berry, to make a shared helper like expect, or even to store your server code on-chain. When you call a method on a sidekick, nothing gets recorded to Bitcoin. But you can call sidekicks from inside jigs and even from your own app. There are no restrictions on what kinds of parameters can be passed into or returned from sidekicks.
Using jig classes and sidekicks, you have a powerful repertoire to build extensible apps.
Deploying
Loading
Linking
Extending
Syncing
Updating
Upgrading
Trusting