News for hackers. Stuff that matters.
Re:Synchronous languages by mcguire on Thursday October 04, 2018 @09:01PM (#18144913)
I've read some about Esterelle, but no other contact. Had anyone had any experience with any of these?

One of my professors had an idea about distributed synchronous programming, but nothing ever came of it.

Re:Synchronous languages by crocal on Friday October 05, 2018 @03:19AM (#18146326)
Out of this language was spined off an entire company (Esterel technologies). They developed the SCADE suite and it was/is used to develop safety critical software in various industries (aeronautics, railways, nuke...) [1]. There are companies providing industrial proof engines too [2]

I have had personal experience delivering the technology in the fields. We implemented the entire safety logic of a driverless train control system using SCADE (hence esterel). Airbus uses it for their onboard computers. So as you can see, this has had massive application around the world.

[1] http://www.esterel-technologies.com

[2] https://www.prover.com/

Re:Synchronous languages by psuter on Thursday October 04, 2018 @10:06PM (#18145196)
A friend+former colleague of mine is the lead author of ReactiveML, a synchronous extension to OCaml: http://rml.lri.fr/

We worked on a hackathon together where we built a physical chessboard interface (https://github.com/chesseye/chesseye). He built the controller, which handles among other things the output from the video recognizer and messages the chess engine, in ReactiveML. I didn't know much about the language beyond first principles then, but was impressed by how easy it made it to compose parallel processes.

We tried to convey some of those conclusions in a later presentation, even though looking at it 2 years later I realize it's probably hard to get the insights without the verbal delivery: https://github.com/chesseye/chesseye/blob/master/presentatio...

(I understand there was a ReactiveML tutorial at ICFP last Saturday: https://icfp18.sigplan.org/program/program-icfp-2018, not sure if this post is related.)

Re:Synchronous languages by eeks on Thursday October 04, 2018 @09:16PM (#18144982)
I was in undergrad and grad school in Grenoble where I had F. Maraninchi and P. Caspi as teachers for the synchronous programming and VLSI classes (embedded system track). We did a lot of Lustre. It's a pretty great way to get acquainted with synchronous programming and all the fun stuff that derives from it (cf. SDF, code generation, soft/hard real-time, and FPGA programming). Fun times.
Re:Synchronous languages by p4bl0 on Friday October 05, 2018 @05:13AM (#18146752)
> One of my professors had an idea about distributed synchronous programming, but nothing ever came of it.

It shouldn't be too difficult to distribute synchronous languages, and it is a quite natural idea. Most have a semantics based on Kahn networks [1], which is already a distributed model of computation :).

[1] https://en.wikipedia.org/wiki/Kahn_process_networks

Re:Synchronous languages by adwn on Friday October 05, 2018 @10:02AM (#18148175)
> It shouldn't be too difficult to distribute synchronous languages, and it is a quite natural idea. Most have a semantics based on Kahn networks [1], which is already a distributed model of computation :).

I don't think this is correct. Kahn networks are asynchronous (and therefore well-suited for distributed systems), but synchronous languages are – well, synchronous.

For every pair of nodes that exchange information, there has to be a rendezvous between them after every non-instantaneous step [1], which is terrible for performance in a distributed system (but virtually free in typical single-clocked, synchronous digital circuits).

[1] You can devise heuristics which reduce the frequency of those rendezvous in some cases, but conceptually, they're still there.

Re:Synchronous languages by p4bl0 on Friday October 05, 2018 @12:42PM (#18149574)
Mh, you're right.

However, there is a notion of synchronous Kahn networks, but maybe it is only used by functional synchronous and dataflow languages (e.g., Lucid Synchrone, ReactiveML). Compilation of such languages involve clock calculus (i.e. typing for scheduling) which I think makes it possible to compute the maximum size of a queue in the network (or maybe at least guarantee that the size is bounded?). This would mean that what you call rendezvous points would be statically computable (in the case of pure synchronous languages it should be easy as the maximum queue size is zero, or one depending on how we count).

Anyway, you're right that I was mistaken to think that it was an easy problem.

EDIT: Heh: https://www.lri.fr/~mandel/papiers/MandelPlateauPouzet-MPC-1... :).

Re:Synchronous languages by jcelerier on Friday October 05, 2018 @08:46AM (#18147667)
I'm working on a multimedia sequencer whose formal model is based on synchronous dataflow : https://ossia.io ; it's actually a fairly common model in audio-video software since it maps so well to the problem domain (applying operations on inputs and producing outputs at regular intervals).
Re:Synchronous languages by jonnydubowsky on Friday October 05, 2018 @03:12PM (#18150912)
Ossia looks like a fantastic project! I've only spent a few moments looking through the site and github, and see some interesting possibilities for integration into my work. I'd love to connect with you. Let me know where best to reach you, my contact info is in my profile. I'm working on an ecosystem management framework where public art installations serve as monitors, dashboards and signal generators for citizen scientists and artists working to expose environmental impact. We've been looking for a protocol to route messages in and out of MaxMSP, Unity, and the external graph databases, and your use of OSC seems to solve many of our problems. Cheers!
Re:Synchronous languages by vanderZwan on Thursday October 04, 2018 @10:57PM (#18145407)
I've dabbled with Céu for some toy programs, which is a modernized Esterel of sorts[0]. I wish more people picked it up; it's a tiny language, currently mostly developed by one professor in Brazil, but quite fun! I think it would be a great environment to teach Arduino in, if I'd ever do that again. A year ago I wrote a comment on /r/Arduino giving an example snippet[1], which I'll copy here:

    #include "arduino/arduino.ceu"
    
    input  int PIN_02; // button input
    output int PWM_05; // LED outputs, remember that pins 5 and 6
    output int PWM_06; // have a higher PWM frequency on the UNO
    
    // a code block that concurrently fades an LED in and out
    // `pin`     the output pin of the LED
    // `min`     min value of the fade
    // `max`     max value of the fade
    // `delay`   ms to wait between `analogWrite` updates
    code/await Fade_forever(var u8 pin, var u8 min,
            var u8 max, var uint delay) -> void do
        loop do
            var int i;
            loop i in [min->max[ do // fade in loop
                if pin == 5 then
                    emit PWM_05(i);
                else/if pin == 6 then
                    emit PWM_06(i);
                end
                await delay ms;
            end
            loop i in [min<-max[ do // fade out loop
                if pin == 5 then
                    emit PWM_05(i);
                else/if pin == 6 then
                    emit PWM_06(i);
                end
                await delay ms;
            end
        end
    end
    
    loop do //endless loop
        // if *any* of these three code blocks (trails) end,
        // all of the remaining trails in a `par/or` are 
        // aborted and code resumes (in this case, the outer
        // loop restarts). By comparison, a `par/and` 
        // would require *all* of the trails to terminate.
        par/or do
            // if a button is pressed, reset the loop
            await PIN_02;
        with
            // fade the LED at pin 5 quickly between 64 and 192
            await Fade_forever(5, 64, 192, 5)
        with
            // fade the LED at pin 6 slowly between 0 and 256
            await Fade_forever(5, 0, 256, 20)
    end
Pretty simple and readable code, don't you think? (Note the use of Bourbaki interval notation for [min -> max[ - how often have you seen that in programming languages?) Now imagine what the plain C version of this would look like.

What I also find fascinating about it is that it has almost no memory overhead per trail - a handful of bytes IIRC. Compare that to the kilobytes required for green thread solutions elsewhere. OTOH, computationally the concurrency doesn't really scale with large numbers of trails - I think you could compare it to insertion sort: unbeatable for small arrays due to low overhead, but then that O(n^2) takes over.

One might envision having many small Céu programs with only a handful of trails each, asynchronously running in their own threads and interacting with each other. From what I gather, programming in this model is called using the GALS principle: Globally Asynchronous, Locally Synchronous. For the intended environment for Céu (embedded programming), you kind of "naturally" get this: asynchronicity just kind of "happens" due to separate pieces of hardware interacting.

Anyway, it kind of feels like the "missing element" in reactive and concurrent programming paradigms to me. I hope more languages will start picking it up eventually.

[0] http://ceu-lang.org/

[1] https://www.reddit.com/r/arduino/comments/5qzv12/c%C3%A9uard...

Re:Synchronous languages by jacobush on Friday October 05, 2018 @04:05AM (#18146502)
Feels like VHDL, with different clock domains
Re:Synchronous languages by vanderZwan on Friday October 05, 2018 @10:01AM (#18148165)
Tangent: I have never used VHDL, but conceptually I find it mind-blowing that we have programming languages for automatic hardware design. I wonder if anything can be learned from it when designing "regular" programming languages.
Re:Synchronous languages by sevensor on Friday October 05, 2018 @10:32AM (#18148395)
I did some VHDL in school when I was doing a computer engineering degree. We came at it from underneath, as it were -- we'd done a fair number of classes on digital logic and VLSI design. So the way we wrote it felt like describing hardware (hence the name, Hardware Description Language) rather than writing software. That being said, it had a lot of affordances we didn't use, that would have made it feel a lot more like a programming language. Unlike a programming language, though, you're acutely aware of the cost. Every line costs you surface area / FPGA gates, and if your HDL is too big, it won't fit in the IC you want to program.