3 ms·
wrt stack allocation are you referring to DYNAMIC-EXTENT? It's implementation dependent so you have to know your compiler well. Allocation in C is explicitly a
by agentultra 11y ago
wrt stack allocation are you referring to DYNAMIC-EXTENT? It's implementation dependent so you have to know your compiler well. Allocation in C is explicitly a part of the language on the other hand. A conforming compiler has to initialize the memory you ask for in the place you tell it to (at least with optimizations off you can think of it this way):
uint32_t flags[100];
vs
(defun form ()
(let ((xs (make-array 100 :element-type :unsigned-int)))
(declare (dynamic-extent xs)
...)))
The CL example could optimize xs depending on the implementation and its configuration to allocate it on the stack. The C example has to initialize enough memory on the stack for 100 32-bit integers no questions.
I hope I didn't give the impression that lists were the only data-structure in CL; I use structs, arrays, and macros to manage structs-of-arrays, etc. Plenty more of course.
I do prefer to use CL but I end up spending more time in C/Python for reasons.
What I find interesting in lisp land are lisps that don't try to take over the whole system and whose principle design is to be small and fast. C has a large run-time library but you can compile programs without it if you're willing to write your own stuff. You don't have such control in the open source implementations I've used.
The open source CL implementations, afaik, still lack tree shakers to try and remove unused code from the image prologue before running the top-level. SBCL still produces a 25MB binary to print "Hello, world!" to the console... because you still have to compile in a GC, the entire CL library, the implementation's run-time, etc -- even if your code never uses it.
- lispm 11y ago> It's implementation dependent so you have to know your compiler well. In any larger application you have to know your compiler and the special libraries well. GCC, CLANG, whatever... SBCL is kind of large. Other open source Common Lisps create smaller applications: CLisp, CCL, ECL, ... Some thought there was a use for delivery Common Lisp with or without GC. But it has not caught on widely. See for example Thinlisp, CLICC, mocl (derived from CLICC) and others. Those have compilers written in Common Lisp, which translated the code to static C. In case of Thinlisp without GC - its origin is in soft-realtime expert systems for process control. Thinlisp is probably not much used, but a related compiler (not publicly available) is still used for product development. There were and still are inhouse delivery compilers. Also specialized languages: You develop in a Common Lisp environment, but write in a special language. SubL, Stella, ... For example Cyc is written on top of SubL, which is derived from Common Lisp (and can be used inside Common Lisp) and the Cyc application then can run on top of C or Java.