Live data from Hacker News

Vine: A programming language based on Interaction Nets

vine.dev

41–50 of 51 posts

Re: Vine: A programming language based on Interaction Nets

#41
post #3

"This function calculates the minimum of a list of numbers, and subtracts every number in the list by that minimum. This function currently iterates over the list twice; once to calculate the minimum, and once to do the subtraction. At a first glance, it looks like there is no way to merge these two loops, because you need to calculate the minimum of all the numbers before you can subtract from any of them. As it tur…

I think that `inverting` also subsumes async functions/values, which is pretty neat!

In the case where asynchrony was actually necessary, it seems like a great alternative to function coloring.

But whether you should actually use it for something like their `sub_min` example is highly dependent on how good the performance of their implementation is. Creating a graph of references rather than making two passes over an array of integers is not clearly faster ... or clearer, for that matter.

Re: Vine: A programming language based on Interaction Nets

#43
post #33
post #13

It starts off looking like a slightly modified Rust until about half way through where it gets real weird. It’s burying the lede… why not open with what interaction nets are and why you’re building them into a programming language? Made my head hurt a bit, it’s odd that it doesn’t really attempt to contextualise if the weirdness is for its own sake or some greater practical purpose. Always fun to find a novel way to…

Yeah I don't know enough rust to know what's special here. Presumably the inverse backwards part. I retain that every project (language, application, etc) should start with what it is, what it looks like (code or screenshot as appropriate), and why it matters. This felt very implicit in that. And, I'm still not sure how that wacky stuff gets compiled down. It looks like syntax sugar as a language.

I think the "backwards in time" aspect can most easily be understood as a consequence of (A -> B) being the same as (~B -> ~A). That is, if you know how to go from A to B, then instead of requesting B it's enough to request A. Though this can be applied more generally to a "logic of resources" which then also requires multiple varieties of the "struct" and "enum" construct, depending on whether the "producer" or "requester" side is making a choice.

Re: Vine: A programming language based on Interaction Nets

#44
post #3

"This function calculates the minimum of a list of numbers, and subtracts every number in the list by that minimum. This function currently iterates over the list twice; once to calculate the minimum, and once to do the subtraction. At a first glance, it looks like there is no way to merge these two loops, because you need to calculate the minimum of all the numbers before you can subtract from any of them. As it tur…

I was thinking it must be possible to do something semantically similar in Prolog: find_min_and_subtract([H], [R], Min) :- Min = H, R is H - Min. find_min_and_subtract([H|T], [R|Rs], Min) :- find_min_and_subtract(T, Rs, TailMin), (H Min = H ; Min = TailMin), R is H - Min,!. Which [9,4,12,2] -> [7, 2, 10, 0]. But this doesn't work for all cases anyway (just the ones where the last value is also the minimum). I feel it…

Prolog also has constraints! You need to import a library called CLP(FD) / CLP(Z) (depending on the Prolog system) and instead of =,
    :- use_module(library(clpfd)).

    min(Min, Y, Min) :- Min #=
With that (and an additional variable for the temporary minimum) it works for me:

    ?- find_min_and_subtract([9,2,4,12], Rs, Min).
    Min = 2,
    Rs = [7, 0, 2, 10]
https://swish.swi-prolog.org/p/qgchfMfB.pl

Re: Vine: A programming language based on Interaction Nets

#45
post #44

Earlier quoted context omitted.

I was thinking it must be possible to do something semantically similar in Prolog: find_min_and_subtract([H], [R], Min) :- Min = H, R is H - Min. find_min_and_subtract([H|T], [R|Rs], Min) :- find_min_and_subtract(T, Rs, TailMin), (H Min = H ; Min = TailMin), R is H - Min,!. Which [9,4,12,2] -> [7, 2, 10, 0]. But this doesn't work for all cases anyway (just the ones where the last value is also the minimum). I feel it…

Prolog also has constraints! You need to import a library called CLP(FD) / CLP(Z) (depending on the Prolog system) and instead of =, :- use_module(library(clpfd)). min(Min, Y, Min) :- Min #= With that (and an additional variable for the temporary minimum) it works for me: ?- find_min_and_subtract([9,2,4,12], Rs, Min). Min = 2, Rs = [7, 0, 2, 10] https://swish.swi-prolog.org/p/qgchfMfB.pl

OW! Thanks, I did not know about that. Last I user Prolog was mid 90s, but I really liked it, just did not have any practical use for it after graduation. Thanks for that!

Re: Vine: A programming language based on Interaction Nets

#46
post #38
post #34

Earlier quoted context omitted.

I would love a better explanation for `~~x = x`. I first understood `~x` as an equivalent of an unresolved future. Would one be able to model `~x` with, say, Rust channels?

In interaction nets, one of the core primitives is the 'wire', which form the edges in the graph. One can think of a wire as like a one-shot channel; it has a 'producer' side, which sends some value across, and a 'consumer' side, which does something with that value. In that context, then, the inverse operator switches which side of the wire you're talking about. If you have a parameter of type `N32`, you're on the '…

