> note: docs/README.txt is from kparc.com/b/readme.txt
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.
I used wget --recursive --no-parent http://kparc.com/b and then deleted a few spurious index.html?= files.
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
Ris a function definition but it’s really a macro). - Ubuntu 16.04 vm (VirtualBox): builds
b.cwith some warnings
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 (
.startinstead ofmainfor some reason)
“Creature comforts” are absent, looks like a technical proof of concept or development version. Don’t expect training wheels.
- accepts
*.bprograms 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)
Weird. Feels like C and K at the same time. An “evolutionary missing link” between the two.
A couple others have started on this same journey.
- https://github.com/tlack/b-decoded Has a README and some inline comments in the code. Much further along than me.
- https://github.com/zgrep/b
- What is
b? - Is it a compiler or a REPL (or both)?
- Why
make /bin/bwhich requiressudo? More obvious workflow perhaps? (/bin/is already onPATH)