react flow

219 views
Skip to first unread message

Paul Tarvydas

unread,
Apr 19, 2021, 12:06:48 PM4/19/21
to Flow Based Programming

Raoul Duke

unread,
Apr 19, 2021, 12:46:57 PM4/19/21
to flow-based-...@googlegroups.com
nice!

On Mon, Apr 19, 2021 at 9:06 AM Paul Tarvydas <paulta...@gmail.com> wrote:
>
> https://reactflow.dev/
>
> --
> You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/flow-based-programming/841b720d-375f-419d-9bc0-b4e77b0ec582n%40googlegroups.com.

ern0

unread,
Apr 21, 2021, 1:13:21 PM4/21/21
to Flow Based Programming
Wow, it's impressing.

It's been a while I posted to this list, just a quick reminder: with a
friend, I've written a dataflow system for home automation purposes,
prototype-hobby state. Also I've made a concept for GUI:
http://linkbroker.hu/ihome/editor/
I code C/C++ for embedded devices for food.

A friend of mine is writing a DAW-like application, for browsers, in
JavaScipt, I was surprised, it's not a toy, it's working (not yet
released, I can't show you). He made a dataflow system, routing one
audio module to another, and I started thinking on the GUI he made:
the modules are stacked, which means connection, the upper one sends
stuff to lower one. Also, there're multiple columns, and modules in
different columns can be connected somehow.

My problem is: even best box-like UI seems uncomfortable, beyond a complexity.

Do we have better representations of this kind of graph?
--
ern0
dataflow evangelist

Raoul Duke

unread,
Apr 21, 2021, 1:18:24 PM4/21/21
to flow-based-...@googlegroups.com
personally i don't thing there is any single "rendering" of the
underlying program that is the Best Right Answer. i think the entire
programming experience needs to offer multimedia interaction. of
course personally i also think everything should support
commandline+emacs+makefile as the fallback, i don't like it if some
language cannot be used at all w/out its gui.

https://baychi.org/bof/future/20030325c/
(vaporware)

Paul Morrison

unread,
Apr 28, 2021, 2:35:15 PM4/28/21
to Flow Based Programming
Hi guys!  How does react.js differ from NoFlo and/or NodeRED?

Thanks,

Paul M.

daudi mungah

unread,
May 1, 2021, 12:42:42 AM5/1/21
to flow-based-...@googlegroups.com
Paul 


React.js is a "frontend" end framework used in building spa(basically HTML in JavaScript) , noflo is a flow based framework for nodejs that has both an editor and a runtime while nodered is a flow based editor that involves making flows mostly used in IOT.

Usecases 

1)want to build a good website with great user experience use reactjs 
2)want to use fbp style building a website still using reactjs use noflo browser runtime and add reactjs as "frontend" framework
3)want to send data from an Arduino device to backend use nodered 




--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Paul Morrison

unread,
May 2, 2021, 12:05:04 PM5/2/21
to Flow Based Programming
Thanks!  I was a bit confused as Matt Carkci has a book out called " Dataflow and Reactive Programming Systems "...

Have you looked at https://github.com/jpaulm/javafbp-websockets ?  It uses Java-WebSocket, indirectly... so a) is it a SPA?  and b) can React.js talk to WebSockets? 

BTW Currently it only works with Chrome, but I'm sure someone who understands security can get it working under Firefox again!

Thanks,

Paul

Ged Byrne

unread,
May 3, 2021, 4:50:12 PM5/3/21
to flow-based-...@googlegroups.com
Hi Paul,

The flow within React is mostly hidden from the developer.   It is an alternative to the flow you describe in your chapter on online applications: Flow-Based Programming: On-Line Application Design (jpaulmorrison.com)

The user interaction is implemented using a single loop that applies content templates to the application data in order to render a DOM. 

The clever part is that it does not replace the current displayed DOM with the newly rendered one.  Instead it compares the two to generate a list of changes necessary to update the currently displayed DOM into the latest version of the rendered DOM.  The whole page does not need to be redrawn, just the parts that have changed.

