Petri net
is a very popular formalism to model distributed systems.
It is a directed bipartite graph whose nodes represent either transitions,
representing events in the modeled system,
or places,
representing the state of the system.
It has a formal syntax, a graphical notation and of course a well-defined semantics.
I’ll spare you the details in this post,
as there are countless scientific papers describing them.
But just so we are on the same page, here’s a quick and super informal description:
The places of a Petri net are marked with a given number of tokens,
describing the state of the system.
A transition is enabled when there enough tokens
in all its input places (i.e. places for which there’s an arc to the transition).
A enabled transition can be fired,
consuming the tokens from its input places and producing new tokens in its output places.
Continue reading
I love Swift!
It’s a great modern programming language,
with performances comparable to C/C++,
and a arguably intuitive syntax.
Just for a taste of the language,
here’s an example:
```swift
enum List: Sequence, ExpressibleByArrayLiteral {
indirect case node(element: Element, next: List)
case empty
Continue reading
An imperative programming languages
(e.g. C, Java, Python, …)
uses statements to change some state of the program.
In modern languages, these changes are often expressed in terms of
variable assignment.
Take the following program example, written in C:
int main() {
int x = 0;
x = 2;
return x;
}
When the function starts,
a new variable x
is created,
and is assigned to the value 0
.
Then, the following statement changes this assignment to make x
assigned to the value 2
instead.
In both instances, we use an assignment operator (in this case =
)
to assign the value on its right to the variable on its left.
Continue reading