[HN Gopher] I added some optimizations to my compiler that turns...
       ___________________________________________________________________
        
       I added some optimizations to my compiler that turns Lisp into
       JavaScript
        
       Author : healeycodes
       Score  : 63 points
       Date   : 2024-05-30 22:30 UTC (2 days ago)
        
 (HTM) web link (healeycodes.com)
 (TXT) w3m dump (healeycodes.com)
        
       | User23 wrote:
       | Good stuff.
       | 
       | On a Lisp compiler optimization tangent: It's still relevant to
       | SBCL and also generally interesting so the CMUCL advanced
       | compiler manual section[1] is good reading.
       | 
       | [1] https://cmucl.org/docs/cmu-user/cmu-user.html#Advanced-
       | Compi...
        
       | tromp wrote:
       | Do you check whether constant folding actually results in shorter
       | code? E.g. something like                   let a="hello ";
       | b=a++a; c=b++b; in c++c
       | 
       | probably shouldn't be changed into                   "hello hello
       | hello hello hello hello hello hello "
        
         | dualogy wrote:
         | A sufficiently smart minifier should rewrite that back into
         | `"hello ".times(8)` =)
        
         | healeycodes wrote:
         | The Lisp variant that the compiler supports at the moment only
         | handles f64 numbers so I don't think this kind of issue is
         | possible.
         | 
         | However, this is a very relevant point. If the goal is just
         | shorter code (as opposed to a mix of shorter code and less run-
         | time operations), then you need to check that folding strings
         | (and similar types) actually makes the expression shorter to
         | represent.
        
         | retrac wrote:
         | Depends whether you're optimizing for program size or runtime
         | speed.
        
       | jagged-chisel wrote:
       | My immediate reaction is that this is as much a semantic mistake
       | as "this message does not exist."
       | 
       | Maybe I'm wrong, but ... well, there it is.
        
       | love2read wrote:
       | I did a similar thing in opposite order, I compile js to scheme.
       | https://github.com/u9g/js2scheme/blob/main/example.js
       | 
       | Not a serious project, made purely because I had a class that
       | mandated writing scheme for the homeworks.
       | 
       | I think the coolest thing to come out of that project was that I
       | learned that it is possible to convert branching if statements to
       | lisp constructs. That was a fun project :)
        
       ___________________________________________________________________
       (page generated 2024-06-01 23:00 UTC)