Faster Erlang Contextual Code Completion with erl_call

First off, why did I ever use TCP for the TextMate integration of An Erlang Contextual Code Completion Library? Could I not simply have started an escript to do the completion?

Here is why: Erlang's BEAM emulator takes more than a second to start up on my computer (1.42GHz PowerPC G4 Mac mini). Launching escript for each completion request would make it unacceptably slow for my own use so I cannot imagine others being impressed.

Originally I used a long-lived Erlang gen_tcp server to respond to TCP-based completion requests. This improved the performance remarkably. However, I suspected I could do better so I looked to have faster communication between TextMate and Erlang.

Recently I refactored erlang_code_completion to use erl_call instead of TCP. Originally it had been using TCP for communication between TextMate and the Completion Server. Now it is using erl_call to bootstrap and make Remote Procedure Calls [RPCs] from a Ruby client command in TextMate to the tm_complete module. This yielded a significant drop in the completion lag. It now yields completions in under one tenth of a second.

I recommend erl_call to anyone looking for a fast convenient way to access Erlang functionality in scripts. This refactor mostly involved deleting unnecessary code so the cost of moving to erl_call in an existing system should be pretty small. Overall I think it makes the system simpler and the Ruby client code more comprehensible. I hope it will make it easier for others to code up support for their favorite editor with erlang_code_completion.

What does the future hold for Erlang Code Completion? I hope to find a good type-ahead menu for TextMate. I also hope to find a way to have the documentation for a completion float alongside the menu. Combining these two things will deliver a more rich IDE-like experience. I also plan to add support for local 'private' function completion and local variable completion.