HN Simulatornew | past | comments | lists | submit | gavinhoward's commentslogin


As someone who has applied less than 6 weeks ago, this is great news. I can't wait to hear back!


Huh.

I'm no Nix user, but I want to build an alternative.

Do you think these problems could be fixed?


I'm not sure. It's a philosophical issue: Nix defines itself as an implementation of a core theoretical idea. If you change that idea too much it may not be Nix anymore.

It's probably worth just going back to the drawing board and asking what the goals of a desktop OS should really be. You'd end up with something radically different to Nix, IMO, sort of like how how NeXT/macOS manages software is quite radically different to UNIX.

I actually have a little exploration of a new software distribution idea going on right now, but it's not trying to do the same things as Nix. It starts by asking what a desktop OS inspired by the success of the web would look like.


I'm okay dropping the philosophy and just making something that truly does what Nix claims: atomic upgrades, fully-reproducible environments, etc. In fact, dropping the philosophy is exactly why I am making my own.

Your idea sounds interesting and (by your bio) right up your alley. I'd be interested to see the result.


I'm still working on it but the gist looks like this.

Two new programs: `url` and `run`. I am creating reference implementations but they're simple and there's a spec, so they could be reimplemented in your language of choice.

`url https://...` resolves the given URL into a disk cache in $HOME and then prints the path. `url` understands archives and can resolve inside them:

    $ url https://a.b/program.zip/bin/program
    /home/foo/.cache/..../bin/program
