Memory-safe, clean implementation of classic Posix "BC" calculator
github.com
github.com
Don't take me wrong, I like when someone creates a better version of something existing. For example, ripgrep is fantastic. But seeing the recent trend of rewriting whatever in Rust just because, I can't help wondering why I should bother whether bc leaks or not...
I think this is the general "rewriting solves all problems" fallacy, which is rarely true, but who wants to maintain existing code, if there is something new and cool? So we get rewrites which largely just add new projects that then have to be maintained in parallel, because they rarely are to completely replace the old (if at all) and at some point the new is not cool anymore and that it is just another thing. I like some key ideas of Rust, but overall I still like many things about C much more (stability, fast compile times, simplicity), so I would much prefer people improving memory safety in C projects.
Cool, so what useful software are rust programmers writing with all that free time? Where is it?
Where's the "killer app"? Whatever it is, nobody is talking about it.
Redox-OS is one such effort.
Smaller and fresher.
I couldn't possibly disagree. My point is that focusing on ownership, lifetime, etc. (the most prominent features of Rust) shouldn't be goals for a tool that's invoked to perform a few quick calculations and shut down immediately after.
I certainly won't say anything against supporting UTF-8 absolutely everywhere, but "dropping old cruft" is IME usually what people say right before dropping useful features or breaking platforms that are actively in use.
Also, while mine is in C, I have tried very hard to eliminate all memory safety bugs, and I think I have done pretty well.
Do you see this as an unexpectedly challenging task? If so, what do you think makes it challenging?
The reason: parsing.
The bc language is poorly designed for a REPL, which it needs to handle.
I got sick of fixing parse bugs, though, and my source code got a sarcastic comment: https://git.gavinhoward.com/gavin/bc/src/commit/4b83bf07b97f...
Integration tests live under a top-level “tests” folder - in this case, you’ll see that the “tests” directory contains test that call the CLI command and verify its output.
See: https://doc.rust-lang.org/book/ch11-03-test-organization.htm...
Only this year I started seeing WebAssembly conference talks actually acknowledging the history of bytecode based distribution.
People are building cool stuff, and happen to do it in Rust.
OSes - redox and many other smaller projects
git - pijul is novel, gitoxide is a pure-Rust git reimplementation
vim - Helix, based on vim and kakoune
>a lot of C code will be made memory safe in the future without needing a rewrite in Rust.
Sanitizers don't do what Rust does, and static analyzers cannot make C memory safe. You would have an easier time of bolting a borrow checker onto a subset of C++ than what you're thinking of, IMO.
I'm also the author of Pijul, a much simpler and more scalable (yes, both! why choose?) version control system, and of Sanakirja, an on-disk transactional allocator to write persistent datastructures (like B trees, ropes, radix trees, HNSW…).
(2) Rewriting isn't necessarily a waste of time. There are rewrites of some wretchedly vulnerability-prone (and poorly extensible) core infra like ntpd, sudo, etc., that are sorely needed. Plus, rewriting them in a safer language will make it easier for future innovations, because it won't be as terrifying to try to have on them without introducing yet more vulnerabilities.
(3) Same applies to using rust for future components within the kernel and major browsers.
(4) Sanitizers are great, but they're not as strong as what you get from a memory-safe language. Most importantly, sanitizers only check where your tests cover.
(5) ripgrep. It's not a rewrite of grep, it's a rethink, and it's amazing.
- Calc it's better if you want to cover complex numbers: https://github.com/lcn2/calc
- Qalc from libqalculate in order to solve some equations in legacy machines. It's lighter and smaller than Maxima, but not as complete. - -
- Maxima for anything else, the biggie one. This will cover calculus. Gnuplot will work fine as a plotter for the previous tools.
> The goal is to create clean, race-free userland utilities that are POSIX compliant, maximizing compatibility with existing shell scripts while minimizing bloat.
> It is not a goal to be compatible with GNU utilities, which are sometimes viewed as bloated and overloaded with rarely-used options.
> A similar project with the aim of GNU compatibility is https://github.com/uutils/coreutils
Because it is a FAQ, the major differences between this project and uutils are:
1. Wider scope: posixutils is far more ambitious than uutils from a breadth standpoint: posixutils will include bc, m4, c99 compiler, fort77 compiler, a cron daemon etc. uutils is far more limited in the scope of programs covered, mimicing GNU coreutils.
2. More minimalist: Each posixutils utility implementation is intentionally more minimalist, intending to avoid the bloat of supporting rarely-used, non-POSIX features. Our common denominator and baseline is the POSIX spec, then add non-POSIX features that users cannot live without.
3. Transportable: Each posixutils utility should look like normal Rust code, easily stand alone with little-or-no deps, and be used in another project. This project is MIT-licensed, not GPL licensed, to aid in that transportability goal.
‘uutils’ is exactly that.
But it's probably still more convenient in dc.
Lagniappe: 6581840dnP
And yes, I hate AI.
Similarly, if this is the memsafe bc, where's the wow it leaks memory like a 1980s rock ballad bc code?
Hint: one has an answer, and the other has really never been on the radar safe or no.