3 ms·
This is nice, but only hardcore Lisp users prefer writing C-in-sexpr's to just writing C. The "industrial-strength" alternative in the open-source world is jus
by JoachimSchipper 10y ago
This is nice, but only hardcore Lisp users prefer writing C-in-sexpr's to just writing C.
The "industrial-strength" alternative in the open-source world is just to parse C into an AST; several important projects like the Frama-C analyzer (and, IIRC, the Cocinelle project best-known for "spatch") use CIL (https://people.eecs.berkeley.edu/~necula/cil/ https://people.eecs.berkeley.edu/~necula/cil/), and of course many recently-started projects use the LLVM infrastructure.
sexpr's do make the AST more obvious than relying on an external compiler, but you need to write a lot of macro's before "more-convenient macro's" beat "more-convenient code".
- taeric 10y agoI would assume this is for writing a program generator. That is, you have a lisp program that will generate a C program.
- kruhft 10y agoIn the end, that's where it's true power would come from where you use the capabilities of the much higher level language to compile ideas to the lower level language. ALso, this allows for far greater compile time data generation for static initialization. Even files can be loaded in to do away with runtime IO, building programs that are closer to self contained 'images' rather than a collection of files.
- tines 10y ago> This is nice, but only hardcore Lisp users prefer writing C-in-sexpr's to just writing C. I object! The choice between this and straight C isn't completely up to personal preference; using s-expressions gives you objectively more power because it lends itself to lisp macros, which are really the strongest reason to use any lisp at all.
- bdowling 10y agoI think he's suggesting that you could add the same functionality using lisp as a preprocessor without having to write what is objectively C semantics weapped in s-exps.
- kazinator 10y agoThat's more or less obvious, and even has prior art by Java father James Gosling in the Ace preprocessor: https://swtch.com/gosling89ace.pdf https://swtch.com/gosling89ace.pdf Well, minus the "using Lisp" part.
- nickpsecurity 10y agoI disagree. I hated C and found LISP's style weird when I used it for a BASIC-like 4GL. I used LISP since it made it trivial to do parsing, transformations, rapid prototyping, and extraction to C for portability. I still effectively coded in a structured & imperative style in BASIC. I only knew enough C... a subset of it... to convert the BASIC commands. So, I could program super-fast in a high-level BASIC with C output. LISP was worth using to reduce effort as I have no idea how I'd do all of that in just BASIC or C with what little experience I had.