[git commit] bc: new applet, throws warning

Gavin Howard gavin.d.howard at gmail.com
Thu Dec 6 16:48:31 UTC 2018


Hello,

I am the original bc author, so take my words with a grain of salt.

Of course, I will understand if busybox decides to write its own
implementation, I just wouldn't suggest it.

First of all, it is important to remember everything that must be in a
bc implementation:

1) Lexer
2) Parser
3) Code generator (mixed with the parser in my implementation)
4) Interpreter
5) Arbitrary precision math library
6) Primitive garbage collection (if you want to not have memory leaks)

I did all that, plus a complete dc (which has its own lexer, parser,
and parts of the interpreter), while making it free of memory leaks
and memory errors, in under 7500 LOC. That is no mean feat. And I did
it while providing more detailed error messages than the GNU bc, while
being about two-thirds the size when compiled (standalone). Inside
busybox, this bc (combined with dc) is about the size of the GNU dc
alone.

To reduce the size significantly (Denys has reduced it some already,
though in my mind, some of those changes are up in the air), you are
going to have to make the bc not give good error messages and/or not
check for errors as thoroughly (a massive chunk of the parser, which
is the largest portion, is dedicated to error checking), reduce the
quality of the code, reduce the performance of the math (though this
would not remove much), or all of them combined.

I think the best idea would be to accept my code (with changes), but
just not enable it by default. Users can choose if they want it.

Gavin Howard
On Thu, Dec 6, 2018 at 6:37 AM Bernhard Reutner-Fischer
<rep.dot.nop at gmail.com> wrote:
>
> Hi,
>
> Are you sure this is a good idea?
> I was under the impression that it would be much more sane to write bc from scratch given the extraordinary size of the proposed implementation.
>
> Thanks,
>
> On 5 December 2018 15:40:38 CET, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> >commit:
> >https://git.busybox.net/busybox/commit/?id=01055ba89a92470587d9012c7e8707d943ebd875
> >branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
> >
> >Signed-off-by: Gavin Howard <yzena.tech at gmail.com>
> >Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
> >---
> >miscutils/bc.c | 7449
> >++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > miscutils/dc.c |   84 +-
> > 2 files changed, 7492 insertions(+), 41 deletions(-)
> >
> >Patch is too large, so refusing to show it
> >_______________________________________________
> >busybox-cvs mailing list
> >busybox-cvs at busybox.net
> >http://lists.busybox.net/mailman/listinfo/busybox-cvs
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list