User actions then update the Application Data, and the templates are once again applied to render a new DOM.  This gives us a flow graph that looks something like this:
image.png

However, React developers work on the templates and do not work with the rendering pipeline, although it is possible to customise it using middleware: Middlewares with react context and hooks - DEV Community

This pattern isn't unique to React, it's also used in TiddlyWiki and ELM.  

So this is the key difference between React and FBP.  React is a defined pipeline that supports component development.  FBP provides a framework for defining flow graphs.  A pipeline is limited for of Flow Graph with all components having the same ports ( usually something like IN, OUT and ERR ).

Regards, 


Ged


Paul Morrison

unread,
May 6, 2021, 6:44:41 PM5/6/21
to Flow Based Programming
Hi Ged, nice to hear from you!  I guess my understanding of the DOM isn't good enough, but this looks like an FBP diagram - in fact the diagram looks a lot like the diagram in https://github.com/jpaulm/javafbp-websockets/blob/master/README.md (near the bottom)...  except that your diagram has the compare and "apply updates" loop in addition.  I can see how that would be more efficient than redrawing the whole screen - if I understood correctly.

OTOH the script files in my JavaFBP-WebSockets example have the advantage of being fairly understandable, e.g. https://github.com/jpaulm/javafbp-websockets/blob/master/src/main/resources/scripts/chat1.html , esp. the onmessage function, but I assume react.js has to access a lower level API, so maybe a bit more complex to specify...?  

Regards,

Paul

Ged Byrne

unread,
May 10, 2021, 4:17:45 AM5/10/21
to flow-based-...@googlegroups.com
Hi Paul,

The diagram was deliberately made to show an FBP style flow.  The real thing is more complex, as shown in this diagram:

image.png

This diagram is taken from this tutorial, which is a good explanation of the React internals: React Components Lifecycle | Props and States in React | Edureka

There has been talk about what a client FBP framework will look like, and I think React is nearly there.  The way it does components is very powerful but the rendering pipeline, which the developer can hook into using hooks, is rather obscure.  If the flow graph was made explicit so that developers could then add their own stages it would be very powerful.

I don't think adding FBP to REACT would work, because it is built from the ground up on Functional principles.  It would be interesting to consider what a similar component framework would look like if built in jsFBP.

Regards, 


Ged


Paul Morrison

unread,
May 11, 2021, 10:50:10 AM5/11/21
to Flow Based Programming
You're right, that's pretty complex!  Based on what you said before, I would expect to see a compare function... unless the orange blobs represent this...?

As I tried to suggest in my previous post, the scripts in https://github.com/jpaulm/javafbp-websockets/tree/master/src/main/resources/scripts basically create html, which is then passed to the browser's html parser.  React must interact with the browser at a lower level...?

I am also keen on getting rid of the JavaScript - WASM looks promising!    Anyone working on that out there?!

Cheers,

Paul
 

Ged Byrne

unread,
May 14, 2021, 6:32:23 AM5/14/21
to flow-based-...@googlegroups.com
Hi Paul,

I think the scripts for web-sockets is a good starting point.

The question is what would a component framework for HTML look like?  The page is described as a tree of components each of which is rendered to produce html.  The basic format is:

IN: ESX Template, Javascript code, Data
OUT: HTML Fragment

The root calls it's branches so that they can render themselves.

Where your code renders the HTML page REACT renders a VDOM and it then compares to see what components have actually changed.  Only those components then render HTML.

It doesn't use any lower level feature, it just wraps every component in a DIV and updates the DIV's InnerHTML.

WASM is looking very promising, especially now that threading is being added: WebAssembly Threads ready to try in Chrome 70  |  Google Developers

I say it's best to wait a little while for the threading model to be standardised.

Regards, 


Ged


--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

paul tarvydas

unread,
May 14, 2021, 7:21:59 AM5/14/21
to 'Alex Kelley' via Flow Based Programming

Can FBP components share mutable data between them?

pt
 

On May 14, 2021, at 6:32 AM, Ged Byrne <ged....@gmail.com> wrote:

Hi Paul,

I think the scripts for web-sockets is a good starting point.

