back
▲ 503 points

Show HN: ScrapScript – A tiny functional language for sharable software

scrapscript.org
by surprisetalk·3y ago·135 comments·view on hn ↗
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 :)

135 comments
So it's like a social network with every type of relationship imaginable built into a low level programming language?

That's wildly cool.

This and Val Town [0] feel like they were made for each other. If you added them together with a nice front-end like mmm.page [1] I bet a million devs would sign up.

I'm working on something in a similar space that I'm hoping mihht develop into that [2]

It makes sense that the next step for the web is a more low-level social platform that works more like an agnostic API than a walled garden.

[0] https://www.val.town/

[1] https://build.mmm.page/

[2] https://hyperspace.so/

Wow, you totally get my vision!

This is pretty much my plan for the next few years, with some added surprises :)

I really want to rekindle the days of geocities and flash. I call this "the cheap web" haha

I've also been working on open standards for authentication and payments within the ecosystem, but I'm not quite happy with the results yet. I don't like this world where we have to use companies like Auth0 and Stripe to build something worthwhile. I'm open to ideas!

Heyyo. Creator of mmm.page here. Fun to see it mentioned. In case it's of interest, I've been coming at this from a more GUI perspective: scriptable objects (like paper) [1] and social primitives [2].

Excited to see where this project goes.

[1] https://paper.mmm.dev/

[2] https://twitter.com/xhfloz/status/1611094168981458981

The signal to noise ratio in your comment is off-the-charts awesome – thank you for the amazing links!!
Thank you I've been trying to find the build.mmm.page link again for a year but I couldn't remember the name of the site XD
Thanks for these links. Looks like I have a new rabbit hole to explore!

Side note: I was just watching the val.town video and at the end he mentions that "you are an object" and other people can access your properties. It immediately made me think of playing hackmud. Not sure if that's a good thing or bad!

> https://build.mmm.page/

The stuff there looks like a "MySpace 2.0".

And that's not a compliment.

Reminds me of what unison already does, I just wonder what will be license and scope

https://www.unison-lang.org/

I'm still not sure about the exact license yet, but everything will definitely be free and open :)
In your styles:

> pre { overflow-x: scroll; }

`overflow: scroll` is very poorly named, and practically never the right tool. You want `overflow: auto` instead, which only renders scrollbars if they’re needed.

(Long ago, there were two potentially valid scenarios for it: for avoiding reflow when changing the document’s length, and for unbreaking viewport units so that 100vw includes the viewport’s vertical scrollbar. The former was only exceedingly rarely useful, and can be achieved better now on all but Safari with the scrollbar-gutter property. The latter only Firefox ever implemented, and no one else wanted to, so they eventually removed it from the spec and from Firefox, so now viewport units are just stupidly broken by design. I myself have not found a single place I wanted to use `overflow: scroll` or where it would have been reasonable in the past decade. Stylesheet linters should include a default rule that complains about `overflow: scroll` because it’s so temptingly-named but so thoroughly not what you want.)

It’s the right tool when you prefer scrollbars to always be rendered, which is a valid preference. For example, in the “not needed” case, the scrollbar being rendered tells you at a glance that there’s no scrollable content with a hidden “only appears upon movement” scrollbar, an information which would otherwise be missing.
It's late and I'm tired but this is one of the most interesting things I've seen in a while.
Would the IPFS-ness of this make updating all the programs that suffer from an exploit or error a difficult thing? Kind of like smart contracts, once it is published, there is no changing it? So the chain of dependencies containing the exploit or error, make updating all of the consumers a pain.
This is a great observation.

By default, using a name like `janedoe91/fibonacci` pulls the latest version of that particular scrap from the scrapyard. But all of its references are baked-in unless the author updates them.

The way around this is that consumers are empowered to use whatever forcing upgrade strategies they want. All scraps are transparent, so you can pipe everything through an "upgrader" scrap before execution, which replaces dependencies all the way down the stack with their latest versions. I'm sure many of these upgraders will exist depending on what types of tradeoffs you're looking for.

