Lurker News
Hi friends,

I started casually working on scrapscript in 2015. I built a few compilers over the years to test out various ideas/implementations, and I think I'm finally happy with the overall design.
The code is not public yet. Email me at hello@taylor.town if you're interested in joining the core team later this year.
Let me know if you have any questions or feedback :)

Comments (135) 41 threads

Earlier comments
zubairq#
Author of a framework that also stores it's code in IPFS for easy sharing (https://github.com/yazz/yazz). ScrapScript is a really nice concept with how it stores code. I originally got the idea for storing the code as a hash of the contents from Unison, and it looks like the idea is really starting to catch on with more and more languages now. Well done!
sagebird3 replies#
This is lovely. I’ve had a vague notion that I wanted something like this… but never quite solidified my understanding of what is necessary. This is a super minimal-maximal example. Bravo.

Do equivalent programs produce the same hash?
Ie: a = 1 + 1 Return a
Vs
a = 2 Return a
What if local internal variable names change?
Ie
b = 2 Return b

surprisetalk1 reply#
This is one great question I've wrestled with over the years.

Right now, all three programs would result in a different hash. I decided that the scrapyard publication process should do as little "magic" as possible.
As the tooling evolves, we can provide a canonicalizer scrap that renames variables and simplifies the code. I think eventually we would make this the default process to encourage more reuse.

alephaleph1 reply#
You might want to look into the way Unison does things: [1], they've got a lot of similar ideas and IIRC the way their hash system works avoids that ambiguity.

[1]: https://www.unison-lang.org/learn/the-big-idea/

surprisetalk1 reply#
Wow, that's a great guide!

I didn't read it in-depth yet, but I think I had a previous implementation that worked very similarly to theirs.
The problem with variable names is that they actually matter for some of the collaborative editor features I hope to implement in the future. There are certain assumptions I can't make quite yet, and so am keeping my options open :)

Continue this thread — 1 reply

sagebird#
Thinking a bit more:

A-If a program is a thing that produces a result for a given input, these programs are the same.
B-You can’t generally know if two programs are the same without solving halting problems, reducing polynomial algos to linear time or having infinite time and space computing resources, etc.
C-The best you can do is ask if two compilers produce the same output, or a linting/refactoring/canonicalization/formatting operation results in same source.
D-If a program is a thing that interactive debuggers use to create explorations next to source code while computing, these programs are different.
I agree with your approach of starting with these programs as being different, and allowing custom scraps to become a higher layer hash resolver. The reason is that compilers change over time, and it is only under the lens of a compiler(or linter, etc) that comparisons can be made. To bake a holy compiler in today would be arbitrary and quickly outdated.

xigoi1 reply#
Due to the halting problem, it's not possible to tell in general if two programs are equivalent.
amelius1 reply#
As far as I know, nobody ever proved that some programs for which halting cannot be determined are smaller in size than the number of atoms in the universe. Or in other words, that the theorem applies to practical programs. It's purely theoretical.
xigoi10 replies#
Here is a Python program which is definitely smaller than the number of atoms in the universe. Can you tell me whether it halts?

  n = 1
  while sum(d for d in range(1,n) if n % d == 0) != n:
      n += 2

Continue this thread — 10 replies

substation133 replies#
Hello!

This looks really interesting to me.
There is a feature I would like that I have never seen in a scripting language, and I wonder if Scrap might support it:
> Monadic bind points and applicative join points in the script language
Hopefully an example can convey what I mean.
Bind:

    do {
      let! x = some_value_in_a_monad

      x + 1
    }
Applicative:

    do {
      let! x = some_value_in_a_monad
      and! y = another_value_in_a_monad

      (x + y) * y
    }
Now when I embed this script, I would like my runtime interpreter to provide implementations of `let!` and `and!`. The script author defines the bind points and the runtime defines the effects.

Is this possible in Scrap?

surprisetalk1 reply#
Wow, I really like that syntax!

Juggling lots of monads can be annoying. But to keep scrapscript small like json, this is something I would try to solve with editor tools rather than the language itself.

substation131 reply#
How should users write async, futures, option, result, etc. in Scrap?

My hunch is that if you do not put the syntax into the language, then it will be hard for the community to standardize on one preprocessing tool.
OCaml (which I am a fan of!) struggles with fragmentation here.

surprisetalk#
With managed effects, all of the async stuff gets pushed over to the platform.

I suspect that everybody will settle on a reusable `task` type, but each platform can determine its own async scheduling system.
Consider this example:

  | "/home" -> q -> res:success <| "

howdy " ++ name ++ "

" , name = q |> dict/get "name" |> maybe/default "partner" | "/contact" -> _ -> res:success "email" | _ -> _ -> res:notfound "

not found

" . res = : success text : notfound text
In this case, the platform creates a simple web server from the following type:

  text => query => res
  . res = : success text : notfound text
Because scrapscript stays out of the scheduling game, the platform is free to run this code on as many cores and servers as it wants in parallel.

But I 100% agree that community standardization is incredibly important! I just don't have a solution yet :) I will try my best to get everybody to work together though haha

debugnik#
Stricly speaking, F# can be used in scripts too, which is where I think you've taken that syntax from. Ionide however is quite broken when writing scripts (or anything else) though.
motohagiography#
This is significant. There's so much I want to add, but I will wait until I can implement the things I needed this for in the actual code.

Load more comments