Hacker News new | past | comments | ask | show | jobs | submit login

Arthur Whitney created a compiler called b that “compiles a language that is isomorphic to c” (his words) and compiles 1000 times faster than gcc etc. The b language code looked very much like k but was essentially exactly equivalent to a subset of C. I read he abandoned it for other reasons but that would not be a bad way of writing a k implementation! “Same madness”:-) May be ngn or someone else would get inspired to write a translator from b to C.

ngn/k is certainly a lot of fun to use. I just wish it also worked on OS X (& plan9).




> ngn/k is certainly a lot of fun to use. I just wish it also worked on OS X (& plan9).

To start on MacOS, can apply this patch then run `make k-libc` on OSX 12.0.1 (M1 processor):

    diff --git a/makefile b/makefile
    index 5b08dde..1ba3c32 100644
    --- a/makefile
    +++ b/makefile
    @@ -10,7 +10,7 @@ w:k o/w/fs.h o/w/k.wasm o/w/index.html $(patsubst w/x/%.k,o/w/x/%.k,$(wildcard w
     h:w o/w/http;cd o/w;./http
     
     k-dflt:; $(MAKE) a N=$@ R=k  O='-O3 -march=native -nostdlib -ffreestanding'                L=''
    -k-libc:; $(MAKE) a N=$@ R=k  O='-O3 -march=native -Dlibc'                                  L='-lm'                       STRIP=true
    +k-libc:; $(MAKE) a N=$@ R=k  O='-O3 -Dlibc'                                  L='-lm'                       STRIP=true
     k-obsd:; $(MAKE) a N=$@ R=k  O='-fPIC -Dlibc=1 -DSYS_getcwd=304 -Dstrchrnul=strchr'        L='--static -fno-pie -lm -lc' STRIP=true
     libk.so:;$(MAKE) a N=$@ R=$@ O='-O3 -march=native -nostdlib -ffreestanding -fPIC -Dshared' L='-shared'                   STRIP=true
     o/$N/%.o:%.c *.h;$M;$(CC) @opts $O -o $@ -c $<

However, Apple platforms are not officially supported (or to put it more bluntly, "officially not supported"), and there are bugs such as this one[1]. I suspect it has to do with libc differences on Mac versus Linux. If you have experience with the libc differences between Linux and Mac, I'd welcome your input! I'm not an ngn/k developer, just interested in adding support for MacOS.

[1]: https://codeberg.org/ngn/k/issues/30


I have tried something similar to this but its self tests still don't pass. Will give this a try. Thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: