6 ms·
Picoc: A very small C interpreter for scripting
- koenigdavidmj 11y agoDoesn't say it in the README, but has anyone checked to see if they implemented enough of C to be self-hosting?
- z92 11y agoTried it when it was posted last time. It couldn't run it's own source files. I was wondering if anyone had tried to use cling in any project? It uses llvm's own parser/jit.
- gh02t 11y agoI've used it a tiny bit as part of ROOT (and its predecessor cint a bit more). It pretty much works as advertised, there's not a whole lot to get excited about IMHO. It certainly doesn't make ROOT any less miserable to use.
- zik 11y agoHi, I'm the author of picoc. It's not self-hosting, no. It's meant to be small rather than a feature-complete implementation of C so it's unlikely it will ever be self-hosting.
- thezilch 11y agoLast HN discussion: https://news.ycombinator.com/item?id=1658890 https://news.ycombinator.com/item?id=1658890
- baldfat 11y agowas 1873 days ago I think it is okay to post this and not be told it was done already.
- andrewchambers 11y agoIt has been posted more recently than that I think.
- akkartik 11y agoYes: https://news.ycombinator.com/item?id=9641832 https://news.ycombinator.com/item?id=9641832 Still, I'm happy to see it since I've somehow missed all the previous times.
- cooper12 11y ago> not be told it was done already. It doesn't sound like they were rebuking you. It's pretty common to link to a previous discussion for people interested, especially if the current one doesn't take off or if the previous one contains some information worth repeating or avoiding.
- dvt 11y agoI've used it before and it's pretty cool. Unfortunately, still a bit too big for some embedded systems (I was using it with an Arduino).
- zik 11y agoAuthor here. I tried to make it small enough to run on tiny microcontrollers like the arduino but unfortunately C seems just a bit too complicated for that.
- dvt 11y agoEither way, awesome work. I actually was working on my own sub-sub-subset of C for a tiny scripting language (for the aforementioned project) and I was often referring back to how you wrote picoc.
- algorithm314 11y agoor use tcc with JIT compilation
- conceit 11y agoTCC isn't a JIT-compiler, the script-option compiles all and then runs it on the fly. This allows C-files to be executable by themselves with a shebang-line.
- ibrahima 11y agoI guess in some sense that could also be described as "just in time," i.e. just before you need to run it.
- TheLoneWolfling 11y agoI've heard the phrase "just-before-time" (or JBT) for this, i.e. compiling on the target machine.
- beagle3 11y agoIt's also usable as a dynamic load library. It's still not a JIT, but a program can use it to run code directly without having to fork/exec/spawn anything.
- invaliduser 11y agoMaybe it's a weird fetish of mine, but I always enjoy a good embeddable, scripting engine. It kind of brings me joy and hope. Can't say why. The more engines, the merrier.
- munificent 11y agoI feel the same way. If you haven't seen it already, take a look at mine: https://munificent.github.io/wren/ https://munificent.github.io/wren/
- tomcam 11y agoProps to you and parent poster. I'm with you both. And thanks for the pointer to Wren. I didn't know about it.
- chncdcksn 11y agoAs a student interested in language design and VM programming, this is wonderful. Clean, easy to read code, as well as what seems to be a really well-thought out language. Thanks for this!
- vmorgulis 11y agoI like a lot your previous work on Vigil :) https://github.com/munificent/vigil https://github.com/munificent/vigil "It goes without saying that any function that throws an exception which isn't caught is wrong and must be punished."
- PantaloonFlames 11y agowhat problem does this solve that is not already solved by the n scripting engines that are already out there? When would I use this in lieu of Rhino / JS on the JVM, for example? Pet peeve of mine: people publish projects and don't position what they've built in the universe of existing things. Readers without context won't know what to do with it. A simple FAQ would be really helpful.
- truncate 11y agoIt was moved from Google Code to Github. It was originally written as the scripting language for UAVs on-board flight system https://code.google.com/p/picoc/ https://code.google.com/p/picoc/
- zik 11y agoI originally wrote it as a scripting language for a UAV controller I was making, and also as an exercise in keeping a language small and neat.
- beltsonata 11y agoUsed it when testing some PCMCIA CAM hardware for my day job. Good tool.
- TheLoneWolfling 11y agoTangentially related: What is the smallest self-hosted interpreter? What about the most efficient one? This isn't it (among other things, it isn't self-hosted).
- PuercoPop 11y agoIn similar spirit: https://docs.enlightenment.org/auto/eio/embryo_main.html https://docs.enlightenment.org/auto/eio/embryo_main.html Enlightment uses its own Scripting Languagew throught the EFL.