The question is what would a component framework for HTML look like?  The page is described as a tree of components each of which is rendered to produce html.  The basic format is:

IN: ESX Template, Javascript code, Data
OUT: HTML Fragment

The root calls it's branches so that they can render themselves.

Where your code renders the HTML page REACT renders a VDOM and it then compares to see what components have actually changed.  Only those components then render HTML.

It doesn't use any lower level feature, it just wraps every component in a DIV and updates the DIV's InnerHTML.

I say it's best to wait a little while for the threading model to be standardised.

Regards, 


Ged


On Tue, 11 May 2021 at 15:50, Paul Morrison <paul.m...@rogers.com> wrote:
You're right, that's pretty complex!  Based on what you said before, I would expect to see a compare function... unless the orange blobs represent this...?

As I tried to suggest in my previous post, the scripts in https://github.com/jpaulm/javafbp-websockets/tree/master/src/main/resources/scripts basically create html, which is then passed to the browser's html parser.  React must interact with the browser at a lower level...?

I am also keen on getting rid of the JavaScript - WASM looks promising!    Anyone working on that out there?!

Cheers,

Paul
 

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flow-based-programming/5f4dc607-7ca1-499a-8e0f-a6fcb5be56dcn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Ged Byrne

unread,
May 14, 2021, 8:10:28 AM5/14/21
to flow-based-...@googlegroups.com
Hi Paul,

Good question.

Let's consider how this works in React. 

The Components themselves will be IPs.  The data would be held in two IPs: Properties and State.

Within React these IPs are passed as parameters to the functions.

Here...
image.png

and here:
image.png

Within FBP we could receive the state, update it and then send it.  The IP is mutable.

In React we cannot change the state, it has to be replaced with a new instance.  The IP is immutable.

ONe big advantage to this for React is that it allows time travel: https://reactjs.org/tutorial/tutorial.html#adding-time-travel

Regards, 


Ged


paul tarvydas

unread,
May 14, 2021, 8:22:56 AM5/14/21
to flow-based-...@googlegroups.com
From WebAssembly Threads ready to try in Chrome 70  |  Google Developers

“… Browsers have supported parallelism via Web Workers since 2012 in Chrome 4; in fact it's normal to hear terms like 'on the main thread' etc. However, Web Workers do not share mutable data between them, instead relying on message-passing for communication. …”

What does the phrase “share mutable data between them” mean?

pt


On May 14, 2021, at 8:10 AM, Ged Byrne <ged....@gmail.com> wrote:

Hi Paul,

Good question.

Let's consider how this works in React. 

The Components themselves will be IPs.  The data would be held in two IPs: Properties and State.

Within React these IPs are passed as parameters to the functions.

Here...
<image.png>

and here:

Ged Byrne

unread,
May 14, 2021, 8:51:01 AM5/14/21
to flow-based-...@googlegroups.com
Hi Paul,

Mutable state means state that can be changed.  Immutable state cannot be changed. If we have Components C1 and C2 and all state is immutable then that means that the two components can only create and read data.  If you want different data then you need to create something new. 

Shared mutable state means that the data can also be changed or deleted.  With mutable state both C1 and C2 can make changes or delete the data.  This introduces problems like C2 deletes the data and then C1 tries to use it. 

Web workers have mutable state that can be altered and deleted but it cannot be shared.  The components can only communicate by sending each other messages. 

FBP has synchronised mutable state.   Both C1 and C2 can change the data, but not at the same time.  The ownership of the object has be transferred first. 

Regards,

Ged

Paul Morrison

unread,
May 14, 2021, 10:42:01 AM5/14/21
to Flow Based Programming
Interesting discussion, and thanks for the feedback on react, Ged! 

Question for Paul T.: how does Alex Kelley fit in with this discussion?   I couldn't find him in the conversation...

I assume someone talks about "sharing mutable data" - of course, this is very dangerous given full asynchronism,  but probably manageable to some extent with the more synchonous, "FBP-like" approaches...

Cheers,

Paul M.

Paul Tarvydas

unread,
May 17, 2021, 4:50:29 PM5/17/21
to Flow Based Programming
> On May 11, 2021, at 10:50 AM, Paul Morrison ... wrote:
...
> I am also keen on getting rid of the JavaScript - WASM looks promising!    Anyone working on that out there?!

I built a small pseudo-code-to-wasm transpiler using Ohm-JS and my own tool (called 'glue').

If you are looking to code WASM (WAT) directly, then I might be able to help, since I've jumped through the hoops, and I ain't no stranger to lisp-like syntax.  I probably can't help if you want to use wasm from an existing language (I don't see the point).

pt

Niclas Hedhman

unread,
May 18, 2021, 1:58:03 AM5/18/21
to flow-based-...@googlegroups.com
On Tue, May 11, 2021 at 4:50 PM Paul Morrison <paul.m...@rogers.com> wrote:

I am also keen on getting rid of the JavaScript - WASM looks promising!    Anyone working on that out there?!


I did a test in 2018 with a small Rust program, to see how large the minimum program would become; ~180kB IIRC.

There is a very good reason to look at Rust when it comes to WASM, in one word; Mozilla. They are heavily involved in both.

But one can use C++ for that matter. The crypto/blockchain of EOS (https://github.com/EOSIO) uses WASM as the on-chain language and runtime, and blockchain contracts are written in C++ and compiled to WASM. Those WASM executables are really small foot print (memory is VERY valuable on EOS). For those who don't know, EOS produces two blocks per second and has piqued at 7840 transactions per second.


Cheers
Niclas


Ged Byrne

unread,
May 18, 2021, 4:34:24 AM5/18/21
to flow-based-...@googlegroups.com
Hi Niclas,

Rust compiles to WASM?

That's interesting because there is an FBP implementation in Rust which was created by Stewart Mackenzie.

The RustFBP crate is here: https://lib.rs/crates/rustfbp

The source code can be found here, a module within the Fractalide project: https://github.com/fractalide/fractalide/tree/master/modules/rs/rustfbp

I'm not sure if Stewart is still on this group.  Fractalide is still showing as coming soon and the last pull request was in 2019.

There is also a video from FOSDEM 2019 where Claes Wallin delivers a talk with the title: Fractalide and Cantor A Racket application built with Flow-Based Programming:

Here's a slide from that presentation:

Could RustFBP provide the foundation for a general purpose FBP framework for FBP, with JS interop allowing the definition of JS components? https://www.youtube.com/watch?v=mqP1z7FaSQs



Regards, 


Ged



--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Ged Byrne

unread,
May 18, 2021, 4:39:29 AM5/18/21
to flow-based-...@googlegroups.com
Sorry accidental Alt-Enter sent that message mid edit.  Here is the correct version.


Hi Niclas,

Rust compiles to WASM?

That's interesting because there is an FBP implementation in Rust which was created by Stewart Mackenzie.

The RustFBP crate is here: https://lib.rs/crates/rustfbp

The source code can be found here, a module within the Fractalide project: https://github.com/fractalide/fractalide/tree/master/modules/rs/rustfbp

I'm not sure if Stewart is still on this group.  Fractalide is still showing as coming soon and the last pull request was in 2019.

There is also a video from FOSDEM 2019 where Claes Wallin delivers a talk with the title: Fractalide and Cantor A Racket application built with Flow-Based Programming: https://www.youtube.com/watch?v=mqP1z7FaSQs

Here's a slide from that presentation:
image.png
 

Could RustFBP provide the foundation for a general purpose multi-threaded FBP framework for FBP, with JS interop allowing the definition of JS components?

I can see FBP and Rust being excellent complements.  Rust is great, but it's uncompromising approach to safety and tight resource management can drag down productivity.  Definining safe, tight components in Rust to be composed using as FBP IDE for high velocity delivery looks to be an ideal partnership, especially if you can then deploy to both the server and the browser.

Regards, 


Ged



Paul Morrison

unread,
May 18, 2021, 12:25:58 PM5/18/21
to flow-based-...@googlegroups.com
Hi Ged,  I agree - this looks pretty exciting - I look forward to watching the video!  I had heard of Fractalide, but know nothing about it... it predates Rust, though, doesn't it?!

Cheer,

Paul

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Niclas Hedhman

unread,
May 18, 2021, 2:46:05 PM5/18/21
to flow-based-...@googlegroups.com

Ged,
I compiled Rust and tested for deployment on EOS blockchain (pre-launch) in 2018 and got that working (but not feasible because min 200kB will be too costly).

But a quick search; https://rustwasm.github.io/book/ and I am sure there are a lot more information out there.


Niclas

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Paul Morrison

unread,
Aug 13, 2021, 11:16:30 AM8/13/21
to Flow Based Programming
More reactions to Ged's remark, where he said,

"I can see FBP and Rust being excellent complements.  Rust is great, but it's uncompromising approach to safety and tight resource management can drag down productivity.  Defining safe, tight components in Rust to be composed using as FBP IDE for high velocity delivery looks to be an ideal partnership,"

I'm afraid my initial enthusiasm has waned - I am just about ready to give up on Rust for the FBP environment!  I wouldn't have come to this conclusion if I hadn't tried to get something working...

I have spent (wasted?) the last week trying to get a simple FBP proof of concept going in Rust - I know someone else has put a similar idea up on GitHub, called RustFBP, but I prefer to implement my own!  My attempt still does not compile, so I can't even begin testing! FYI, the URL is https://github.com/jpaulm/rust-test/blob/master/src/main.rs .

A nice chap in Germany has modified my code so that it does run, but he is cloning connections (and maybe also closures?), which IMHO doesn't make much sense, and seems unnecessary,  just to get around Rust's paranoia (!), so I am trying to use pointers, which feel more in keeping with real FBP... !   This in turn seems to lead to a lot of weird "lifetime" stuff...  Getting some simple code working shouldn't be this hard!

Andrew Cherry on the Slack group made some changes earlier, which worked and which I have kept - thnaks Andrew! - but I needed more function, hence my current situation...  I would like to move on, but can't get past this point!  Help!

I also need a mechanism for storing individual components in separate source files ("crates"?) - I can't even start that until I get the present version running...

Preliminary reactions:

a) my code is a dog's breakfast (with apologies to dogs) -  a lot of the declarative stuff is unnecessarily repeated - at any rate, when I leave it out, the test ('cargo run') tells me to put it back!  Why could Rust not just use a simple system of declaring variables, and then using them without having to repeat all the declarative info?

