You are viewing archived messages.
Go here to search the history.

Paul Tarvydas 2024-08-19 01:15:04

Call Return Spaghetti

2024-08-18

PAUL TARVYDAS

AUG 19

In the essay referenced below, I examine why a diagram of a Call/Return system makes less sense than a diagram of a concurrent system.

Call/Return operates in a LIFO - last-in first-out, stack-like - manner.

Adopting an alternate perspective - FIFO, first-in first-out, queue-like manner - allows us to represent diagrams more easily.

CPU chips implement CALL and RETURN instructions as single opcodes, but, they do not implement queue behaviour as single opcodes.

Most popular languages are generally function-based, e.g. C, Haskell, Python, Javascript, Smalltalk, etc. Such function-based languages tend to adopt a LIFO (callstack) perspective and tend to use CALL and RETURN opcodes to fake out the function-based paradigm.

Such languages allow programmers to implement FIFO queues, but, such languages encourage the use of LIFO stacks. This seemingly small difference subtly affects designs with function-based - stack-based - thinking. This difference ultimately encourages single-threaded design while making multi-threaded design more difficult to imagine and to implement, as witnessed by the fact that most languages relegate multi-threading to hefty code libraries, while treating functions as basic building blocks.

This subtle encouragement towards function-based thinking has led to the general impression that Visual Programming Languages (VPLs), node-and-wire Diagrammatic Programming Languages (DPLs), Actors, etc., are ineffective programming tools.

I argue that VPLs, DPLs, Actors, etc. are effective programming tools, but that their use is are ultimately discouraged by the over-use of the function-based paradigm.

Further

guitarvydas.github.io/2020/12/09/CALL-RETURN-Spaghetti.html

Kartik Agaram 2024-08-19 01:44:41

One thing I've tried to articulate to you in the past, might be worth trying again:

LIFO has one advantage over FIFO as you implement it so far in your projects:

  • call/return involves passing arbitrary numbers of values between a single producer and a single consumer (caller/callee).
  • FIFOs involve passing arbitrary numbers of values between multiple producers and a single consumer (or vice versa)

I think the single/single constraint is easier to reason about. FIFOs might be easier to program with if you somehow preserve that constraint. It would certainly eliminate at a stroke a bunch of corner cases of timing and synchronization that bother me every time I think about your stuff.

One way to achieve this would be to say the nodes in the VPL can only have a single input port, but that port can take on arbitrarily structured types (records, arrays, etc.). Then you'd simulate multiple ports using tuple types, but the tuples would have to be explicitly created in a single node at a time.

Another way would be to restrict fan-in or fan-out somehow. Either input ports or output ports can only connect to a single wire. (I work at recroom.com, and our VPL includes both the input and output constraints in different situations. Might be worth a look: blog.recroom.com/posts/2021/5/03/the-circuits-handbook.)

Mark Dewing 2024-08-19 16:59:02

What is your opinion of Go?

Multi-threading is much more fundamental to the language (and lighter weight). Part of that is how it manages the stack memory for each thread.

