5 ms·
Hi, author here. When I started writing PicoC it was mostly because I was thinking about how small AppleSoft BASIC was back in the day and I was curious how sma
by zik 11y ago
Hi, author here. When I started writing PicoC it was mostly because I was thinking about how small AppleSoft BASIC was back in the day and I was curious how small you could make a C implementation. I also had in mind to use it for robotics/drone scripting on STM32 processors which have about 64KB of RAM.
PicoC runs ok in 64KB although it is a bit cramped. I like that you can write scripts in C on the actual device without needing a host computer of any kind. It's also been fairly popular for embedding as a scripting language in desktop applications, mostly because it's small and easy to integrate. It's really designed for scripting so don't expect it to be fast though.
- endergen 11y agoHey zik, has anyone tried getting it running through emscripten? It would be very cool to have interactive C purely client side in browser. Could make some cool c based jsbin like hosting websites from that.
- zik 11y agoI don't think anyone's tried that. It sounds like a pretty cool idea though.
- Tloewald 11y agoGiven it's written in C, it seems like a direct port to Javascript might be a much better option.
- vardump 11y agoAny particular reason for that?
- Tloewald 11y agoA lot of c will translate very simply to JavaScript and any parsing or string manipulation will be insanely easier.
- vardump 11y agoHow can parsing and string manipulation be easier than just compiling C to Javascript using Emscripten? The interpreter already works in C. Wouldn't translating it manually to Javascript be extra effort?
- Tloewald 11y agoParsing and string manipulation are (hugely) easier in Javascript than C. Compiling the interpreter to Javascript via Emscripten is certainly easier than translating to Javascript -- but porting C to Javascript should still be very easy.
- bobajeff 11y agoI tried to port fastcomp (Emscripten's llvm backbend) for that purpose. Based largely off of work Alon Zakai (kripken) already did towards porting llvm and clang to js. Basically, I was going to compile fastcomp to js then run the commands emscripten would normally run via "arguments" function in the modules corresponding to the tool I needed (clang, llc, llvm-link and opt IIRC). But I stopped short of getting clang to work correctly with the flags I needed it to use. I know it's possible I just needed to work around a few system dependencies like posix_spawn. I was going to trace it's use using a macro to replace calls to it with a function that prints the file and line number instead. But I got fed up with the system I was using (Amazon Linux / ssh / tablet) to do all of this on and by extension everything else that has to do with programming or trouble shooting.