What happens when a variable is assigned more than once?

Re: Vine: A programming language based on Interaction Nets

#47
post #38
post #34

Earlier quoted context omitted.

I would love a better explanation for `~~x = x`. I first understood `~x` as an equivalent of an unresolved future. Would one be able to model `~x` with, say, Rust channels?

In interaction nets, one of the core primitives is the 'wire', which form the edges in the graph. One can think of a wire as like a one-shot channel; it has a 'producer' side, which sends some value across, and a 'consumer' side, which does something with that value. In that context, then, the inverse operator switches which side of the wire you're talking about. If you have a parameter of type `N32`, you're on the '…

Is it possible to put the 'producer side' into a 'consumer side' of another wire?

Should ~ be considered part of the type signature? Does `let ~x = y` work as destructuring?

Re: Vine: A programming language based on Interaction Nets

#48
post #2

I first heard about interaction nets from HVM [1]. It sounds very interesting but I can't say I get it. [1] https://higherorderco.com/

I am very interested in the work they are doing with Bend and Kind, but right now, I am just confused as to what language is actually being actively developed. As I see it, right now they have HVM3(the runtime), Bend, Kind, Kind2, and some other stuff. No idea how all of that is supposed to tie in together.

Re: Vine: A programming language based on Interaction Nets

#49
post #47
post #38

Earlier quoted context omitted.

In interaction nets, one of the core primitives is the 'wire', which form the edges in the graph. One can think of a wire as like a one-shot channel; it has a 'producer' side, which sends some value across, and a 'consumer' side, which does something with that value. In that context, then, the inverse operator switches which side of the wire you're talking about. If you have a parameter of type `N32`, you're on the '…

Is it possible to put the 'producer side' into a 'consumer side' of another wire? Should ~ be considered part of the type signature? Does `let ~x = y` work as destructuring?

> Is it possible to put the 'producer side' into a 'consumer side' of another wire?

Yes; you can take the producer side of an `N32` wire `x` and link it to the consumer side of an `N32` wire `y`; that just means that the value that is sent across `y` will be sent across `x`.

> Should ~ be considered part of the type signature? Does `let ~x = y` work as destructuring?

In `let ~x = y`, the `~` is part of the pattern, and is destructuring, yes. So assuming `y` is some `~N32`, that statement declares a new variable `x`, with no initial value, and whatever the final value of `x` is, that's what passed along the wire. So re: what happens when a variable is assigned more than once, the last assignment wins.

Re: Vine: A programming language based on Interaction Nets

#50
post #33

Earlier quoted context omitted.

Yeah I don't know enough rust to know what's special here. Presumably the inverse backwards part. I retain that every project (language, application, etc) should start with what it is, what it looks like (code or screenshot as appropriate), and why it matters. This felt very implicit in that. And, I'm still not sure how that wacky stuff gets compiled down. It looks like syntax sugar as a language.

I think the "backwards in time" aspect can most easily be understood as a consequence of (A -> B) being the same as (~B -> ~A). That is, if you know how to go from A to B, then instead of requesting B it's enough to request A. Though this can be applied more generally to a "logic of resources" which then also requires multiple varieties of the "struct" and "enum" construct, depending on whether the "producer" or "req…

I guess I'm just not understanding the minimum subtraction example. They claim it only loops through the array once, and I see that in the code, but I don't see how that's possible. In Python land I can certainly do [x - min(v) for x in v] and maybe that looks like I'm only going once but really I'm not. Maybe I'll fire up the compiler and check the resulting code.

I guess I'm still in the edit window. I installed it. Naturally once of its hundreds of dependencies needed a newer rustc than the 22.04 PPA but whatever, got that sorted. Turns out it doesn't compile down into assembly but if I'd kept reading I would've seen that it goes to Ivy, an intermediate language that's run later. Running the example gives:

> vine run vine/examples/sub_min.vi [1, 0, 4, 6]

Interactions Total 948 Annihilate 491 Commute 21 Copy 88 Erase 102 Expand 142 Call 63 Branch 41

Memory Heap 1_184 B Allocated 19_520 B Freed 19_520 B

Performance Time 0 ms Speed 6_245_059 IPS

Apparently the stats are default. Which makes this feel like a toy but again, whatever. Running that first way gives:

Interactions Total 1_069 Annihilate 562 Commute 21 Copy 96 Erase 114 Expand 163 Call 67 Branch 46

Memory Heap 1_184 B Allocated 22_000 B Freed 22_000 B

Performance Time 0 ms Speed 7_088_859 IPS

IPS seems quite variable at this small an input size. So my conclusion is: if it helps one write code better, go for it. Who cares. But this certainly doesn't seem like some magic bullet that doesn't need to go through the array twice. The ivy code is not very human friendly so I couldn't wrap my head around what it's actually doing, but it looks like it's a bunch of functional programming. It really does look quite slow and mathematically pure. So as a math toy I think it's doing a good job.

Post reply on HN