Hi, as I’ve mentioned in other topics, for similar reasons why people have written their implementations of HTM, I’ve started my own, however, with a couple of constraints:
- concurrency should be “easy”, which brings me to the Actor Model and Pony
- I have limited time, so progress will be slow, and at first, I’ll try to reimplement an existing library with sufficient tests: the Go implementation https://github.com/htm-community/htm/
Here’s the repo: https://github.com/d-led/htm.pony
Where it takes off from there, we’ll see. Anyone willing to learn Pony, play around or contribute are welcome.
The issues and the readme reflect the current state of the implementation. There are no actors yet, as as of the time of writing I’ve just passed the scalar encoder. However, as soon as there’s some flow of data to multiple objects (SP?), actors can step in. It’s possible to start with classes and just embed them in actors to run the classes concurrently. The language takes care of the safety.
In the Actor Model each concurrent activity can be modeled as an actor, which will potentially be run in parallel to other actors. Actors are lightweight, so millions of actors on one machine are no problem. Actors themselves are run sequentially, so their state is never accessed in parallel from multiple threads. This should align with a model of a brain well, as cells are physically parallel and exchange various kinds of messages. To do it computationally efficient, a sensible subdivision of the problem is to be found,
The Actor Model unifies the APIs for concurrency and distribution, as there are no locks: actors communicate via messages. These translate to simple method calls in Pony
actor Thing
let _env : Env
var _counter: U64 = 0
new create(env: Env) =>
_env = env
be jump() =>
_counter = _counter + 1
_env.out.print(_counter.string() + ": jumping")
actor Main
new create(env: Env) =>
let t = Thing(env)
t.jump()
env.out.print("Hello, world!")
t.jump()
↓
Hello, world!
1: jumping
2: jumping
By the way, Pony syntax is similar to Python. Also, there are no globals in Pony, thus one can see the safe environment to print something being passed around.
Other topics for more context: