One of the novelties of Pony compared to most programming languages is the concept of object capabilities. If you come from a background unfamiliar with them, you may be tempted to believe that they only add unnecessary abstraction to your code. However, they are a powerful tool that offer several new possibilities to improve and secure your programs. This section will present you some additional concepts that can help you to develop awesome Pony code.
Problem As shown in the tutorial page about object capabilities, we can limit the actions of other objects or actors with object capabilities. This is used in the standard library of Pony for network connections and file access, for example. But it can also be used for other systems created in Pony.
For example, let’s say we want to implement a capability-restricted service, that returns one unique number every time it is called.