News for hackers. Stuff that matters.
Re:Unison Programming Language by lisper on Sunday June 27, 2021 @01:39PM (#27653489)
Sounds like a cool idea, but how do you fix bugs in functions with lots of callers?
Re:Unison Programming Language by umvi on Sunday June 27, 2021 @02:06PM (#27653734)
That's basically what the twitter thread I linked explains. It sounds like there is an automatic propagation mechanism for updating downstream callers if the type hasn't changed, otherwise it sounds like a manual update process.
Re:Unison Programming Language by torginus on Sunday June 27, 2021 @02:48PM (#27654105)
Sounds like trading one set of problems for another.
Re:Unison Programming Language by vanderZwan on Monday June 28, 2021 @03:37AM (#27659053)
Tangent: here's what I find fascinating: when we evaluate which algorithm or data structure is best to handle a given situation, we know how to reason about algorithmic complexity and pick a best option for our situation.

But then when it comes to ideas like this we just tend to say "we're trading one set of problems or another", as if we can't evaluate the problems in a similar manner. And I'm not picking on you here, I tend to do the same!

Yes, we're trading one set of problems for another, but what if the old set of problems was "O(n²)" and the new set of problems is "O(nlog(n))"? Or maybe it's the other way around. Why isn't it obviour how to apply those earlier skills here?

Re:Unison Programming Language by nytgop77 on Tuesday June 29, 2021 @12:32AM (#27671791)
I would like to note that even with algorithms/datastructures "best" is USUALLY not the word (even assuming that all algorithms/structures are discovered/known). "Good enough" / "fits in my multi dimensional budget" is reality:

(0) It is easy to order two real numbers. 1 is greater than 0. But can we order points on the cartesian plane (1,2) or (2,1) or (0,100000000000)? Already at 2nd dimension not all points are easily ordered. There is solution "just give priority to 1st coordinate", but can you really completely disregard memory usage and focus solely on cpu?

(1) Theoretically, to get "best", one needs to evaluate not only O(n) of avg cpu usage, and avg memory usage, but also worst and best cases, while using knowledge of input data distribution (e.g. maybe input is almost sorted). Memory access patterns, cache locality, battery life, suitability for your hardware also must come into play. (many dimensions)

(2) Practially one has to do profiling on real hardware with real configurations / inputs / workloads. Different workloads may favor different algorithms/structures. (again results with many dimensions)

(3) Due to constrained time people will not even go over all algorithms. Real people will immediatly rule out really bad ones, then pick 1 or 2 algorithms that theoretically are good enough match, and see if their profiling results fit in cpu/memory budgets. (even if budget is not on paper, but just part of intuition)

Re:Unison Programming Language by capableweb on Sunday June 27, 2021 @04:07PM (#27654814)
Welcome to software engineering where there is no golden bullets, only different tradeoffs :)
Re:Unison Programming Language by nytgop77 on Tuesday June 29, 2021 @01:12AM (#27672044)
There are also circles of hell. (opposite of silver bullet)
Re:Unison Programming Language by aparsons on Sunday June 27, 2021 @04:07PM (#27654815)
Law of conservation of complexity
Re:Unison Programming Language by acjohnson55 on Sunday June 27, 2021 @01:41PM (#27653504)
The same way we do now: release a new version and tell people to migrate.
Re:Unison Programming Language by lisper on Sunday June 27, 2021 @01:48PM (#27653566)
No, now I can just redefine the buggy function and all the callers will get the new version automatically. Having to update all callers seems like a high price to pay. Seems like the Right Answer is something like a hash of the api or the contract rather than the implementation.
Re:Unison Programming Language by ucarion on Sunday June 27, 2021 @01:54PM (#27653633)
The (public) name of the implementation is the unique identifier of the contract in most systems, so I think your "Right Answer" is roughly the status quo?
Re:Unison Programming Language by ajuc on Sunday June 27, 2021 @02:07PM (#27653735)
Nope, according to https://twitter.com/unisonweb/status/1173942969726054401

when you change a function implementation the system has to walk the callers graph backwards starting from all the places where the function was called updating all the implementations with the new hash, then callers of these with the new implementation and so on up to main (or whatever it's called).

I had a chance to implement something like this in a system that used jbpm 3 graph language (basically process X version 1 called process Y version 1 and I updated process Y to version 2). It's nontrivial especially with recursion, I'm wondering how they are dealing with that.

Re:Unison Programming Language by lamontcg on Sunday June 27, 2021 @03:01PM (#27654229)
A git-like datastore for your AST+callgraph.
Re:Unison Programming Language by ajuc on Sunday June 27, 2021 @03:11PM (#27654313)
Let's say you have definitions like that:

    f: Nat -> Nat
    g: Nat -> Nat
    h: Nat -> Nat
    h x = g (x * 2)
    g x = f (x * 3)
    f x = x < 0 ? 1 : h (x / 4)
And now you change f to be

    f x = x < 1 ? 1 : h (x / 4)
How do you do that? There's a cycle in the callgraph. In fact - how do you calculate a hash of a function that calls itself if you need its hash to calculate its hash :)

EDIT: nevermind, recursion is a special case handled differently.

Re:Unison Programming Language by lisper on Sunday June 27, 2021 @01:59PM (#27653680)
No. The name of a function in current languages has no connection at all to what the function does. (What would be the contract for a function named ‘foo’?)
Re:Unison Programming Language by gbhn on Sunday June 27, 2021 @02:28PM (#27653928)
That's kind of the thing that makes APIs possible, right? It sounds to me like "what if programming were done in a completely flat global namespace in which abstractions, encapsulation, and structure were impossible."
Re:Unison Programming Language by lisper on Sunday June 27, 2021 @03:15PM (#27654357)
No. An API specifies more than the name of the function. It will specify the arguments, their types, the type of the return value, and at least informally, what the function does. You can change the underlying implementation without changing the API. That's the whole point of an API. The problem with current API technology is that the informality of the spec of what the function does. That allows some aspects of the behavior of the function to change without triggering any warnings.

By having the linker work on hashes of implementations you eliminate that problem but create a new problem. You can no longer change the behavior of the function because you can't change the function. That means you can't suddenly change behavior that some caller is counting on, but it also means you can't fix bugs without changes in the caller.

Re:Unison Programming Language by tgbugs on Monday June 28, 2021 @01:04PM (#27664442)
Reading this now, I'm imagining all the horrors of static linking but applied to every function instead of whole modules.

Maybe the simplest solution is to allow the function to change to the new version, but make it easy to revert in the event that something breaks. This of course means that you can't make the names of the functions their hash (without lying, preventing the runtime from checking that hashes ways match, or modifying emitted bytecode or native code to do what you want), it has to be an orthogonal layer on top of them like types (as I mentioned elsewhere in the thread).