hoosierEE/b

It certainly *requires* close study. Not sure if it *rewards* it yet. :)

★ 2Forks 0CGitHub ↗Compare

README

> note: docs/README.txt is from kparc.com/b/readme.txt

b

I want to understand what’s going on over at kparc.com/b. The docs call it a compiler, but it looks like an interpreter to me. At the very least I can see a REPL in the “main” function[1]. It is implemented in Whitney-style C, an acquired taste.

The readme claims that the generated code is on par with gcc/llvm at highest optimization settings, but with massively shorter compile times, and smaller binaries.

[1]: actually there’s no main, but there is a _start in assembly which invokes the REPL.

download latest

I used wget --recursive --no-parent http://kparc.com/b and then deleted a few spurious index.html?= files.

make/install

No k.c on my machine, so I will only try to make /bin/b.

  • MacOS: I failed to get a working build. Lots of “function definition is not allowed here” errors. Seems to have missed a macro somewhere (thinks R is a function definition but it’s really a macro).
  • Ubuntu 16.04 vm (VirtualBox): builds b.c with some warnings

overview of files

b.c includes a.h includes c.h

  • c.h: typedefs, macros, accessors
  • a.h: more accessors, public interface (lots of static inlined functions)
  • b.c: entry point (.start instead of main for some reason)

the b executable

“Creature comforts” are absent, looks like a technical proof of concept or development version. Don’t expect training wheels.

  • accepts *.b programs from the command line
  • does not permit spaces (repl exits)
  • no error handling (segfault)
  • function definitions work f[ii]{x+y}
  • function call works f[2;3] returns 5
  • / and \ do not seem to perform left or right shifts as hinted in the documentation (not sure what they do)

impresions

Weird. Feels like C and K at the same time. An “evolutionary missing link” between the two.

related work

A couple others have started on this same journey.

questions

  • What is b?
  • Is it a compiler or a REPL (or both)?
  • Why make /bin/b which requires sudo? More obvious workflow perhaps? (/bin/ is already on PATH)

Contributors

ENGR110hoosierEE

Issues