6 ms·
https://github.com/eradman/entr https://github.com/eradman/entr is Language files blank comment code ----
by kreyenborgi 2y ago
https://github.com/eradman/entr https://github.com/eradman/entr is
Language files blank comment code
-------------------------------------------------------------------------------
C 4 154 163 880
Bourne Shell 2 74 28 536
C/C++ Header 4 21 66 70
Markdown 1 21 0 37
YAML 1 0 0 14
-------------------------------------------------------------------------------
SUM: 12 270 257 1537
-------------------------------------------------------------------------------
including a well-designed CLI.
entr supports BSD, Mac OS, and Linux (even WSL). So that's several platforms in <2k lines of code. By using MATHEMATICS and EXTRAPOLATION we find that non-WSL Windows file-watching must take four million minus two thousand equals calculate calculate 3998000 lines of code. Ahem.
Though to be fair, cargo watch probably does more than just file-watching. (Should it? Is it worth the complexity? I guess that depends on where you land on the worse-is-better discussion.)
- lifthrasiir 2y agoYou are comparing a bicycle and a car; while you might only need a bicycle for your daily life, they are not directly comparable. BSD, Mac OS and Linux share the same interface that approximates POSIX---so it only supports a single platform with different variants. Its CLI is not well-designed, it's just a fixed unconditional terminal sequence that even doesn't look at $TERM and its options have no long counterpart (probably because it couldn't use getopt_long which is a GNU extension). And cargo-watch actually parses the `cargo metadata` JSON output (guess what's required for parsing JSON in C) and deals with ignore patterns which are consistent in syntax (guess what's required for doing that besides from fnmatch). And I'm not even meant to say that the supposed figure of 4M LoC is all required. In fact, while the problem itself does exist, I don't think that figure is accurate at all, given the massive `windows` crate was blindly counted towards. I guess the faithful reproduction of cargo-watch without any external library will take about 20--50K lines of code in Rust and in C. But doing it in C would be much more painful and you will instead cut requirements.
- varjag 2y ago(guess what's required for parsing JSON in C) Certainly nothing on the order of MLOC. Ditto for other features you listed.
- lifthrasiir 2y agoSee my other comment about the inexactness of 4M LoC figure. The total amount of true dependencies would be probably a tenth of that, which is still large but much more believable.
- gpderetta 2y ago> BSD, Mac OS and Linux Do these OSs share file watch interfaces? Linux itself has, last I checked, three incompatible file watch APIs.
- lifthrasiir 2y agoHence "variants". Many other aspects, including the very fact that you can safely use `char*` for the file name, are shared.
- Arch-TK 2y agoThere's no standard way of doing file watching across BSDs, Mac OS and Linux. > it's just a fixed unconditional terminal sequence Are you referring to the clear feature? Yes, it's fixed. It's also pretty standard in that regard. It's optional so if it breaks (probably on xterm because it's weird but that's about it) you don't have to use it and can just issue a clear command manually as part of whatever you're running in the TTY it gives you. Honestly I don't think the feature is even really needed. I highly doubt cargo-watch needs to do anything with TERM so I am not sure why you mention it (spamming colours everywhere is eye candy not a feature). But more importantly, this is just a convenience feature and not part of the "CLI". Not supporting long options isn't indicative of a poorly designed CLI. However, adding long option support without any dependencies is only a couple of hundred lines of C. > And cargo-watch actually parses the `cargo metadata` JSON output Which is unnecessary and entirely cargo specific. Meanwhile you can achieve the same effect with entr by just chaining it with an appropriate jq invocation. entr is more flexible by not having this feature. > (guess what's required for parsing JSON in C) Not really anywhere near as many lines as you seem to think. > deals with ignore patterns which are consistent in syntax (guess what's required for doing that besides from fnmatch). Again, entr doesn't deal with ignore patterns because it allows the end user to decide how to handle this themselves. It takes a list of filenames via stdin. This is not a design problem, it's just a design choice. It makes it more flexible. But again, if you wanted to write this in C, it's only another couple of hundred lines. From my experience doing windows development, windows support probably isn't as painful as you seem to think. All in all, I imagine it would take under 10k to have all the features you seem to care about AND nothing non-eye-candy would have to be cut (although for the eye candy, it's not exactly hideously difficult to parse terminfo. the terminfo crate for rust is pretty small (3.2k SLOC) and it would actually be that small (or smaller) if it didn't over-engineer the fuck out of the problem by using the nom, fnv, and phf crates given we're parsing terminfo not genetic information and doing it once at program startup not 10000 times per second). Yes, I think trying to golf the problem is probably not appropriate. But 4M LoC is fucking ridiculous by any metric. 1M would still be ridiculous. 100k would also be ridiculous 50k is still pretty ridiculous.
- ben-schaaf 2y agoNote that entr doesn't recursively watch for file changes. It has a list of files it watches for changes, but this list isn't amended when new files are added. Fundamentally that's a fairly small subset of proper recursive file watching. In terms of just watching files a better project to compare against is https://github.com/inotify-tools/inotify-tools https://github.com/inotify-tools/inotify-tools.
- kreyenborgi 2y agofrom man entr: Rebuild project if a source file is modified or added to the src/ di‐ rectory: $ while sleep 0.1; do ls src/*.rb | entr -d make; done Though I shudder to think of the amount of code needed to rewrite that in a compiled language while sticking to the principle of not reinventing anything remotely wheel-shaped. (Btw the libinotify/src is like 2.3kloc, inotify cli <1.2kloc.)
- raincole 2y ago> By using MATHEMATICS and EXTRAPOLATION we find that non-WSL Windows file-watching must take four million minus two thousand equals calculate calculate 3998000 lines of code You joke, but Windows support is the main (probably the only?) reason why cargo-watch is huge. Rust ecosystem has some weird shit when interacting with Windows.