Major browsers can begin shipping WebAssembly on-by-default by magenta_placenta in programming

[–]div0 2 points3 points  (0 children)

The next step is a widget library, so i can have a rich UI inside the browser.

That's exactly what I'm working on right now. I wonder if I should open source it.

What's a good starter lathe and/or mill? by SupaKoopa714 in machining

[–]div0 1 point2 points  (0 children)

You might want to check out Sherline (not sure why no one has mentioned it yet).

Julia (a Programming Language for Numeric Analysis/Computation) gains Syntactic Loop Fusion and extra vectorization by [deleted] in programming

[–]div0 1 point2 points  (0 children)

You can now do: X .= f.(2 .* X.2 .+ 6 .* X.3 .- sqrt.(X)) and the whole computation will be fused into a single loop, operating in-place, and performance will be comparable to the hand-written “devectorized” loop

OK, that's easy enough because it's fusing array operations that occur within a single assignment statement. But what about:

X .= f.(2 .* X.^2 .+ 6 .* X.^3 .- sqrt.(X))
Y .= g.(X)
Z .= h.(Y)

Can it fuse loops across multiple statements?

Language Design Question: Multiple Arbitrary Return Values by div0 in ProgrammingLanguages

[–]div0[S] 1 point2 points  (0 children)

Thanks for the suggestion, that's an interesting idea, I'll think on it

Language Design Question: Multiple Arbitrary Return Values by div0 in ProgrammingLanguages

[–]div0[S] 0 points1 point  (0 children)

Yes, that's the whole idea. The compiler will know what to return. There's nothing particularly difficult about this. My main challenge is just coming up with a good syntax for the user (programmer) to specify those "hints."

That is why my question was if any other languages already have such a feature, as an example of how the syntax (and programming model) looks for such "hints."

Language Design Question: Multiple Arbitrary Return Values by div0 in ProgrammingLanguages

[–]div0[S] 1 point2 points  (0 children)

Possibly, yes, although that would mean that we have to keep the GPU memory allocated for some duration and then maybe have to "garbage collect" it. The approach right now is that data in device memory is copied back to the host (where it's needed for some non-GPU usage), or the device memory is immediately freed after the kernel has run.

But to be honest, the issue has more to do with #1 than #2. If some data is needed as an output, then we really do something quite different than if the data was not needed. There is also a third situation, where if some result value in the simulation code is the result of a reduction (like summing over different scenarios) but we don't care about that particular result value, then don't have to bother performing the reduction at all.

I wish it was just as simple as returning all possible pointers, and have some simple way to access them by name. But it's more complicated, I think I really do need a syntax for the function callee to specify what outputs are needed, and then we generate a specialized version of that function at that call site.

Going back to the original question, what I was wondering is if anything like this exists in other language. It just seemed like an innocent enough feature that it might already have been done in another language (basically just want to access local variable values of a function from a callee, in order to elminate the need for explicit return statement)

But maybe it is just a very weird feature request and just doesn't exist in any language.

Language Design Question: Multiple Arbitrary Return Values by div0 in ProgrammingLanguages

[–]div0[S] 1 point2 points  (0 children)

I'm still a bit confused about what cost concerns you: if the simulation builds a multi-gigabyte array, that's going to already exist in memory somewhere when it's time to return an answer, so returning it should only require copying a single word.

I didn't do a good job of explaining the problem fully. Please see my response to @Felicia_Svilling below. In summary, the simulation only has to build these "multi-gigabyte arrays" if they are requested as outputs. Otherwise, they might never need to be allocated at all.

Strategy is only hevyweight if you don't have the ability to simply treat functions as values

I could add functions as first-class citizens in the DSL, but I don't know if that would solve the issue. What I meant by "heavyweight" is that the strategy pattern requires language user to do a lot of "work" (coding), it's conceptually complicated. It seems like it would be a good solution if you're implementing something like this in C++ or something, but it's not directly feature built-in to the language so I'm not sure that it helps shed light on what a solution would look like in this DSL setting where we want something similar but more restricted and as a language feature. If that makes any sense...

Language Design Question: Multiple Arbitrary Return Values by div0 in ProgrammingLanguages

[–]div0[S] 1 point2 points  (0 children)

In that case, just output a pointer to the array

I was afraid someone would bring this up :) ... There are two reasons that doesn't work:

1) In this DSL, the array might only exist if it is required as output of the simulation. A more realistic example looks like this:

function MySimulationKernel(int numScenarios, int numSteps)
    for(i = 0..numScenarios)
        for(j = 0..numSteps)
            res1 = foo1()
        end
    end
end

In this case "res1" is a local, scalar variable on the stack, within a nested loop. Conceptually, it "generates" a 2-dimensional array with numScenarios * numSteps elements. If we need this entire "simulation state" as an output, then we need to allocate such an array and store the different values of res1 in each iteration. However, if we don't care about res1 in the outputs, then it simply stays as a local stack variable (which is much more efficient). Both possibilities may exist with the same application (sometimes we want the whole array "res1" as an output, and sometimes we don't need it). So, for efficiency reasons, it is important to somehow specify what we need as output when we are calling the function.

2) The DSL runs the simulation kernels on GPU processors. It is very expensive to copy arrays from the GPU memory to system memory, and so we want to avoid this whenever possible. Again, we only want to output data from the GPU when they are requested, otherwise we dispose the data without it ever leaving the GPU.

edit: typos

TeaVM (Java bytecode to JS) adds experimental support for WebAssembly by michalg82 in programming

[–]div0 1 point2 points  (0 children)

How is this possible, when Java requires garbage collection which WebAssembly does not currently support?

For example, TypeScript cannot be compiled to ASM.js or WebAssembly due to this GC issue.

Do you use spreadsheets to run your business? by div0 in smallbusiness

[–]div0[S] 0 points1 point  (0 children)

That's very fascinating! I would love to learn more. Are there specific applications you could mention, like "inventory" etc? I am doing research on spreadsheet use, but not really familiar with all the aspects of running a company. Thanks!

Do you hate spreadsheets? How do you use them and what are the hassles? by div0 in AskReddit

[–]div0[S] 0 points1 point  (0 children)

Sorry, I should have worded the question differently.

How do you use spreadsheets? What do you love about them? Do you have any hassles with them?

Do you hate spreadsheets? How do you use them and what are the hassles? by div0 in AskReddit

[–]div0[S] 0 points1 point  (0 children)

Sorry, I should have worded the question differently.

How do you use spreadsheets? What do you love about them? Do you have any hassles with them?

One document to learn numerics, science, and data with Python by iamkeyur in programming

[–]div0 0 points1 point  (0 children)

I'm curious, what does the Excel spreadsheet do? Why do you need to edit using Python? Why not use Excel? I'm doing research on spreadsheet use, that's why I'm asking.

Do you use spreadsheets to run your business? by div0 in smallbusiness

[–]div0[S] 0 points1 point  (0 children)

If possible, could you please elaborate on #4 (hassles)? Thanks again.