[HN Gopher] 8cc.vim: Pure Vim script C Compiler
       ___________________________________________________________________
        
       8cc.vim: Pure Vim script C Compiler
        
       Author : JNRowe
       Score  : 99 points
       Date   : 2024-07-02 14:36 UTC (8 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | INTPenis wrote:
       | It looks like they're just taking the entire eightcc compiler and
       | stuffed into vim buffer memory.
        
         | rhysd wrote:
         | No. It is a C compiler compiled to Vim script. So it is
         | actually a C compiler written in Vim script.
        
           | flohofwoe wrote:
           | I wonder how much faster a manually written C compiler in Vim
           | script would be.
           | 
           | The current code is essentially assembly instructions running
           | as Vim script, this gotta be incredibly slow, probably not
           | much faster than an x86 emulator written in Vim script:
           | 
           | https://raw.githubusercontent.com/rhysd/8cc.vim/master/autol.
           | ..
        
             | svlasov wrote:
             | I wonder how much faster it would be if it was written in
             | Vim9 script.
        
             | aghastnj wrote:
             | There's only one way to find out, bubba! You're gonna have
             | to write an x86 emulator in vimscript for us, and tell us
             | how it compares...
        
             | actionfromafar wrote:
             | Time for JIT-compiled vimscript, I guess? Why should
             | Javascript have all the fun.
        
               | augusto-moura wrote:
               | Funny because neovim supports LuaJIT for it's lua init
               | files by default. I wonder if there would be a way to
               | compile vimscript to lua and have it everything inside
               | the lua IR. Probably very hard, given the DSL nature of
               | vimscript
        
           | munificent wrote:
           | I think a more accurate way to describe it is that it's a C
           | compiler written in C and then automatically transpiled to
           | VimScript.
           | 
           | No human hand-authored this giant pile of VimScript: https://
           | raw.githubusercontent.com/rhysd/8cc.vim/master/autol...
        
             | rhysd wrote:
             | Yes. It is compiled to Vim script using ELVM[1]. Though the
             | author of Vim script backend of ELVM is me :)
             | 
             | [1]: https://github.com/shinh/elvm
        
               | nequo wrote:
               | That is very cool! So with ELVM one could put together a
               | C compiler in TeX too? Or transpile Vim into Vim script
               | to self-host it?
        
               | krick wrote:
               | Cool. Why, though? I mean, it's not like this project has
               | any practical value anyway, but wouldn't it be actually
               | easier and more efficient to actually implement a C
               | compiler in VimScript? Or is the vimscript ELVM backend
               | the actual end-goal here, and C-compiler at question is
               | basically just a proof that it works?
        
             | metadat wrote:
             | Thanks, at first I thought someone had written it in vim
             | script, then I inspected the README in detail and learned
             | it's only transpiled from C to vim script, which is not
             | particularly exciting or impressive compared to a human
             | wielding such a degree of vim script fu.
        
             | gsuuon wrote:
             | Ah - my impression went from 'this is pure masochism' to
             | just 'this is slightly insane'.
        
       | flying_sheep wrote:
       | I'd love to use vim to compile vim lolz
        
         | queuebert wrote:
         | I always suspected Emacs would achieve sentience before vim.
         | Maybe I'll be wrong.
        
           | zelphirkalt wrote:
           | The difference is, that with Vim script it will either happen
           | unexpectedly or unexplicably, while in Elisp it will/might
           | happen later, but will be in the realm of understandable
           | things.
        
             | tambourine_man wrote:
             | Just keep adding closing parenthesis to the end of the
             | file. Eventually Emacs will greet you in HAL 9000 style.
        
       | riddley wrote:
       | Checkmate, athiests.
        
       ___________________________________________________________________
       (page generated 2024-07-02 23:00 UTC)