(Disclaimer: I don't know Go very well).

Jasmine Otto 2024-08-19 17:35:35

(xpost from substack) What I am hearing is that dataflow notebooks, like ObservableHQ in my case, are a bit of an unholy matrimony between the two styles. FWIW I've been using their 'Runtime' dispatcher as a set of training wheels, given my heavy functional-programming bias. But my experience has been that important quality-of-life tools (map-reduce pipelines) that rely on the call stack are inherently hard to debug under the event-driven paradigm. And this seems to be the kernel of that idea.

Kartik Agaram 2024-08-20 03:42:10

Yeah works for me just now.

(I didn't actually click on it this time because I've read it before πŸ˜…)

Jasmine Otto 2024-08-20 18:35:52

I also got the 404, it's because a . is postpended to the URL. My best guess is that Slack on Windows -> Firefox behaves differently than Kartik's setup. This one works for me:

blog.recroom.com/posts/2021/5/03/the-circuits-handbook

Kartik Agaram 2024-08-20 20:23:23

Ha, I totally misinterpreted which blog link we're talking about. Paul's blog link works fine for me, my recroom link does not. Unfortunately I can't edit that comment anymore.

At least Slack is consistent across platforms.

Paul Tarvydas 2024-08-21 15:58:17

What is your opinion of Go?

I have strong opinions about how to structure component-based programs while retaining both, FIFOs and LIFOs. 0D is but one manifestation of these opinions. Golang comes closer than most other languages but is more like an assembler for component-based programming rather than a structured way to compose component-based programs. ...

Paul Tarvydas 2024-08-21 16:02:09

@Jasmine Otto do you have a suggestion on how I might get a 50,000 foot overview of ObservableHQ and the 'Runtime' dispatcher?

Jasmine Otto 2024-08-21 21:57:25

Paul Tarvydas Yes! They've been shuffling their docs around, especially for the Framework release, so I really hope these don't get lost.

syntax - observablehq.com/documentation/cells/observable-javascript

dispatcher - observablehq.com/@observablehq/how-observable-runs

Kyle Beechly 2024-08-23 20:27:01

I just published Tensort, a family of sorting algorithms (slash research paper?) inspired by Ivan's remark near the end of Beyond Efficiency by Dave Ackley about Robustsort not existing yet. I'd love to hear what y'all think! πŸ’™

Ivan Reese 2024-08-24 04:10:54

This is fantastic. The guiding presence of Sir Michael Caine, the way you introduce terminology, the first step of tensort ( 🀯 ).... what a cool project, and enjoyable write up to go with it.

Ivan Reese 2024-08-24 04:24:48

The tensor part would take me some serious time with paper and pencil to figure out. But the rest is quite straightforward and fun to think about.

Ivan Reese 2024-08-24 04:32:40

Oh my god! I was just thinking about Austin Powers' dad today (the stiff neck joke, as I took an Advil), probably for the first time since that movie came out. I can't even!

Oh and then I read the explanation of Magicsort. This has to be a troll. It's too much!

Eli Mellen 2024-08-24 13:09:01

Me, after reading this ❀

IMG_0152

Kyle Beechly 2024-08-25 01:42:29

Yes!!!!! Thank you!!!! My heart is full:smiling_face_with_3_hearts:

Haha I very nearly used a Scrooge Caine for the Magicsort image!

The tensor part would take me some serious time with paper and pencil to figure out

Yeah it can get hard to reason about (😝) pretty quickly once you get into the higher dimensions. I did a lot of playing with cards and Jenga blocks while working on it😸

I'd really like to make a visualization of it but that will prolly have to wait until after I land a new job

I was just thinking about Austin Powers' dad today

Hahaha certain parts of that movie never leave my psyche ("Nothing could be my father from the truth!", "No I dadn't!")

This has to be a troll

The way I presented Magicsort was 100% a troll directed at you specifically Ivan Reese, I'm not even joking lol. And slightly a jab at the Computerphile guy who couldn't think of any practical applications of Bogosort. I was hoping you'd get a kick out of it 😹

Ivan Reese 2024-08-25 01:45:13

Hats off Kyle. You've made something very cool and technical and fascinating, but also woven charm and joy into its presentation. Beautiful.

Kyle Beechly 2024-08-25 02:05:05

I'm just so happy y'all are enjoying and appreciating it:smiling_face_with_3_hearts: I've had a lot of fun working on it. Thanks everybody, this is such a cool community, I appreciate y'all:heart_hands:

Mariano Guerra 2024-08-24 09:54:44

πŸ“Ό Bootstrapping OOP Part 3: Who Parses the Parser?

How do we feed the prelude if there's no parser (yet)?

πŸ’‘ If code is data then a data serialization format is a binary representation of a program

✍ marianoguerra.org/posts/bootstrapping-oop-part-3-who-parses-the-parser

πŸ“ Bootstrapping OOP Part 3: Who Parses the Parser?

In Bootstrap post-collapse OOP technology with Wasm GC (Part 2) we implemented the minimum viable runtime in raw WebAssembly to run our prelude and bootstrap a basic OOP language. But the prelude was