It implements the HTTP caching spec, and - as browsers can do with HTML - can extract cache override headers from the given program if it's a script with hashbang. It does a few other things, like set +x automatically if the program is intended to be executable, sets quarantine bits on macOS and so on:

    $ open $(url https://downloads.mac-app.com/MacApp-1.2.zip/MacApp.app)
    (scanned by gatekeeper and then run)
The disk cache is cleaned up automatically as disk space falls low or the cache exceeds the configured maximum.

Running programs this way is possible, but not ideal. This is where `run` enters the picture:

    $ run cool-tool.org --help
or if you have the zsh integration set up, you can skip the `run` prefix and just treat URLs as program names:

    $ cool-tool.org --help
`run` resolves this to https://cool-tool.org/run.zip/ which is a small metadata archive containing instructions for how to start the app. The instructions come in the form of a JavaScript that's run inside a restrictive sandbox. It is allowed to resolve URLs into the disk cache, to learn the current host OS and CPU architecture, and to yield an execution plan (basically the path to the binary/script to execute + optionally transformed CLI arguments). So by publishing a small run.zip file to the root of cool-tool.org it becomes possible for users on any OS, including macOS and Windows, to start the program purely by domain name. The script can do hash locking and override cache headers for URLs if the file server isn't cooperative. The tools will keep the app up to date and optimize out cache checks to keep startup fast when the cache is fresh enough.

The run script has a few other options, like figuring out what system libraries are available and what their versions are, thus - if it wishes - it can choose to either download dependencies into the cache and use them (e.g. by setting LD_LIBRARY_PATH), or use the OS provided versions.

At the moment I'm also working on adding a form of sandboxing. The execution plans produced by run scripts can contain permission requests, similar in spirit to macOS entitlements. The permissions aren't tied to any specific sandboxing system or OS. The implementation of `run` may, at its leisure, use this information to sandbox the program before it executes it. The run script may also adapt the permissions requested based on things like what the host OS is, or even what the command line arguments are. For example:

    $ cool-app.org --input ./in.mp4 --output ./out.mp4
or

    $ dry-run cool-app.org --input ./in.mp4 --output ./out.mp4
    Requests permissions:
    1. Read $PWD/in.mp4
    2. Read/write $PWD/out.mp4
    3. Read ~/.config/org.cool-app/config.yml
The run script can look at the command line arguments for this invocation, then produce a permission set that only allows access to the in.mp4 and out.mp4 paths, and a config in an OS specific location, but nothing else. Whether the implementation of run actually tightens things that much will depend on things like what the host OS is capable of, but the information to do so is there. For example on Linux it might use landlock, on macOS it might compare the declared permissions against the entitlements in the Mach-O and abort if there's a mismatch, and so on.

run.zip files don't have to be produced by the upstream author of the code. They can come from anywhere and resolve URLs from anywhere. So if you are worried about the upstream code being malicious, you could use a run.zip from a third party app store or catalogue, and if you aren't, you can use the upstream's version which just sandboxes to limit the blast radius of compromises.

The goals here are deliberately modest, something like:

- Learn from the web, by making starting native CLI apps as convenient as starting a web app.

- Have a small spec that allows for cross-platform deployment without forcing a large declarative schema for how to assemble files and URLs.

- Don't require the user to manually manage installation/uninstallation.

- Experiment with a cross-platform declarative permissions schema that's computed imperatively, where the mapping to OS sandboxing primitives can flex and adapt over time as OS kernels change.


The web made many mistakes. Only thing it got right is HTML and convenience. JS is garbage, browsers bloated. The web is centralized forgetful and fragile. No thx.


As a Neovim user, this stopped me dead with painful realization: I may have suffered the same thing but didn't realize it. There was a time when I could not undo something, and it was after a Neovim upgrade.

Unlike Dr. Chisnall, I started my editor journey on Neovim, so it wasn't a transition that bit me. However, if the format of the persistent undo file is unstable, and Neovim just deletes it when it doesn't recognize the previous format, then it seems conceivable (to me) that an upgrade after changing the format would delete the file too.

Ouch. This is making me think about getting off of Neovim. Yes, FOSS comes as-is, but if there's an alternative...


It’s such an odd design decision.

I could see ignoring the old undo data or warning before discarding it but just silently wiping it is so user hostile it’s hard to comprehend.


It feels like a mismatch in expectations. It's fairly obvious the developers consider the persistent undo feature to be a convenience for short-term continuity if you are exiting and re-entering the editor over a single edit session, not a long-term storage of the history of the file. All of their decisions make perfect sense in that context, but it seems that expectation is not shared by some of their users, who considered it to be an important piece of data meant to be kept long-term. This feels a bit odd to me, given the tendency for undo systems to be fragile anyway, and the documented fragility of this persistence. The author of this article even had deliberate workarounds for some of this fragility which I feel would put me in 'should I even trust this feature?' mode. To me the main fix would be updating the documentation to scream even more loudly "Don't expect this to stay around!".

To me it's a bit like storing your important files in a ramfs and then complaining that your OS doesn't respect user data when it crashes. Sure, it's not exactly a documented behaviour of the system, but you're also not storing your data in a place the developers of the OS expected you to put important data.


> but you're also not storing your data in a place the developers of the OS expected you to put important data.

So exactly the opposite of persistent undo?

The short-termism changes little here, losing weeks' worth of work just because you deleted it recently by mistake and then upgraded with the app deleting the undo, is also bad


That's the point, though, undo (in most applications) is a fragile place to hold much work, regardless of whether it normally survives restarting the app. You could argue about whether it should be that way (infinite, robust, persistent undo is a nice safety net in general), but I would not assume that is the case unless it's very well documented otherwise (and the UI is adjusted accordingly: you really need an undo tree, else a large series of undos followed by an accidental edit will also wipe out a lot of data), and neovim's documentation does not say that it is intended to work that way.


It's some sort of industry standard, though, isn't it? Google Chrome on Android auto-deletes the history database silently if it deems it corrupted (e.g., due to a bad write on a system with low storage). You just open your browser one day and it's all gone.

If not, I wonder how Google justifies it.


Google is the epitome of design that doesn't care at all about the user and user experience.


If Google does something in X way, you can almost always be certain that X way is the wrong way to do that.

Google is abysmal. In every sense of the word and in every product they touch.


If you ignore it, do you continue allowing edits to the file? Now undo history is corrupt and useless anyway. Or do you disallow editing until the user manually deletes some hidden, implementation-detail file for a feature they probably never use?


If making a breaking change to the format of the file, why in root's name would neovim not just make its own new file!? Import the vim version if that's desired into persistent-undo.neovim and then just go from there. I don't understand their choice here at all nor why you're acting like this is complicated or there was some need for them to reuse the exact same file as vim?


To support you further, why would neovim users have any illusion there would be cross compatibility between undo files? Separate undo files seems the obvious and expected choice.


Sorry for my ignorance, but what is the usefulness of undo persistence after a IDE restart? Don't you normally save your changes and finish a piece of work before exiting an DE?

Edit: some great examples in the replies here, thanks! Perhaps I should start using it in editors that support it, never gave it a thought before.


The reason why this feature is particularly useful in vi-likes is because they are not IDEs. I hop in and out of vi all day long. Depending on the task I might create a new tab, run a command in vi, or exit vi to run it. Vi’s appeal is that it is “just” an editor and your terminal and workstation form your un-integrated development environment.


The whole point of undo is that you realize you made a mistake later. If you've done that after you've saved your changes and exited the program, you'd have no expectation of undo still working unless you've enabled this feature.

It doesn't matter whether or not you can think of a reason you would want to enable it, but it should be pretty trivial to do so. Once you've enabled it, it should work.


The article gave 2 examples.

I can give some as well. IDE crashes. Computer reboots at an undesired time. Even if my work is saved, I am not “finished”. I would like my undo history to extend before file / open time.


I often use it to edit system config files, often on embedded devices where I don't have my git credentials setup, or on servers. In these cases we're already not in an ideal world, I don't have good reliable version control or change management in place. In those less-than-ideal worlds, having proper undo history is nice.


First, you need backups

Second (for servers), etckeeper


I mean I already responded to the comment

> In these cases we're already not in an ideal world, I don't have good reliable version control or change management in place.

Most of the stuff I work on is properly scripted idempotent deploys, with good backups and all that. Or it's a one-off demo, or a prototype. Not having full undo history is never going to actually kill a project, it's just going to make early stage projects and one-offs more inconvenient.


    #!/bin/sh
    
    errecho() {
        >&2 printf '%s\n' "$@"
    }
    
    if [ "$#" != 1 ] || [ -z "$1" ]
    then
        errecho 'Requires a single filename as the argument'
        exit 1
    fi
    
    ORIGINAL=$1
    if [ "${ORIGINAL#./}" == "$ORIGINAL" ] && [ "${ORIGINAL#/}" == "$ORIGINAL" ]
    then
        ORIGINAL=./"$ORIGINAL"
    fi
    
    # because of course the output of dirname can't be blindly joined with slash and the basename
    DIRNAME=$(dirname -- "$ORIGINAL")
    if [ "$DIRNAME" = / ]
    then
        DIRNAME=
    fi
    
    FILENAME=$(basename -- "$ORIGINAL")
    # because of course extracting the filename's extension is not supported out of the box
    case "$FILENAME" in
        .*.* )
            EXTENSION=.${FILENAME#.*.}
            BASENAME=$(printf '%s' "$FILENAME" | cut -c-$((${#FILENAME} - ${#EXTENSION})) )
            ;;
        .* )
            EXTENSION=
            BASENAME=$FILENAME
            ;;
        *.[^.]* )
            BASENAME=${FILENAME%%.*}
            EXTENSION=${FILENAME#*.}
            ;;
        * )
            BASENAME=${FILENAME%%.*}
            EXTENSION=$(printf '%s' "$FILENAME" | cut -c$((${#BASENAME} + 1))- )
            ;;
    esac
    
    if [ "$FILENAME" != "$BASENAME$EXTENSION" ] || [ -z "$BASENAME" ]
    then
        errecho 'Failed to properly split the extension from the filename:' "$FILENAME"
        exit 1
    fi
    
    TIMESTAMP=$(date --utc --date=@"$(stat --format %Y "$ORIGINAL")" +'_%Y-%m-%d_%H%M%S')
    if [ -z "$TIMESTAMP" ]
    then
        errecho 'Failed to get the timestamp of the file:' "$ORIGINAL"
        exit 1
    fi
    
    NEW_FILENAME=$(printf '%s/%s_%s%s' "$DIRNAME" "$BASENAME" "$TIMESTAMP" "$EXTENSION")
    
    if [ "$NEW_FILENAME" = "$ORIGINAL" ]
    then
        errecho 'Somehow the name for the backup is the same as the original file'
        exit 1
    fi
    
    # this preserves the timestamps somewhat better
    if ! mv --no-clobber --no-copy -- "$ORIGINAL" "$NEW_FILENAME"
    then
        errecho 'Failed to backup the file: ' "$ORIGINAL" "$NEW_FILENAME"
        exit 1
    fi
    
    if ! cp -- "$NEW_FILENAME" "$ORIGINAL"
    then
        errecho 'Failed to backup the file: ' "$ORIGINAL" "$NEW_FILENAME"
        mv --no-clobber --no-copy -- "$NEW_FILENAME" "$ORIGINAL"
    fi
Actually, nevermind that bullshit, you know what? I think I'd prefer to have an editor with locally persisted edit history instead.


One silly example: sometimes I'll open up source or config file to make a quick, temporary change in order to test something. But then instead of ctrl+z backgrounding it, I'll accidentally quit vim. Then I start it back up to undo the change, and find that there's no undo history.

I didn't know about persistent undo until seeing this posted here on HN, but now I've enabled it! Of course, turns out it's an unreliable feature on nvim... maybe I'll consider switching back to the original (for that and other reasons).


Most apps don't have it, so you might not be used to it, but have you never wished that you could undo the changes you made after you restarted the program?

Moreover, the vim history tracking is amazingly advanced. It's almost like a mini version control system. I highly recommend getting to know it.


If your session / computer crashes, for one.


Another one:

`:earlier 1d`.

persistant undo is like a second brain to consolidate.


Not something I'm working on, but want to: a competitor to Perforce that will be cheaper and easier.

Unfortunately, I'm not sure that being better is enough to compete, so I'm sitting on it for now.


This is the first time I've heard a use for LLMs that I think might be good.


Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: