Compiler for the B Programming Language

2025-06-1812:278322github.com

Compiler for the B Programming Language implemented in Crust - tsoding/b

Warning

Compiler is not fully implemented yet.

Logo by Strawberry 🍓

Compiler for the B Programming Language implemented in Crust

  • Rust - the compiler is written in it;
  • fasm - used as the compiler backend;
$ make
$ ./build/b -run ./examples/hello_world.b

Also check out more examples at ./examples/.

The project comes with btest utility which tests the B compiler. It is built automatically along with the B compiler when you do make.

When you run it, it just builds and runs all the tests from the ./tests/ folder on all the supported targets and generates a matrix report. Give it a try to see it for yourself:

It doesn't crash when it encounters errors, it just collects the statuses of the tests on all the platforms to give an overview of the current state of the compiler.

If you want to test only on a specific platform you can supply the flag -t

$ ./build/btest -t fasm-x86_64-linux

You can supply several platforms

$ ./build/btest -t fasm-x86_64-linux -t uxn

If you want to run a specific test case you can supply flag -c

You can do several tests

$ ./build/btest -c upper -c vector

And of course you can combine both -c and -t flags to slice the Test Matrix however you want

$ ./build/btest -c upper -c vector -t fasm-x86_64-linux -t uxn

Read the original article

Comments

  • By avmich 2025-06-226:46

    A pretty recent work: https://github.com/sergev/BCause .

  • By treyd 2025-06-2123:512 reply

    Interesting that this is in a self-developed subset/dialect of Rust called Crust which attempts to treat it as a better C, using unsafe everywhere among other things.

    • By kzrdude 2025-06-2123:551 reply

      That's a little bit interesting. It remains then a C-like language with generics, and that sounds a lot more fun than regular C. I don't yet understand the point of avoiding references or libstd, though.

      • By int_19h 2025-06-228:171 reply

        Avoiding references means avoiding the borrow checker, and I don't think you can use much of stdlib if you avoid references...

        • By lkuty 2025-06-2214:41

          At the beginning of one of his videos on Crust, he's trying to avoid stdlib exactly for that reason.

    • By IshKebab 2025-06-2220:491 reply

      I don't know why you'd see that as desirable and not use Zig. Unsafe Rust is actually harder to get right than C or Zig.

      • By month13 2025-06-230:151 reply

        This is mainly for fun, really.

        Tsoding's main lesson is how simple systems can be and the desire and demand for complex build systems is silly.

        • By IshKebab 2025-06-236:441 reply

          > the desire and demand for complex build systems is silly

          No it isn't. "Simple" build systems like Make don't solve many of the problems that "complex" build systems like Bazel do.

          At my current company I tried to convince my boss at the start of our project to use Bazel (it's very difficult to change build systems once your project is big), because I knew from experience it would solve many problems we would eventually run into.

          He wouldn't let me and wanted to keep things "simple". Guess what happened? Now we have to run dozens of hours of CI just to fix a typo in a comment. CI regularly breaks because people forget dependencies. Etc.

          • By sureglymop 2025-06-2315:56

            Make is definitely not a simple system. In tsodings latest stream about this project he actually implemented a small build/test runner system for it that is really simple.

            But actually I would disagree with the commenter you replied to. I think the main goal of this project seems to just be doing it for fun.

HackerNews