VisiCalc Reconstructed

126 points - last Tuesday at 10:39 AM

Source

Comments

fouronnes3 today at 5:21 PM
Very cool article!

I also implemented a spreadsheet last year [0] in pure TypeScript, with the fun twist that formulas also update backwards. While the backwards root finding algorithm was challenging, I also found it incredibly humbling to discover how much complexity there is in the UX of the simple spreadsheet interface. Handling selection states, reactive updates, detecting cycles of dependency and gracefully recovering from them is a massive state machine programming challenge! Very fun project with a lot of depth!

I myself didn't hand roll my own parser but used Ohm-js [1] which I highly recommend if you want to parse a custom language in Javascript or TypeScript.

> One way of doing this is to keep track of all dependencies between the cells and trigger updates when necessary. Maintaining a dependency graph would give us the most efficient updates, but itโ€™s often an overkill for a spreadsheet.

On that subject, figuring out the efficient way to do it is also a large engineering challenge, and is definitely not overkill but absolutely required for a modern spreadsheet implementation. There is a good description of how Excel does it in this famous paper "Build systems a la carte" paper, which interestingly takes on a spreadsheet as a build system [2].

[0] https://victorpoughon.github.io/bidicalc/

[1] https://ohmjs.org/

[2] https://www.microsoft.com/en-us/research/wp-content/uploads/...

ivanpribec today at 5:06 PM
Reminds me of spreadsheet-fortran (https://github.com/lwsinclair/spreadsheet-fortran), a project creating a VisiCalc lookalike in FORTRAN 66, which even runs on a PDP-11.
afandian today at 3:53 PM
Quote:

  #define MAXIN 128  // max cell input length
  enum { EMPTY, NUM, LABEL, FORMULA };  // cell types
  struct cell {
    int type;
    float val;
    char text[MAXIN];  // raw user input
  };
  #define NCOL 26    // max number of columns (A..Z)
  #define NROW 50    // max number of rows
  struct grid {
    struct cell cells[NCOL][NROW];
  };
I doubt that 171 KB of static allocation would fly on an Apple II! I do wonder how they did memory allocation, it must have been tricky with all the fragmentation.
airstrike today at 4:38 PM
> Maintaining a dependency graph would give us the most efficient updates, but itโ€™s often an overkill for a spreadsheet.

It's not overkill at all. In fact, it's absolutely necessary for all but the simplest toy examples.

rnxrx today at 7:06 PM
This a great article - both interesting and potentially really useful to folks teaching- or learning- programming.
bonsai_spool today at 3:53 PM
Are there good command-line interfaces for spreadsheets? I don't do anything super financially-important and I'd prefer to stay in the terminal for quick editing of things, especially if I can have Vi keybindings.
breadsniffer today at 4:45 PM
Anyone know what kind of departments/parts of business were the first adopters of visicalc?
airstrike today at 5:12 PM
4leafclover today at 6:50 PM
Very nice read!

Though I think the definition of the parser struct should be

  struct parser {
    const char* s;
    const char* p;
    struct grid* g;
  };
based on the rest of the code.
pstuart today at 5:32 PM
Other open source command line spreadsheets:

  https://github.com/drclcomputers/GoSheet
  https://github.com/xi/spreadsheet/
  https://github.com/andmarti1424/sc-im
  https://github.com/saulpw/visidata
  https://github.com/bgreenwell/xleak
  https://github.com/SamuelSchlesinger/tshts
  https://github.com/CodeOne45/vex-tui
tracker1 today at 4:08 PM
Kinda cool to see... TBH, I'd be more inclined to reach for Rust and Ratatui myslf over C + ncurses. I know this would likely be a much larger executable though.

With MS Edit resurrected similarly, I wonder how hard it would be to get a flushed out text based spreadsheet closer in function to MS Excel or Lotus 123 versions for DOS, but cross platform. Maybe even able to load/save a few different formats from CSV/TSV to XLSX (without OLE/COM embeds).

khazhoux today at 5:04 PM
Iโ€™m genuinely worried that weโ€™re the last generation who will study and appreciate this craft. Because now a kid learning to program will just say โ€œWrite me a terminal spreadsheet app in plain C.โ€