1. 17

  2. 7

    Author here. I’m rather stoked that people are still interested in my little project.

    1. 3

      I was impressed that it fired right up from a make and I had a c interpreter shell less than 10 seconds after checking the project out. If 68k of LOC is a small project, what are your large ones? Do you still use PicoC ? What other systems has it been integrated into? What is the largest codebase it has executed? Can it interpret itself?

      1. 5

        Only about 4,500 lines of that code is the actual C interpreter. The rest is support code, tests, platform-specific code etc..

        I’m not using picoc myself right now but I do have a rocketry project in the pipeline I might use it for. I’ve used it in UAV projects in the past.

        It’s been used by other people for a wide variety of things in the past. A lot of people embed it into their programs as a scripting language. It’s ideal for that since it’s small and portable and presents little surface area to integrate. Other people use it in embedded projects - robotics etc.. It’s been used in some commercial robotics systems too.

        It can’t interpret itself since it doesn’t implement the full C standard. Keep in mind here that the aim of the project was to make a very small C implementation, not a complete one. It doesn’t implement things like struct bitfields, it doesn’t have a full C preprocessor and it doesn’t run particularly fast. It’s good for what it does though - running simple C scripts with a minimum of fuss.

        1. 1

          […] and it doesn’t run particularly fast.

          If one were to embed it as scripting language in another program, how does it compare in speed to LuaJIT?

          1. 1

            LuaJIT will be many times faster than this.

    2. 3

      Interesting project. Just a heads up in case people are not aware – if all you want is run “c programs (sort of) as scripts (on a x86 host), the Tiny C compiler might be a better bet: http://bellard.org/tcc/

      Looks like this has a different focus than tcc though.

      1. 2

        My co-worker is asking, why just not use normal compiler?


        Scripts are slightly simpler than standard C programs - all the system headers are included automatically for you so you don’t need to include them yourself. Also, scripts don’t have a main() function - they just have statements which are run directly.

        1. 4

          I originally wrote it because I wanted to edit and run scripts on a tiny device with only 64k of RAM (an STM32 microcontroller). It turned out to be handy for other situations too - like when you want to add a simple scripting language to a C program and you don’t want to put in an entire compiler just for that.

        2. 1

          This is really cool! I’ve always wanted to play around with a C interpreter!

          I understand that it is completely impractical - but it is a shame this doesn’t support C99. I’d love to package a interpreter along with Cello because I think it would really help people learn the library a lot faster, and it suites the dynamic nature of it.

          1. 2

            If you’re looking for a fully featured C interpreter there’s always CINT:


            It’s about 100x the code size of picoc but it claims “CINT covers most of ANSI C (mostly before C99) and ISO C++ 2003”