ugly code

Perfect code doesn’t guarantee success if you haven’t solved a real problem for real people. Pursuing elegance in a vacuum leads to abandoned side projects or frameworks nobody uses. By contrast, clunky but functional code often comes with just the right compromises for quick iteration. And that in turn means a lot of messy code powers products that people love — something that’s a far bigger challenge.

Are you shipping a product and racing to meet user needs? Or are you building a reusable library or framework meant to stand the test of time?

Both mindsets are valid, but they rarely coexist harmoniously in a single codebase. Flamework is a reminder that messy, simple solutions can be powerful if they solve real problems. Eventually, when the time is right, you can clean it up or rebuild from the ground up.

no_std rust

featureno_stdstd
heap (dynamic memory)note 1yes
collections (Vec, BTreeMap, etc.)note 2yes
stack overflow protectionnoyes
run init code before mainnoyes
libstdnoyes
libcoreyesyes
firmware, kernel or bootloaderyesno
  • note 1: only if you use the alloc crate and use a suitable allocator like alloc-cortex-m

  • note 2: only if you use the collections crate and configure a global default allocator.

  • note 2: HashMap and HashSet are not available due to a lack of a secure random number generator.

ref

femalemale
maria: sea of sorrowjose: god will increase
carmen: garden, guard, and songluis: renowned warrior
ana: grace, mercymanuel: god is with us
isabel: god is my oathfrancisco: free man
maria carmen: sea of sorrow, gardenjuan: god is gracious
dolores: sorrowjavier: new house
pilar: pillarmiguel: who is like God
teresa: harvestercarlos: free man
rosa: roseangel: messenger
lucia: lightalberto: nobel and bright
esther: starramon: wise protector
luz: lightdiego: teaching

parallelism models: actor, CSP, multithread

  • actors model: erlang, scala, rust
  • CSP: go
  • threads: java, C#, C++

multithread: deadlocks, bad scaling, shared state.

Both CSP and actor-based parallelism models are based on message passing. In both models, the receiver is synchronous: when it’s ready to listen for messages it blocks until it gets a message (although variants allow for them to do a non-blocking poll or have a time out).

CSP is fully synchronous. A channel writer must block until a channel reader reads. The advantage of that blocking based mechanism is that a channel only needs to ever hold one message. It’s also in many ways easier to reason about.

With actors sending is asynchronous. A message sender will not block whether the reader is ready to pull from the mailbox or not, instead the message goes into a queue usually called a “mailbox”. Which is convenient, but it’s a bit harder to reason about and mailboxes potentially have to hold a lot of messages.

In CSP processes communicate using channels. Program can create and pass them around as first class objects. Actors have an address system and inboxes. Only one address per process.

In CSP send and receive operation may block. In Actors Model only receive operation may block.

In CSP messages are delivered in order they were send, in Actors model it’s not the case. In fact system may not be able to deliver some messages at all. So far CSP model works best on one machine, while Actors model scales easily across several machines.

In a conclusion: Actors are more appropriate for distributed systems. Because of blocking nature of CSP, it’s hard to use them across several machines/runtimes.