News for hackers. Stuff that matters.
Re:Show HN: ScrapScript – The Sharable Programming Language by thrrwy007 on Friday April 28, 2023 @09:00AM (#35740752)
everyone says this is cool, but I didn't understand it at all, so embarrassing :(( please eli5, honestly, want to understand this, what is this and how is it useful?
Re:Show HN: ScrapScript – The Sharable Programming Language by evilspammer on Friday April 28, 2023 @10:40PM (#35749521)
To over simplify & risk that I misunderstand, it is "just" content addressible storage for code.

The code fragments are hashed and the hash is used to refer to the code fragment. So instead of writing this code with explicit names:

    let functionA = (x) => x;
    let functionB = (y) => functionA(y) + 1;
You can look at the function bodies and hash them (this part is drastically simplified): `(x) => x` has a MD5 of `3bebbe46355493ecc5f6b6c9bb7e9db7`. So rather than calling `functionA` inside of `functionB` you would define `functionB` as `(y) => 3bebbe46355493ecc5f6b6c9bb7e9db7(y) + 1`. The hash of that function would be `51e272dc500e6a58889dde88ec1057fd`.

To name the functions, you can assign the hashes human-readable labels.

    let functionA = (x) => 3bebbe46355493ecc5f6b6c9bb7e9db7;
    let functionB = (y) => 51e272dc500e6a58889dde88ec1057fd;
The author states that when you refer to a name, it will always download the latest version. So, once you define the names, your program is effectively the same as how things work in conventional languages right now, using names and not hashes.

The difference is that the entire tree of functions is hashed. If `functionB` refers to `functionA` and `functionA` is updated to have different behavior, things can break. But if `functionB` calls `3bebbe46355493ecc5f6b6c9bb7e9db7` rather than `functionA` then you know that `3bebbe46355493ecc5f6b6c9bb7e9db7` will always be `(x) => x` and it won't change out from under you.

Hope this made sense, it was eliJS rather than eli5.

Re:Show HN: ScrapScript – The Sharable Programming Language by will5421 on Saturday April 29, 2023 @12:55PM (#35754680)
One cool thing, I think, is that you can do

import foo/bar

And foo's bar library will just work in your program without you having to download it then bundle it. It will just look for foo’s bar library online when it runs (and I guess it’ll be running on an online platform, not necessarily on your own computer).

Re:Show HN: ScrapScript – The Sharable Programming Language by ivanjermakov on Saturday April 29, 2023 @09:18PM (#35758864)
Sounds quite dangerous...
Re:Show HN: ScrapScript – The Sharable Programming Language by surprisetalk on Saturday April 29, 2023 @09:28PM (#35758910)
It's only dangerous in very predictable circumstances :)

Type-safety guarantees that you won't get any side-effects where the types don't fit.

And if you really want to run untrusted code, scraps are designed to be very easy to inspect :)