I like the unique hash thing like Unison, but it also has an Urbit/Nock/Hoon vibe aside from IPFS one you mentioned. I'll check it out tomorrow. Ilike the examples and syntax. Types - yay!
Why the custom language? Building a language is already a lifetime project on its own

As I see it most of the more unique ideas could be implemented in form of some tooling on top of some existing languages.

What do I overlook here?

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?
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!
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

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?

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.
I'm trying to wrap my head around the "magic compression" bit. So literally every namespace lives in a repo somewhere? And even files referenced are just automatically committed to that repository? What am I missing?

Also how does this not create either an enormous tangle of circular references or a huge pile of unused... scrap?

This is very cool. I have similar goals with my own language. Though I am developing only and AST and no syntax because I would like to be able to embed the same language into visual programming environments.

https://petersaxton.uk/log/

Since each function is independently versioned, how does ScrapScript deal with functions that need to upgrade together?

For instance, suppose "foo" produces a structure and "bar" consumes it - what happens if the user passes the output of "foo version 10" to "bar version 1"?

Very interesting! I'm especially curious on how the live-coding experience plays out.

I wish there was an example of a moderately-complex scrapbook, so that I could see what the code looks like when you start mixing several scraps and need a minimum of scaffolding.

This is fantastic. I can't count the number of hours I've wasted hacking away broken CI pipelines to fix broken links, passing data around through environment variables sorcery, runners and artifacts wizardry.
One question. If you reference a package by hash. Is there semantic versioning? Can you get security updates?
Not 100% sure but there is another project with similar ideas https://www.unison-lang.org/
I don't get it. Can someone use an example to demonstrate the value of this?
This is perhaps too bright for the gloom of recent months here.

Thanks to the author, this is a very exciting thing.

Of course, ligatures without the "disable ligature under a cursor" extension are slightly weird, but it even adds charm, we're on a site "for hackers" (laughing).

So, well, what kind of a ChatGPT can come up with something like that? :)

This is incredible. I’ve been thinking a lot about personal software systems and a hypothesis that I have is that simpler code sharing/versioning mechanisms is key to greater agency in programming environments. I’m already a huge fan of unison (we had Rúnar on devtoolsfm) so I’m eager to explore scrap further.
Neat but... Someone will make a crummier version of this in a language which doesn't feature parts looking like Unicode white noise and the original authors will be frustrated why the crummier vetsion took off and their project didn't.

Not every idea deserves to have an esoteric language attached to it to work.

Looks fun, but doesn't look like it will be open source. That's a shame, since it considerably raises the risk of adopting such a platform.

EDIT: the author claims that it will be open sourced soon :)

Neat!

Maybe check out the Joy programming language? It seems well-suited to this domain.

Looks extremely fun. Coming from nix background, content addressability of stuff is a huge win. Looking forward to be able to play with this.
If you have any measure of success, you are 100% going to wind up with a thing in your ecosystem called "scrappy do"
This is awesome. I had a shell of an idea like this that never got anywhere. Wasn't even sure if it were feasible. Really neat!
I haven't fully understood this. Is this a way to share code? Where are the functions executed?
Would you mind publishing a EBNF or similar grammar spec? That would make the syntax clearer.
Would love to see more of the type system described.

If each scrap carries its own versions of its dependencies, then even the "same type" could actually be a "different type" because of version mismatches?

I like the high level ideas and goals. I still have to get my head around the syntax and how it works in practice but will definitely keep an eye on this!
Surprised, none of the more functionally minded have jumped in. Looks interesting, I'll be taking a look, when it ships.
This looks like a fun thing!

It makes me feel like some hacker dweebs in the future would be communicating through this platform.

Did I miss the reference to the license?

Looks interesting though. Would like play with this when it's released.

Super cool!!
This is nuts and incredibly cool.
Looks fun!
Is this meant to be understood by geniuses or something? I'm halfway through reading about it and I still have absolutely no idea what any of this remotely means. Is the target audience for this genius hipsters who have 10,000 years of boilerplate context to even grok what the author is saying?