
Show HN: Céu, Structured Synchronous Reactive Programming - fsantanna
http://www.ceu-lang.org
======
fsantanna
Hi, I'm the author of the programming language Céu.

Although Céu is about 5 years now, this is the first time I post to "Show HN".

In this new version, we are trying to surpass the academic fences with a more
polished work (docs, build, etc).

All feedback is welcome.

Francisco

~~~
teleclimber
It would be helpful if you could provide a high-level explanation of what
"Structured Reactive Programming" means and what problem you are trying to
solve with current solutions? How is it different from current reactive
environments?

~~~
fsantanna
Thank you, I will improve the page.

In summary:

Reactive: code executes in reactions to events

Synchronous: reactions run to completion, i.e., there's no implicit preemption
or real parallelism (this avoids explicit synchronization: locks, queues, etc)

Structured: programs use structured control mechanisms, such as "await" (to
suspend a line of execution), and "par" (to combine multiple awaiting lines of
execution)

Structured programming avoids deep nesting of callbacks letting you write
programs in direct/sequential style. In addition, when a line of execution is
aborted, all allocated resources are safely released.

In comparison to FRP/dataflow, it is more imperative supporting
sequences/loops/conditionals/parallels. The notion of (multiple) program
counter is explicit. Also, everything is lexically scoped, there's no GC
involved.

In comparison to promises/futures, it provides lexical parallel constructs,
allowing the branches to share local variables and, more importantly,
supporting safe abortion of code (with the "par/or").

~~~
jessaustin
_Synchronous: reactions run to completion, i.e., there 's no implicit
preemption or real parallelism_

Does this mean a program will hang if e.g. disk or network access takes too
long?

~~~
hisham_hm
Yes in theory. But in practice the language includes "async" support so you
can guard these few operations that may take long. Like in a functional
language you assume everything is pure unless marked to have side-effects,
here you assume every reaction is instant unless is something that has to be
explicitly "awaited" for. It's a pretty clean model.

------
ratstew
What are the advantages of Céu over other synchronous programming languages
such as Esterel and Lustre?

~~~
junke
Céu looks really similar to Esterel. The thesis ([http://www.ceu-
lang.org/chico/ceu_phd.pdf](http://www.ceu-lang.org/chico/ceu_phd.pdf)) has a
section titled "III.7 Differences to Esterel". _(edit: removed explanations,
the other comment is more detailed)_.

~~~
fsantanna
Thanks, forgot to mention in the other comment that Céu is actually based on
Esterel.

------
zzzcpan
Was there a particular problem you were trying to solve by creating Ceu? Or
was it just to learn things about compilers?

EDIT: found the answer in the paper: "Despite the continuous research in
facilitating programming WSNs, most safety analysis and mitigation efforts in
concurrency are still left to developers, who must manage synchronization and
shared memory explicitly. In this paper, we present a system language that
ensures safe concurrency by handling threats at compile time, rather than at
runtime."

~~~
pron
I'm not the language's creator, but I assume that part of the goal was to
bring synchronous programming to the mainstream. Synchronous programming
languages are well known in the safety-critical hard realtime world. They're
based on a mathematical theory that (as opposed to pure-functional
programming) embraces interaction and concurrency, which makes them very
suitable for interactive applications (whereas compilers are the natural
domain for pure-FP). In addition, synchronous languages are currently the most
amenable languages to formal verification. These two reasons are why they're
popular and successful in the domain I mentioned. Also, synchronous languages
naturally support styles of programming (under research) that are intended to
be more natural, and facilitate correct code (in addition to the formal-
method-friendliness), such as behavioral programming[1].

BTW, Eve is another synchronous language, although a declarative rather than
an imperative one like Céu. It's great to see those time-tested and well-
studied ideas finally break out of the safety-critical realtime world.

[1]:
[http://www.wisdom.weizmann.ac.il/~bprogram/more.html](http://www.wisdom.weizmann.ac.il/~bprogram/more.html)

~~~
fsantanna
> "part of the goal was to bring synchronous programming to the mainstream"

This was not the original academic goal, but it is now.

We want to offer an imperative alternative to program reactive systems.

~~~
pron
Any plans on offering formal methods for Céu?

~~~
fsantanna
Some colleagues are working on an operational semantics of the language (based
on the one in the thesis). This will allow us to prove some claims (e.g.,
reaction termination, bounded memory). Then, we may think about something
else. Anything more specific in mind?

~~~
pron
Temporal logic verification (via model checking, static analysis, test
generation, runtime checks etc.)?

~~~
fsantanna
That would be interesting.

It seems to be feasible given the language semantics.

We'll definitely investigate it.

------
talles
Just a bit of trivia: "lua" means "moon" and "céu" means "sky" in Brazilian
Portuguese.

------
AlexanderDhoore
I've been trying to learn more about synchronous programming languages for a
while now. Will definitely look into this.

Does anyone know how I could get my hands on Lustre or Esterel? They are not
freely available, or are they? Also any good books or resources are very much
appreciated.

~~~
fsantanna
You can download Esterel freely:

[http://www-sop.inria.fr/esterel-org/files/Html/Downloads/Dow...](http://www-
sop.inria.fr/esterel-org/files/Html/Downloads/Downloads.htm)

(AFAIK, it is not open source though.)

[EDIT] For documentation, see "The Esterel Language Primer":

[http://www.rw.cdl.uni-
saarland.de/~kaestner/es0203/esterel_p...](http://www.rw.cdl.uni-
saarland.de/~kaestner/es0203/esterel_primer.pdf)

Don't know about Lustre.

~~~
AlexanderDhoore
Thank you! I'm actually working on my own synchronous language, but it's more
in line with Lustre than Esterel. Synchronous dataflow with soft real-time
goals. If it starts to look like something decent I'll put it on github.

~~~
ratstew
Since you're interested in the implementation of synchronous languages you
could also take a look at Quartz [1]. Their book is a fantastic resource about
the topic.

[1] [http://www.averest.org](http://www.averest.org)

------
hisham_hm
Kudos for the work! The intro video is really nice (pro tip: it is perfectly
watchable at 1.25x (or even 1.5x) speed — thanks, YouTube speed settings!)

------
flippyhead
Great to see this here. I love Ceu. It's a joy to use for the Arduino.

