GithubHelp home page GithubHelp logo

hoosieree / b Goto Github PK

View Code? Open in Web Editor NEW
3.0 6.0 0.0 23 KB

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

Assembly 0.86% C 77.03% C++ 16.46% Makefile 1.84% Brainfuck 3.30% Shell 0.51%

b's Introduction

> 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)

b's People

Contributors

engr110 avatar hoosieree avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.