Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

What If Programs Were Mostly Just Values Flowing Through Functions?

I've never particularly enjoyed reading code that makes me suddenly switch from following values to chasing control flow. A variable gets assigned halfway through. A function returns halfway through. An if redirects the path. Then the value gets another name. None of this is difficult to understand. But when I'm tired, I eventually end up asking: "So where did this value come from, and where is…

In the world of programming, one question that often arises is whether it would be simpler if code displayed how values change as they travel through the program. The author of the source material expresses a preference for this approach, noting that reading code where variables are assigned and then returned midway can be distracting, especially when fatigue sets in.

They provide an example in TypeScript, where filtering, mapping, and reducing an array is done in a way that makes the transformations visible in order. However, once the value is no longer an array or ordinary functions are introduced, method chaining breaks down and additional libraries need to be learned, complicating the learning curve.

The author's project, F-Box, aimed to keep the value flowing smoothly. In their implementation, they used a pipe helper and a library to achieve this. A sample code snippet in Seseragi, the programming language they developed, showcases this concept. The value moves from left to right through various functions, with a clear visual representation of the data flow.

The author explains that small functions help maintain this shape, making the code more readable and easier to comprehend. They also mention the use of the '$' operator for function application, which they find visually appealing and less nested than other syntaxes.

The author emphasizes that their focus is on making ordinary code pleasant and enjoyable to work with, rather than incorporating complex features that might be impressive but difficult to understand. They acknowledge that Seseragi includes advanced concepts like type classes, Effect, and Signal, but these are not the primary focus.

Instead, the language aims to provide a gentle learning curve, where writing a function, passing a value through it, and sending the result to the next function feels natural and intuitive. The author invites readers to experiment with the language by changing values, modifying functions, or adjusting the pipeline's structure, demonstrating that language design is a matter of personal preferences and comfort.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why Should the Language Change the Moment I Build a UI?

In ordinary application code, I create values, pass them to functions, and distinguish between cases. Then Web UI begins, and sometimes the whole world changes. Component. Hooks. JSX. Store.

  • Seseragi framework treats components as ordinary functions.
  • UI expressed as ordinary values and data constructors.
  • Development mirrors language progression, feels natural.

More from Sunday 16 August →