Live data from Hacker News

Tiny-C Compiler (2001)

iro.umontreal.ca

21–30 of 82 posts

Re: Tiny-C Compiler (2001)

#21
post #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.

I was about to comment and say the same thing, but as a graded learning exercise there is certainly value in that approach.

Re: Tiny-C Compiler (2001)

#22
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.

I think you are confusing the work of Frabrice Bellard with this very one. The former is a C-language compiler. This once is a compiler for a language called "Tiny C". Understandable confusion, though.

Re: Tiny-C Compiler (2001)

#23
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.

Thanks for sharing! I've yet to go through my C phase, but see it on the horizon, and will remember this and the shebang trick.

Re: Tiny-C Compiler (2001)

#24
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.

I think you are confusing the work of Frabrice Bellard with this very one. The former is a C-language compiler. This once is a compiler for a language called "Tiny C". Understandable confusion, though.

[deleted]

Re: Tiny-C Compiler (2001)

#25

Earlier 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.

In contrast, Java also did that and I doubt if most people think of Java as interpreted. So, using a byte-code interpreter may not be the criteria most people are using to decide on this. Truthfully, I think it is all a bit arbitrary.

Re: Tiny-C Compiler (2001)

#26
first assignment would be to add the multiply and divide operators...

I admit I have trouble understanding how the VM run() function works... anybody can give some insight?

Re: Tiny-C Compiler (2001)

#29
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.

Thanks for sharing! I've yet to go through my C phase, but see it on the horizon, and will remember this and the shebang trick.

This is a recommended practice for scripting with Nim if you want a batteries-included language.

Re: Tiny-C Compiler (2001)

#30

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.

This is a compiler for a language called Tiny-C.
Post reply on HN