Hired: A Modern Take on 'Ed'
github.com
github.com
(And in case there were any doubts, I applaud your hellmouth seal-breaking invention. Scratch those itches, eternity will take care of itself!)
It is just so easy to run, easy to use, can open multiple files and is so readable. Why would I open an editor when I'm already in a terminal and it's right there?
So the feature makes perfect pragmatic sense.
https://drive.google.com/file/d/1l13UdgRJy2XvEzI4bYYFU09MW20...
https://www.youtube.com/watch?v=6oPRUzzP9DU
They demonstrate how to build the The Ultimate Dev Setup for mind-blowing Interactive Clojure Development atop the one true, the right honourable, the standard editor, Edward 'ed(1)'.
(Although usually I prefer to run my shells in Emacs instead)
/bin/bash <> /dev/tcp/...
With netcat listening my side. Most things kind of worked (no way to send ctrl-c though) but vi couldn't properly redraw it's screen. So I had to use ed.I also like being able to see my changes as I work.
With a command based editor you just type commands, no fancy keybindings that get jumbled when you have a different layout.
(And I have plans for writing fired, which is basically hired with a window to see the state of the buffer. It would still be strictly command based though, so not a vim remake.)
As long as you write your code with plenty line-breaks it is often easy to just replace a line to make the change you want, so `s` and `C` are rarely needed (though I am weak and tend to use `C` quite often, for example to get the indentation right when adding lines).
It is useful when you are operating over a high-latency connection. As long as you do not send newline by mistake, you can form the command you want to dispatch with confidence. You do not have to worry about where your cursor is, and you won't find yourself in an unexpected mode, or having done the wrong number of undos or redos.
For a while I used it to write C for a hobby-project on the train, using an android phone and screen keyboard. Simple keypresses are easier than control characters in that setting. If you are interacting with a remote unix system from an ipad, you may find it useful for the same reason.
About once a year I find it useful in situations where I have some kind of broken or low-function TTY, or library problems and want to make an edit.
At times, it would be useful to have an ed-like mode available in bash, so that you could have access to an editor when your system was preventing you from spawning new processes.
(i) fixing mistakes is costly: one needs to think more/be more cautious;
(ii) one needs to grow a "mental image" of the codebase;
(iii) which encourages to be more regular and austere/simpler, while training memory;
(iv) the lack of features encourages creativity, e.g. using "good" regexps to navigate the code; a common example is for C functions to be essentially uniquely identified with `^foo\(`, when the functions are defined with:
int
foo(…) {
…
The dumber the tool, the more intelligent the user has to be, and reciprocally. Of course, there are practical limits; that's just the general idea.The backing library https://github.com/sidju/add-ed could either be run through https://neon-bindings.com/ , or compiled into web assembly for that matter. Should just be a weekend project to create an electron `ed`, and if that isn't sufficiently bloated you can `node install everything`.
The build folder weighs in at 618MB and it took 5 minutes and 139 packages to compile on a decent 2019 machine. The final executable is 84M (debug, 11MB after stripping)
It then takes something like 10MB of RAM for opening an empty file, of which 1MB is on the heap.
It is not Electron, but for an "ed" remake, it is definitely a bloat monster. Overall, it is 100 to 1000 times heavier than "ed".
EDIT: speaking of bloat, I remember when EMACS was nicknamed "Eight Megabytes And Constantly Swapping" as a joke on how bloated it was. Times have changed...
Aside from that I guess I have included some pretty big libraries, which due to static linking basically add directly to the binary size. I'm open to replacing most of them for smaller versions, but I won't do it myself.
When I checked the memory usage I saw that bash is using 11 MB and hired 9.2MB, so I'm pretty satisfied with that. If you want some memory usage horror though, note that due to having unlimited undo/redo hired will constantly increase its memory usage for every change you make until you close it. (It is at least diff-based, so it doesn't blow up on larger files unless you change every line.)
Yep, decidedly a different time. Very different expectations about what functionality should be expected in a tool, and when it is meaningful to try to reduce memory usage.
In case anyone else wishes to read the qed manual, here is the link I found after a while spent searching: https://wayback.archive-it.org/all/20150203071645/http://cm....
But it's rusty.
What I am looking for is a less shitty, open replacement for AmigaOS's provided 'ed' editor.
There is a bit of a gotcha that if you build a debug build the build script will be less optimized. This makes a debug build take nearly 4 minutes total on my computer due to how much processing is done in the build script. A release build only takes roughly 2 minutes total due to the optimized build script.
(The "cargo:rerun-if-changed" tells cargo under which circumstances it is necessary to rerun the build script. It doesn't change its behavior on a fresh build.)
Please check if it really does run twice, and thus changes process ID and command line. (I run `top`, press shift+v for process tree, c for command line and go look at the cargo process to find the build-script run.)
Reasons for choosing rust were: - Error handling style, easy to include context - Easy to import and use syntax highlighting library - Some level of inherent UTF-8 validation and support - Easier to make the ed-runtime support pluggable IO and UI
I'm not using the original ed binary (though I could have and it would probably have been smarter), I wrote my own full implementation as a library to also change some things that annoyed me.
On a visual terminal it gets hard remembering what's there. I was really relieved they added EDIT to DOS 4.
I'd like to know what kind of deluded I am.
If you just wanted to rewrite ed in Rust - sure, go ahead, but just say it. My point is the reasons for hired you stated do not sound like reasonable choices at all.
I didn't blindly decide to switch to ed, I tried it out and found its commands to suit my editing methodology, the lack of keybindings to help make it work well on dvorak and the line editing workflow to save me from often manually moving my cursor "long distances". Due to how much I liked the concept I wanted to make improvements.
(I have also looked into vi but I don't quite like the cursor focused way of working it entails, and really dislike how it depends on keybindings (at least hjkl).)
Regarding why I rewrote it rather than forking the C repo you can look into my other comment that explains what I gained from it. And of course I did it because I wanted to, it's not like I'm getting paid for this.
It is well established that commits aren't a great way to judge anything, and innovation is especially hard to judge by any metric. Feel free to look at the usage documentation for add-ed https://docs.rs/add-ed/latest/add_ed/ if you wish to quickly gather some insight into the design, to base your judgement upon.
(btw, some corrections
ed arguably is a modal editor with default command mode and an input mode entered by `a` and `i` and left with either ctrl+c or a lone `.` on a line.
The hired repo has around 100 commits since it is only the syntax highlighting UI, CLI and config handling; the `ed` runtime implementation is in https://github.com/sidju/add-ed with around 200 commits.
)