11

Intrigued by Flow Based Programming a la J Paul Morrison. I wonder if one can implement FBP in Excel/VBA. I searched quite a bit for a Basic-Lang FBP implementation to no avail. I've looked at some FBP implementation details in Python but I'm not grokking it. VBA is what I'm most familiar with, but I'm suspicious that VBA can do FBP at all, without having coroutines or (?). Code 2 simple components, an Info-Packet Buffer Class, and a linkage between them and I would get it. I can't see where to begin.

Specifically I wonder:

  1. What would be the In-Ports, Out-Ports, 'bounded-buffer' graph-edges, and code to link them up look like?
  2. How to do message passing? Using raised application events?
  3. No way the resulting beast is inherently parallel or asynchronous, right?
  4. If it just can't be done in VBA, why not?
klausnrooster
  • 231
  • 1
  • 6
  • There is a somewhat related post on multi-threading in Excel 2007: http://stackoverflow.com/questions/14677866/concurrency-and-multi-threading-in-excel-vba Multi-threading is not fully supported in VBA. – Axel Kemper Sep 15 '13 at 11:33
  • @AxelKemper: dataflow programming AFAIK does not need any multihreading. – Doc Brown Sep 15 '13 at 13:33
  • ... though it will multithreading make easier. – Doc Brown Sep 15 '13 at 13:41
  • The C# FBP implementation (http://www.jpaulmorrison.com/fbp/CsharpFBP-2.3.zip) of "Component" makes heavy use of Threads. So does the Java implementation. Co-routines should be sufficient but difficult to implement in VBA. One could use Excel's inherent serialization feature which is working behind recalculation of a spreadsheet. But this would probably lead to a very limited mini-FBP. – Axel Kemper Sep 15 '13 at 15:46
  • I was thinking the same thing - use UDFs, Change Events, and Recalculation. I don't need a long-running process, just something I can run every midnight with a task scheduler. How a component is more re-usable than a class/ module/ function with a single purpose, and limited side-effects escapes me. The whole "port" thing too. – klausnrooster Sep 15 '13 at 16:30
  • @AxelKemper: Ralf Westphal's suggestions about implementing Flow Design in C#, which seem to be similar to FBP, do not need any threading, see here: http://geekswithblogs.net/theArchitectsNapkin/archive/2011/03/20/flow-design-cheat-sheet-ndash-part-ii-translation.aspx. The examples I have seen in the SICP book 20 years ago (http://mitpress.mit.edu/sicp/ , see chapter 3.3.4) did not need any threading. So I guess the need for threading is a fallacy, and it should not be too hard to make a VBA implementation. – Doc Brown Sep 16 '13 at 08:14
  • @DocBrown: If the Flow is modelled as a Petri Net or a Finite State Machine, it can be easily implemented in VBA. But this would then be a fully synchronous scheme which lacks the alleged benefits of FBP. If FBP is actually able to structure complex applications and to distribute the components seamlessly across multiple processors, VBA is definitely not the best choice as FBP programming language and development environment. – Axel Kemper Sep 16 '13 at 09:29
  • @AxelKemper: it may lack *some* benefits of FBP, but I suspect the independent-component aspect makes it still worth to investigate it. I am still hoping someone else had tried something like this already and will share his practical experience. – Doc Brown Sep 16 '13 at 20:56
  • @DocBrown: Your [geekswithblogs](http://geekswithblogs.net/theArchitectsNapkin/archive/2011/03/20/flow-design-cheat-sheet-ndash-part-ii-translation.aspx) link may do the trick for me (certainly clearer to me than any before), so thanks. I won't be able to code much until mid-Oct, but I may yet answer my own question here. – klausnrooster Sep 19 '13 at 00:37
  • @AxelKemper thanks too for introducing me to [Petri Net](https://en.wikipedia.org/wiki/Petri_net) concept. _Very_ interesting (Mathematical Rigor!) and I bet I will use it. – klausnrooster Sep 19 '13 at 00:40
  • @klausnrooster: I would appreciate to see your solution to your question! – Doc Brown Sep 19 '13 at 06:37
  • @klausnrooster: Another pointer could be the model of distributed computation proposed by Chandy and Misra: http://en.wikipedia.org/wiki/Chandy-Misra-Haas_Algorithm:Resource_Model – Axel Kemper Sep 19 '13 at 09:01
  • You can simulate flow based programming in VBA: you can create long-running encapsulated black-box objects in VBA, and link them together using a VBA script. You can do simple FBP in Excel: You can create and execute multi-threaded objects in Excel, and control them using a VBA script. You can do more complex FBP in Excel with the "HPC Services for Excel" and an HPC cluster. None of this meets the narrow definition of FBP, because there is no way of implementing "fixed-capacity" connections. – david Nov 30 '16 at 07:56

0 Answers0