b) I don't like not being able to look at a variable and see what type it is - Rust claims to be type-safe, so why not just write in the types, instead of having it be deduced?!

c) all this "lifetime" garbage - FBP has a nice clear lifetime concept, so there should be a way in Rust to say "trust me - I know what I'm doing"!  Instead I get the impression that the Rust folks think they're smarter than anyone else!  However, apparently they are not familiar with FBP, so FBP and Rust are very much working at cross-purposes!  This won't be the first time that I've experienced this feeling of frustration!  By comparison, when something works well with FBP, it feel great!  :-)

d) There doesn't seem an easy equivalent of Java 'null' - that's weird!  That should be in all languages!

e) The only tool I've found that gives half-way useful diagnostics is 'cargo run', but it gives too many, and often its recommendations don't work when I try them out!  Basically, same problem as before - it doesn't understand FBP, and doesn't understand why one might want to pass IPs from one process to another via connections!

e.g. thread::spawn(move || {
    |         ^^^^^^^^^^^^^ `(dyn FnMut() -> bool + 'static)` cannot be shared between threads safely

what the h*** does that even mean?  I never said I wanted to share it...

So, if any of you are FBP and Rust enthusiasts, and feel they can work together, please take a look at my chunk of code, and tell me how to get things rolling again!  There are probably tools that would help, but so far I have not run across them!

Thanks in advance, and

<End of rant!>

Paul Morrison

unread,
Aug 13, 2021, 12:40:50 PM8/13/21
to Flow Based Programming
Oh, forgot to mention this mutability nonsense!  I know some people like immutability in FBP, but you don't have to mention it on every construct!  It's almost as if Rust is stuck in a pre-FBP world, where you had huge, monolithic programs!  FBP on the other hand has a very simple storage utilization model - virtually zero globals, and all data is either in method-local working storage, or in IPs.  That's it!  Code of course is read-only - so why do you have say whether functions are mutable or not...?  If FnMut means something different, then that's totally misleading!  :-(

Ged Byrne

unread,
Aug 13, 2021, 12:51:01 PM8/13/21
to flow-based-...@googlegroups.com
Hi Paul,

I feel your pain because I’ve found Rust to be difficult to learn as well.  

I really hope some Rust experts are able to help. 

Regards,


Ged

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Paul Morrison

unread,
Aug 13, 2021, 1:36:56 PM8/13/21
to Flow Based Programming
Thanks, Ged!  I'll give that wish a thumbs-up!

Cheers,

Paul

Paul Tarvydas

unread,
Aug 13, 2021, 1:50:58 PM8/13/21
to Flow Based Programming
My rules of thumb for implementing languages:

There are 2 types of languages:
1. human readable / human writable
2. machine readable / machine writable.

It is very painful to write a language compiler/interpreter AND target a human writable language (declaration-before-use, funky formatting conventions, etc., etc.).

It is MUCH easier to write a language compiler/interpreter AND target a machine writable language.

I can think of only several machine-writable languages:

1. Assembler
2. Bash
3. Common Lisp

JavaScript comes close, but someone chose to give it syntax (e.g. pesky "return" statements) and to loosen its type-checking to the point that number-of-args is not quite checked.

Python looks pretty good, but it has funky formatting conventions.  Ideally, I would want a python-with-braces without indentation requirements.

All you need are 1st class functions and a way to invoke functions (which, invariably means calling-a-function) to emit code for a language.

Creating an FBP compiler/interpreter/system falls into the writing-a-language class of things, IMO.

pt

Ged Byrne

unread,
Aug 13, 2021, 6:22:10 PM8/13/21
to flow-based-...@googlegroups.com
Hi Paul,

I don’t think that FBP are conceptually that different.  I would say that they are fundamentally different.  The problem is that Rust does not differentiate between the two levels of code and flow graph.  It tries to do everything statically within the one language.  

Regarding this error here:

it doesn't understand FBP, and doesn't understand why one might want to pass IPs from one process to another via connections!

e.g. thread::spawn(move || {
    |         ^^^^^^^^^^^^^ `(dyn FnMut() -> bool + 'static)` cannot be shared between threads safely

what the h*** does that even mean?  I never said I wanted to share it...

So, if any of you are FBP and Rust enthusiasts, and feel they can work together, please take a look at my chunk of code, and tell me how to get things rolling again!  There are probably tools that would help, but so far I have not run across them! 

Rust won’t let you pas a variable between threads.  To pass data between threads you must use a channel:  

 One major tool Rust has for accomplishing message-sending concurrency is the channel, a programming concept that Rust’s standard library provides an implementation of. You can imagine a channel in programming as being like a channel of water, such as a stream or a river. If you put something like a rubber duck or boat into a stream, it will travel downstream to the end of the waterway.

A channel in programming has two halves: a transmitter and a receiver. The transmitter half is the upstream location where you put rubber ducks into the river, and the receiver half is where the rubber duck ends up downstream. One part of your code calls methods on the transmitter with the data you want to send, and another part checks the receiving end for arriving messages. A channel is said to be closed if either the transmitter or receiver half is dropped.

Here, we’ll work up to a program that has one thread to generate values and send them down a channel, and another thread that will receive the values and print them out. We’ll be sending simple values between threads using a channel to illustrate the feature. Once you’re familiar with the technique, you could use channels to implement a chat system or a system where many threads perform parts of a calculation and send the parts to one thread that aggregates the results.”

If you take a look at the Fractalide port then it is using channels to send and receive.

Regards,



Ged

Paul Morrison

unread,
Aug 13, 2021, 7:04:32 PM8/13/21
to flow-based-...@googlegroups.com
Thanks Ged, didn't quite understand your first sentence: "FBP... are"...?!

However, I read your statements about channels, and that certainly doesn't explain the error message I quoted, as I haven't even gotten around to throwing in a second process!  So far, I have basically one "spawn" - I assume equivalent to an FBP process - and a main line, which I assume is equivalent to the network definition.  So, I'm afraid your note doesn't really apply!  Yet!

However, maybe you know: how do I do individual components which "extend" a class like JavaFBP Component - the only thing I have found so far is Trait "extending" Trait...?

Where are those experts?!   🤔

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Ged Byrne

unread,
Aug 13, 2021, 7:27:42 PM8/13/21
to flow-based-...@googlegroups.com
Sorry, that should read “fbp and rust are …”

I’m nit trying to explain the error.  What I’m suggesting is that you are trying to write code for a feature that already exists in the language.  

Rust already has built in mechanisms for creating processes on separate threads and then passing data between them using a channel. 

This is provided as a language feature because the underlying mechanisms are abstracted away from the user for the sake of safety.  

That means that when you try to add your own implementation you find yourself fighting the compiler.  

Regarding not yet having a second process - you do. 

To begin with you have the main process, which is where you define Closure1.  When you spawn your first thread you introduce the second process.  When you attempt to move Closure1 into the thread’s process it is rejected as unsafe. 

At least that’s how I understand it.  We really do need those experts. 

Paul Morrison

unread,
Aug 13, 2021, 10:32:32 PM8/13/21
to Flow Based Programming
Hi Ged, Thanks for your prompt response! 

This is why I think we have an architecture problem here - not just an implementation one!  What I think is happening - correct me if I'm wrong - is that I am trying to implement an FBP environment using a language that a) knows nothing about FBP, and b) does understand some of the problems that FBP addresses, but thinks it has a smarter way of solving them!  BTW without 50 years of experience with the concepts of FBP and a number of implementations in various languages!

My most "friendly" FBP implementation was written in IBM 360/370/Z90 Assembler Language (early '70s) - you could do anything with it, including interfacing with other systems that spoke the same language!  When PL/I interfaced with Assembler, no problem; when PL/I changed to run on its own VM (LE/370 I think), we lost that capability.  If PL/I had been willing to work with us, we would have had a very powerful, open-ended environment.  Same thing with CICS - it even had a similar internal architecture, but we could never make contact with them!

If you look at https://github.com/jpaulm you will see a variety of "true FBP" implementations which all support approximately the same mental model, and support multiple cores (apart from JSFBP, which does not support multiple cores).  They all have a clear "lifetime" concept for IPs, and storage is very safe, as all storage is either in method-local working storage, or in IPs.  There is virtually no "global" storage.  Within a single component, the programming is simple and straightforward!  At the network level, it is just a list of "quadruples"

      (process, output-port, process, input-port)...

At this point I have no interest in adapting the mental model of an FBP implementation to fit Rust's paranoia - I suspect it won't be "true" FBP anyway.  If the tools I use won't adapt themselves to the "true FBP" mindset, I will be forced to look for a more friendly language! 

Cheers!

Paul Morrison

unread,
Aug 13, 2021, 11:58:45 PM8/13/21
to Flow Based Programming
One other thought: where you said, " When you attempt to move Closure1 into the thread’s process it is rejected as unsafe.  "  That is weird!!!  Code is read-only - what does it mean to say "move it into the thread's process"?!!!   The only way code becomes non-read-only - at last in the last several decades - is if the code tries to modify a static field! 

Maybe this has to do with all this move/borrow nonsense!!?  Don't they understand how functions work?!  Sorry, Ged - I shouldn't get so excited...!

Ged Byrne

unread,
Aug 14, 2021, 1:24:48 AM8/14/21
to flow-based-...@googlegroups.com
Hi Paul,

Agreed.  Conceptually they are similar because the Rust concurrency is based on Communicating Sequential Processes.  I believe the missing insight is  that their are two levels of implementation.  Separating the two levels makes the implementation so much simpler.  

What we wanted from Rust was not it’s paranoia but rather the ability to target web assembly and interop with JS.  That is not unique to Rust, you can do it using emscriptn: 

That works for any language with an LLVM backed compiler.  Perhaps cross compiling from C would be better?  

That said, the compiled code doesn’t have any special multithreading abilities, it just uses web workers as explained in the article I posted to slack. 

I’m afraid I’ve led you down what looks to be a dead end.  Sorry, it looked so promising.  

The question is: what is the best way to do FBP in the browser?  Crosscompile CppFbp ( including Lua?), adapt JSFBP to use web workers, or Async/Await like StreamPunk?

Regards,


Ged

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Ged Byrne

unread,
Aug 14, 2021, 1:32:26 AM8/14/21
to flow-based-...@googlegroups.com
Within Rust you cannot pass code, only a closure.  That is code + state.  

It’s exolained here: 

The error message says you are passing in a FnMut. Thats a closure with mutable state.   It’s that mutable state that displeases the compiler. 

What you want to pass in is a Fn, a closure with immutable state.  Possibly an FnOnce that has its own state.  

The trick is learning the complex incantation necessary to appease the Rust compiler and cast that particular spell. 

--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.

Paul Morrison

unread,
Aug 14, 2021, 11:20:04 AM8/14/21
to flow-based-...@googlegroups.com
Hi Ged, thanks for your patience!  Re closures, the link you sent me says "function pointer + context", not "code + state"!  For me, "context" is the environment the closure lives in - I don't believe a function should have any state, so I'm thinking maybe I should try (stateless) functions...  BTW I tried changing the FnMut to Fn and got the same message!

I think your previous note was spot on!   You're absolutely right - I did not have any interest in Rust for itself - I really wanted something I could convert to WASM!   As you say, :

"The question is: what is the best way to do FBP in the browser?  Crosscompile CppFbp ( including Lua?), adapt JSFBP to use web workers, or Async/Await like StreamPunk?"

I think this is the right question!  CppFBP uses Boost for its multiprocessing, so I would be interested in whether WASM can talk to Boost, but this seems a more pragmatic issue than whether the philosophy of Rust is compatible with the philosophy of FBP!   Or what to sacrifice to appease Rust!  🤔

Given that I haven't done a Python implementation (although there are a lot of Python FBP or FBP-like products out there, maybe I should take a look at Pyston! Or do I want to spend the next several years working on Py**onFBP?!  🙂

So, some interesting choices ahead!

Thanks and best regards,

Paul

Ged Byrne

unread,
Aug 14, 2021, 11:51:21 AM8/14/21
to flow-based-...@googlegroups.com
Hi Paul,

The state is considered part of the environment, as it says here:  

 When a closure captures a value from its environment, it uses memory to store the values for use in the closure body. “

It also says: “ This is because the traits implemented by a closure type are determined by what the closure does with captured values, not how it captures them. ”

So it seems you can’t specify when you want a fn or fnmut, it decides based on what you do in the closure.

Personally, I’d rather it point to the place in the code that mutates the state and say “you can’t do that with an FN.”.  I’m sure that adding an the right symbol somewhere will give me that behaviour, but I can’t figure it out.  

Regards,


Ged



On Sat, 14 Aug 2021 at 16:20, Paul Morrison <jpau...@gmail.com> wrote:
Hi Ged, thanks for your patience!  Re closures, the link you sent me says "function pointer + context", not "code + state"!  For me, "context" is the environment the closure lives in - I don't believe a function should have any state, so I'm thinking maybe I should try (stateless) functions...  BTW I tried changing the FnMut to Fn and got the same message!
.

Paul Morrison

unread,
Aug 14, 2021, 4:22:25 PM8/14/21
to flow-based-...@googlegroups.com
Thanks again, Ged!  I didn't realize the difference between closures and functions!  I had coded my closure like a function - with one parameter, and strictly local storage!  Given that, I should be able to recast my closure as a function... with appropriate incantations!   😉  Have to say, though, that closures are weird - but they sort of make sense in JavaScript.... until you throw in the Rust "move" convention - then they make no sense at all IMHO!  🙁
P.


--
You received this message because you are subscribed to the Google Groups "Flow Based Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flow-based-progra...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages