Posts in DesignStudy

A Heisenbug in the Sieve

In Castle, one can dynamically connect components and send events over those connections. Typically, this is an action on an incoming message (see: The Actor Model). And depending on ‘The Machinery (ToDo)’, those events can be queued. It is this combination that can result in a beautiful Heisenbug.

First, let’s explain the Heisenbug, before we give an example. Then we analyze it, show how to improve the code, and finally formulate a requirement to prevent & detect this kind of bug in Castle.

Read more ...


QuickNote: Connecting two ports

Like in QN: Sending Events, we collect here some lines/fragments about connecting two ports in the handCompiled code to find similarities, and to design the (Jinja) templates.

Read more ...


QuickNote: Sending Events & Machinery

Depending on the The Machinery (ToDo), the generated code to send an events will alter. However, only a little bit as we will see in this study.

Read more ...


QuickNote: Jinja Events (templating)

As we have seen in the recent Workshop blog: QuickNotes a lot of code (to send/handle events) is always the same, but for some details. A template engine, like Jinja, can help in that.

Let’s study how those templates can help us.

Read more ...


QuickNote: Sending Events (generated code)

The handCompiled, generated to send an event is about 4 to 6 lines; depending on the The Machinery (ToDo), with a lot of similarity. It is however buried in lot of other code, notes, ect. And therefore hard to see the difference.

Here, we collect al those pieces, and see which lines/fragments are common – and can go into a template. And which parts we have to fill-in.

Read more ...


rPY: Use (r)Python as backend

When designing a Castle-Compiler with a C-backend, we found some nasty details unrelated to CCastle but to the C-language. For example, C has no namespaces (see No Name Collisions); we can simulate them, but that is extra work. Likewise, we need to generate many (data)classes that are very similar. Again, it is possible, but it takes a lot of work: to write the code that generates those almost codes.
Therefore, I started to think about how we can automate that. Or: who has done it before, and what can we borrow?

PyPy –an alternative Python implementation– has developed a concept for that! They have built a translator to convert (r)Python into C and compile that into native machine code.
Can we re-use that? And can it help to realize the “first (bootstrap) compiler” faster?

Read more ...


Concurrent Computing Concepts

Sooner as we realize, even embedded systems will have piles & heaps of cores, as I described in “Keep those cores busy!”. Castle should make it easy to write code for all of them: not to keep them busy, but to maximize speed up [useCase: In Castle is easy to use th... (U_ManyCore)]. I also showed that threads do not scale well for CPU-bound (embedded) systems. Last, I introduced some (more) concurrency abstractions. Some are great, but they often do not fit nicely in existing languages.
Still, as Castle is a new language, we have the opportunity to select such a concept and incorporate it into the language.

In this blog, we explore a bit of theory. I will focus on semantics and the possibilities to implement them efficiently. The exact syntax will come later.

Read more ...


FSM syntax, an evaluation

As described in FSMs are needed Finit State Machines are great and needed – even tough no (main) programming language has syntax support for it. But there are other (computer) language that (more-or-less) support the corresponding State pattern.
By example plantUML –very populair by mature developers– has a syntax to draw them.

What can we learn from them? That is the topic of this post, before we define the Castle syntax.

Read more ...


No inline actions

In Grammar is code we have mentioned that many compiler-compilers reuse the Yacc invention “actions”. And we hinted already that Castle prefers an alternative.

Let’s see why the old concept is outdated … And what is easier to use.

Read more ...


Grammar is code

In Compiler Compiler we have seen that we can define a grammar within a Castle-program. And we have argued that each grammars-rule can be considered as a function.

In this post, we look into de details of how this works. And will confirm grammars is code …

Read more ...