from Hacker News

Memory-safe, clean implementation of classic Posix "BC" calculator

by jgarzik on 6/8/24, 1:04 AM with 52 comments

  • by teo_zero on 6/8/24, 5:53 AM

    Am I the only one who thinks we need less short-lived tools written in memory-safe languages an more system infrastructure written in said languages?

    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...

  • by gavinhoward on 6/8/24, 4:37 AM

    As the author of the default bc in macOS and FreeBSD, good luck.

    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.

    https://git.gavinhoward.com/gavin/bc/

  • by downvotetruth on 6/8/24, 3:52 AM

    Lost as to why there is a tests folder yet the test function marked with the #[test] attribute is being added to /src: https://github.com/rustcoreutils/posixutils-rs/pull/132/comm... edit: Since the change was to the grammar saved in a separate .pest file, which is separated from the procedural code, then would that make the test an integration rather than a unit test as the "parse_program" function is public?
  • by uecker on 6/8/24, 6:21 AM

    I am still waiting for Rust people to do something new and innovative. I acknowledge that Rust itself is innovative, don't get me wrong, But where are the true proof-of-concept projects such as the Linux kernel, qemu, git, postgresql, vim, etc. of the Rust world? Rewriting code is a waste of time of time, fragments the eco system, and introduces new bugs. And with a new focus on memory safety and analysis tools and sanitizers evolving, a lot of C code will be made memory safe in the future without needing a rewrite in Rust.
  • by anthk on 6/8/24, 1:08 PM

    - DC to convert between bases and if you like RPN.

    - 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.

  • by mongol on 6/8/24, 9:48 AM

    Seems there are multiple Rust coreutils implementation projects? I have heard about uutils, but this is another one?
  • by tiffanyh on 6/8/24, 1:04 PM

    If you want core utilities rewritten in Rust …

    ‘uutils’ is exactly that.

    https://github.com/uutils/coreutils

  • by 082349872349872 on 6/8/24, 5:31 AM

    bc(1) is nice to have, but —for my purposes— less useful than dc(1), because it doesn't generate arbitrary binary output.
  • by mstef on 6/8/24, 2:06 PM

    what's next that urgently needs mem-safety? /bin/true?
  • by mstef on 6/8/24, 1:42 PM

    this must be parody. what exactly is the threatmodel where memory-safety matters for a calculator? did these devs miss the point of popping a calc.exe? surely no bc has ever been used for LPE or RCE.
  • by scrubs on 6/8/24, 3:35 AM

    The title reminds me of the adds for "Shen Yun China Before Communism" which begs the question: ok what about life after communism ... where's the song and dance show about that?

    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.