Hacker News new | past | comments | ask | show | jobs | submit login

Tree shakers require that you look at every function-bound symbol and determine if that symbol appears in the call graph of the main function(s) or in an isolated call graph. The functions that follow the call graph exist in most Common Lisps but they are not standardized; they're implementation-dependent. That's part of the reason tree shakers aren't widespread. Another reason is that if you're using the compiler in your runtime, even isolated parts of the call graph can still be useful, so tree shaking becomes something of a policy decision rather than a pure algorithm.



It's also not that easy, given one can cross the data is code frontier easily:

    (let ((fs '(+ - *)))
      (mapcar (lambda (f)
                (funcall f 1 2))
              fs))
How do we know that the functions in FS can't be removed? They are just symbols in a list in the code.


Exactly. That's what I was getting at but your example is better because the compiler isn't really even being used at runtime here.


Yeah that’s super tricky... how does LispWorks deal with such things?


...and just as a follow-up, once you've dug into the problem enough to discover it's surprisingly difficult to define what is "the right thing" for a tree-shaker in Lisp to do, you realize that even if you build it, it doesn't buy you much. That's why we tend to sound curmudgeonly about the issue. It's a valuable learning exercise, so feel free to dig in. You'll gain some valuable insights into what makes Lisp special.


I have the impression that lispworks gets the gc to do the tree shaker's work http://www.lispworks.com/documentation/lw50/DV/html/deluser-...


Treeshaking is a separate phase during 'delivery' (aka creating an optimized application/library): it may use the GC in the treeshaking phase:

http://www.lispworks.com/documentation/lw71/DV/html/delivery...




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: