Today in prototypes that worked too well: Sheety!

What is a spreadsheet? It’s a bunch of nodes tied with dependencies. Some of the nodes are pure data, others are code.

It’s a DAG. And you know who has wrote library that processes DAGs as tasks? This guy! it’s called Croupier.

So, some cells are just a value with a key: Sheet1!A1 => 42

Other cells are code: Sheet1!A2 => =A1+2

But of course the code is in “Excel formula language” … how if there was a parser for it? There are a bunch. I liked one called “formulas” in Python. So I ported it to Crystal, and that creates a AST.

Of course one can use a AST to generate code. So it could generate Crystal code. Which could be defined as Croupier tasks. Of course the parser knows EXACTLY the dependencies. So the tasks can be wired to do the right thing.

So then you can compile the “spreadsheet” into a program.

And the cells that are just data don’t need to recompile the program, they are just data, you update, then croupier reruns ONLY the tasks that need running, updating ONLY the cells that need updating, and can even do that on multiple threads.

So … GitHub - ralsina/sheety: Playing with spreadsheet ideas

Here’s an example of it in “action”:

9 Likes

Why the hell not. Huge props to @omarluq and his termisu shard.

asciicast

3 Likes

Oh hell yes!! :fire:

1 Like

Wow why did I not know that a spreadsheet is a DAG! In retrospect after reading your breakdown it makes lots of sense but I guess I never thought about this :exploding_head:

1 Like

Actually they cheat because they use position to break loops.

If A1 -> A2 -> A1 They are not going to loop, they stop at loops :-)

1 Like

Ha, that’s such a pragmatic way to tiebreaker and move on. Side note: great distro choice with EndeavourOS :eyes: :fire:

1 Like

Ok, it now supports editing cells (no recompilation) and formulas (automatic recompilation) mouse click, double click, and wheel events, and so on (ui branch). TBH it’s a state of the art spreadsheet for 1984

I am shocked this went this well in … about 6 hours of work?

2 Likes

For the spreadsheet lovers, may I recommend some resources? They have been a game changer for me

Something I wanted to have in the past is a spreadsheet engine that would allow overlays. As in I have a spreadsheet and I can open multiple working sessions on it, in memory, and apply some changes each session while sharing common resources. Not starting from scratch motivates me, now I just need … time :-P

1 Like

Spicy!

image

I feel super identified, having built a build system and … 1 2 3 4 … a few toy spreadsheets :-D

This can now read .xlsx files and I need to stop wasting time in a toy spreadsheet :-D

2 Likes

https://sheety.ralsina.me/ and I am not touching this ever again unless I am bored

2 Likes

Added a testimonial section from proud users.

1 Like

pushing the idea further, I wonder if it wouldn’t make sense to interpret instead of compile, until you’re done with the formulas, and then compile to get the released spreadsheet

In a practical sense? Sure! But you may as well use excel and only do this on “release” :-)

fair!

One accidental feature is that if you only have the “spreadhseet binary” but not sheety itself, you can’t edit formulas, only data, so it works as … a modeling tool?

This thread made me realize that something that’s been a bit of a challenge at work (content dependencies), is basically a DAG issue. Build the DAG, and if it starts going cyclic, error out.

Thanks for that.

Np!

PS: there are tools that have helped me in many many many occasions. DAGs are one of them :-)

I kinda got motivated after this and finally cleaned up a bunch of bugs and added wide char support, now the lib handles Unicode width much more reliably (including CJK and emoji), and rendering/state edge cases are a lot tighter than before.

also got carried away and made a small site https://termisu.io with https://hwaro.hahwul.com/

hwaro is cool you should check it out folks!

1 Like

Latest updates.

  • Really self-contained binaries (only need crystal)!
  • Xslx roundtrip!
  • Fixed a bunch of bugs in the formula parser!
  • Much nicer generated code!
  • More ergonomic CLI!
  • Don’t use it for a sheet with 10000 formulae in it or you will end up with a 150KLOC crystal file and your compiler will explode!