ENTRIES TAGGED "flow-based"

Bringing Programming Out of Its Temples

If everyone should learn to code, code needs to change

2013 may have seen a tipping point for the popularity of programming. Even people who aren’t programmers are suddenly arguing that it’s a good idea for everyone to learn programming. Computers are now everywhere, traveling with us, common in places where they would once have seemed an extravagance, and it seems obvious that we need to be able to do more with them.

Anil Dash looked beyond the basic vision of teaching everyone to code this week. Dash leads with President Obama’s encouragement of computer science as part of this week’s Hour of Code project, and his suggestions to young Americans:

“Don’t just play the latest video game. Make one.

Don’t just download the latest app. Help design it.

Don’t just play on your phone. Program it.

(It’s not just the President—it’s House Majority Leader Eric Cantor too.)

It is, of course, harder than that. I love Dash’s piece, which reflects on the value of code, the challenges of crossing tech culture boundaries, and the need for tech culture itself to support and make more valuable such efforts at democratizing coding. I shared it on Facebook, happily citing the part about:

Read more…

Comments: 9 |

Toward Explicit State

Minimize assumptions, maximize testability

Model the flow of data instead of the logic of the program? That’s crazy! How can you encapsulate anything that way?

My piece on flow-based programming set off a lot of conversations, notably at Slashdot and Reddit. Many of them were hostile, wondering how such a different model could possibly work. Not all, but a lot, were the right kind of productive skepticism.

The reason this makes sense to me isn’t my time programming. My time in markup makes it seem much more sensible. While there are ways to incorporate content by reference (entities) in markup, parsers typically flatten those references into a single tree that is “the document”. Markup processing certainly can combine document transformations with data picked up from some other aspect of the program, but clean transformations are pretty ordinary.

In my broader programming experience, clean transformations are rare. Most of the code that I’ve written is all about creating logical components (often mixed with data) that communicate with other components. Data flows in fragments, and comes and goes from databases, other processing, and whatever structures seem convenient. Testing pieces in isolation is difficult, and worse, not always meaningful. If tests only apply when a program or process is in one state but not another, gaps will grow and test suites will expand perpetually.

The path I see forward – whether in functional programming, flow-based programming, or other attempts at sanity – is making state explicit at every step. This means structuring flows of information so that pure transformations are separated from side effects. Transformations take all the data they need directly as input, and generate only resulting data as output. Other functions (or processes, or whatever name they have in your system) handle all the interactions that have side effects. “Side effects” includes a lot:

Read more…

Comments: 3 |

Transformative Programming

Flow-based, functional, and more

“Small pieces loosely joined,” David Weinberger’s appealing theory of the Web, has much to say to programmers as well. It always inspires me to reduce the size of individual code components. The hard part, though, is rarely the “small” – it’s the “loose”.

After years of watching and wondering, I’m starting to see a critical mass of developers working within approaches that value loose connections. The similarities may not be obvious (or even necessarily welcome) to practitioners, but they share an approach of applying encapsulation to transformations, rather than data. Of course, as all of these are older technologies, the opportunity has been there for a long time.

The Return of Flow-Based Programming

No Flo and its successful Kickstarter to create a unique visual environment for JavaScript programming reawakened broader interest in flow-based programming. FBP goes back to the 1970s, and breaks development into two categories:

“There’s two roles: There’s the person building componentry, who has to have experience in a particular program area, and there’s the person who puts them together,” explains Morrison. “And it’s two different skills.”

That separation of skills – programmers creating separate black box transformations and less-programmery people defining how to fit the transformations together – created a social problem for the approach. (I still hear similar complaints about the designer/programmer roles for web development.)

The map-like pictures that are drawing people to NoFlo, like this one for NoFlo Jekyll, show how the transformations connect, how the inputs and outputs are linked. I like the pictures, I’m not terribly worried that they will descend into mad spaghetti, and this division of labor makes too much sense to me. At the same time, though, it reminds me of a few other things.

graphic representation of flow through Jekyll

NoFlo diagram for noflo-jekyll

Read more…

Comments: 20 |