Tiny-C Compiler (2001)
41–50 of 82 posts
Re: Tiny-C Compiler (2001)
#42This doesn't have types, functions, arrays or much error checking. It has one char identifiers. I don't think we should read into this any more than a tiny example or experiment by the author.
So, a Tiny C?
Re: Tiny-C Compiler (2001)
#43This is an interpreter for a super restricted subset of C and it looks well written from a pedagogical standpoint (keeps thing pretty simple, fairly easy to read). But it's slightly awk to strip-down a language (what features do you keep, what do you lose?). I think it's more fun to build an interpreter for an actual tiny language. In my next book I have interpreters for Brainfuck [0], an obfuscated kind of joke of a…
Re: Tiny-C Compiler (2001)
#44Earlier quoted context omitted.
It is a compiler rather than a direct evaluator, since it generates bytecode for a stack VM --- and also includes the interpreter for that (look at the bottom).
That’s more or less every interpreter. CPython compiles to bytecode before interpreting that, yet nobody would call it a compiler.
Your SQL database also has a compiler. SQL is compiled to an execution plan. Compile doesn't only mean "create a machine code executable file".
Re: Tiny-C Compiler (2001)
#45Not to be confused with https://bellard.org/tcc/ , which is a tiny compiler for the C language.
It is sad that tcc is unmaintained as it would be really useful in small embedded systems. I just tried it on Debian and compilation fails without #undefining CONFIG_TCC_MALLOC_HOOKS in lib/bcheck.c. After compilation it passes tests, but they warn that it could be unreliable.
For details, check their current working repository [1] and mailing list [2].
Re: Tiny-C Compiler (2001)
#46Oh, Marc Feeley. Wonder if we'll see a Tiny-C target for Gambit?
$ cat hello.scm
(display "hello!\n")
$ gsc hello.scm
$ gsi hello.o1
hello!
$ ls -l hello.o1 # this is generated by gcc
-rwxrwxr-x 1 feeley feeley 18152 Mar 13 17:16 hello.o1
$ rm hello.o1
$ gsc -cc "tcc -shared" hello.scm
$ gsi hello.o1
hello!
$ ls -l hello.o1 # this is generated by tcc
-rwxrwxr-x 1 feeley feeley 4432 Mar 13 17:17 hello.o1Re: Tiny-C Compiler (2001)
#47This doesn't have types, functions, arrays or much error checking. It has one char identifiers. I don't think we should read into this any more than a tiny example or experiment by the author.
So, it's the C equivalent of Tiny BASIC? So, a Tiny C?
See Feeley's response for the proper context.
Re: Tiny-C Compiler (2001)
#48Earlier quoted context omitted.
That’s more or less every interpreter. CPython compiles to bytecode before interpreting that, yet nobody would call it a compiler.
That is definitely a compiler and anyone with a CS degree would call it that if they were discussing its functionality, because that's technically what it is. (Referring specifically to the part which compiles Python to bytecode) Your SQL database also has a compiler. SQL is compiled to an execution plan. Compile doesn't only mean "create a machine code executable file".
None of these assertions is correct.
> (Referring specifically to the part which compiles Python to bytecode)
So referring specifically to something different than what I explicitly specified, it's called something else.
By that reasoning, a cow is a muscle and you are an acid.
> Your SQL database also has a compiler.
"Has a" and "is a" are rather different relationships.
> Compile doesn't only mean "create a machine code executable file".
You're the only person who made that assertion.
Re: Tiny-C Compiler (2001)
#49Re: Tiny-C Compiler (2001)
#50Sigh. I wish people would teach compilers using Oberon as an example. One can write a small yet complete compiler for (what turns out to be not-so-tiny) a language.