tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

New bc



Hello,

I am the author of a new bc implementation. (https://github.com/gavinhoward/bc)

It is BSD-licensed and contains all GNU extensions, including void
functions and array references. It has its own internal implementation
of command-line history, so readline and editline are not necessary.
In fact, it has no dependencies other than a POSIX-compatible system,
since it even uses a custom POSIX shell script for configure and a
POSIX make-compatible Makefile.

This bc also includes a dc in the same binary (it is a mult-call
binary). The dc has every extension that GNU and *BSD dc's have, but
it does omit one command: the '!' command (for security reasons).

It also has many features on top of the GNU extensions:

* My bc is bigger than GNU bc, but it is smaller than GNU bc and dc
combined, and since it includes both in the binary, that is a more
fair comparison.
* Despite being smaller (combined), it implements all GNU extensions
(including void functions and array references) plus a bunch of its
own.
* It is also more robust. Before I release, I make sure that it cannot
crash. It is thoroughly fuzzed and tested. This is, in fact, why I did
the project: I was curious as to exactly how perfect I could make a
piece of software, and I think it is pretty close.
* It actually implements the POSIX standard. (The GNU bc deviates in a
few subtle ways.)
* It still basically matches GNU in speed.
* It actually responds to locales and outputs error messages in the
specified locale (translations welcome!).
* Extra extensions include:
  * It has the -e and -f command-line options that BSD bc's have.
  * It can turn scale, ibase, and obase into stacks (see
https://github.com/gavinhoward/bc/blob/master/manuals/bc.1.ronn#options,
--global-stacks option). What this means is that functions don't need
brittle code to make sure those three global variables are restored
before returning.
  * It accepts numbers in scientific or engineering notation.
  * It also will output numbers in scientific or engineering notation.
  * It has a more extensive math library (see
https://github.com/gavinhoward/bc/blob/master/manuals/bc.1.ronn#extended-library
for all extra functions). A lot of these functions are geared towards
programmers that need to know bit patterns of certain values.
  * It adds the following operators:
    $ (truncation)
    @ (truncation to a certain number of decimal places)
    >> (decimal right shift)
    << (decimal left shift)
    @= (places assignment)
    >>= (decimal right shift assignment)
    <<= (decimal left shift assignment)

Would there be interest in adding my bc as a port? If so, would there
also be interest in investigating whether my bc could replace the
current default bc?

Gavin Howard


Home | Main Index | Thread Index | Old Index