Live data from Hacker News

Tiny-C Compiler (2001)

iro.umontreal.ca

11–20 of 82 posts

Re: Tiny-C Compiler (2001)

#13
post #4

Earlier quoted context omitted.

It's probably better to call it an interpreter, since it will also run the program and print the values of all non-zero variables afterward. Calling it a compiler is (to me) really stretching things, I can't see any code to emit any other form of the code, it's all aimed at evaluating (executing) it. Edit: oops, I didn't read the code closely enough, it does emit code but only internally, that code is what gets execu…

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.

Re: Tiny-C Compiler (2001)

#15

I did my CS degree at umontreal and this was an assignment in a second year class. This was a pretty interesting introduction to compilers, and even if this is a toy subset of C, this was challenging, at least for me. We would get 0 if there were any memory leak, so we were pretty paranoid about it. The second assignment was writing a Scheme interpreter.

That's kind of surprising they cared so much about memory use, a lot of one-shot C programs such as compilers don't bother freeing memory and let the OS clean up after them once they exit.

Re: Tiny-C Compiler (2001)

#16

Not to be confused with https://bellard.org/tcc/ , which is a tiny compiler for the C language.

I'm quite confused, not the same project at all? To me tiny c compiler always meant the bellard page. Super useful stuff for micro hacky projects.

One could say that the one from this submission is Tiny-C Compiler and Bellard's is Tiny C-Compiler.

Re: Tiny-C Compiler (2001)

#17

Not to be confused with https://bellard.org/tcc/ , which is a tiny compiler for the C language.

I use tcc for all of my small C "scripts" for doing ioctls, etc. Less bloat, suckless. I imagine most software would be better off using tcc than gcc/clang. Performance isn't that important in most cases.

Re: Tiny-C Compiler (2001)

#18
post #17

Not to be confused with https://bellard.org/tcc/ , which is a tiny compiler for the C language.

I use tcc for all of my small C "scripts" for doing ioctls, etc. Less bloat, suckless. I imagine most software would be better off using tcc than gcc/clang. Performance isn't that important in most cases.

> Performance isn't that important in most cases.

Optimizing for storage space is…better?

Re: Tiny-C Compiler (2001)

#19

Not to be confused with https://bellard.org/tcc/ , which is a tiny compiler for the C language.

I'm quite confused, not the same project at all? To me tiny c compiler always meant the bellard page. Super useful stuff for micro hacky projects.

I understand the confusion: it is more about "syntax associativity"

(tiny C) compiler --> "This is a compiler for the Tiny-C language"

vs

Tiny (C compiler) --> "TinyCC [...] is a small but hyper fast C compiler"

That's it! ;-)

Re: Tiny-C Compiler (2001)

#20
post #17

Earlier quoted context omitted.

I use tcc for all of my small C "scripts" for doing ioctls, etc. Less bloat, suckless. I imagine most software would be better off using tcc than gcc/clang. Performance isn't that important in most cases.

> Performance isn't that important in most cases. Optimizing for storage space is…better?

Since they say "scripts", note that tcc supports being invoked in the shebang line. E.g.

    #!/usr/bin/tcc -run
You can do that with gcc/clang too (e.g. #if 0, #endif to wrap a block of shell script to compile the current file and execute the result) but a primary value of tcc is that it compiles fast.

On a more philosophical note, the suckless approach is to optimise for simplicity not storage. It's perfectly valid to disagree with that of course, but if simplicitly of the system as a whole is a consideration gcc and clang doesn't really fit.

Post reply on HN