An Erlang IDE and interactive shell

Jeff Massung massung at gmail.com
Sun May 2 13:10:28 EDT 2010


On Sun, May 2, 2010 at 9:05 AM, Andre Garzia <andre at andregarzia.com> wrote:

>
> This is wonderful! Can you write some words on how you're communicating
> with
> the REPL, are you using something like "open process" or is it a TCP/IP
> exchange like SLIME & Friends.
>

I'm using open process with read/write process as well. There's just a
message loop running in the background periodically checking for more data
from the Erlang shell. Something akin to:

on pingShell
  if sErl is not among the lines of the openProcesses then
    exit pingShell
  end if

  read from process sErl until empty

  ## .. put it into the terminal shell and scroll it down ..

  send "pingShell" to me in 200 milliseconds
end pingShell



> About your colorization, is that a Rev field with some kind of HTMLText set
> with that disclosure triangle being an image or is it something like
> RevBrowser window?
>


It's just a simple Rev field. Nothing special about it other than there is
no background (it is not opaque and I turned off the showBorder property.
The background is just a rectangle graphic with a gradient applied to it.

Erlang syntax is pretty simple because it doesn't allow for multi-line
comments. For that reason, highlighting a single line as you type is fairly
trivial. I tokenize each line with a set of very simple regular expressions.
After the line is tokenized I end up with a token list that looks something
like this:

decl,1,8
keyword,10,14
string,21,34

After that, it's just a simple loop with a switch statement re-colorizing
the line based on the token type and where it happens to be.

As for the disclosure triangle, well, that's a bit of a joke for me and my
friends. Rev doesn't allow for color cursors [in 4.0] and I don't want to
use the developer preview quite yet, and with the dark background the mouse
can get lost in the editor. The triangle just follows the mouse so it's
easier to find. Once I get 4.5 and can drop in the color cursor I want it
will be much nicer.


I am building a little editor to talk to ARC (http://arclanguage.org) so I'd
> really like your thoughts!
>


Ah yes, Paul Graham's little toy. ;-)

If you haven't looked at it yet, I'd highly recommend Ypsilon over Arc (a
Scheme implementation that's quite exceptional).

Regardless of whatever language you use, something I implemented as a test
in my Erlang editor that turned into one heluva kick ass feature was
shift+return...

Basically, any line you are editing, just hit shift+return and it will
highlight and send that line to the REPL of the running shell so you can see
what happens (in Lisp/Scheme I'd probably take it a step further and make it
match the nearest ()'s and send the entire block of text).

Better still, my friends and I wanted to have a way of sending example code
over to the REPL as well within our sources without actually corrupting the
source file and breaking compilation. For that reason, I also made it so
that lines that were commented in a special way could also be sent over as
commands. It's amazing how much more readable the source code is when you
can directly show the reader how to use it and they can even test it out
immediately. For example (from the screenshot):

pips () -> [2,3,4,5,6,7,8,9,10,jack,queen,king,ace].
suits () -> [clubs,diamonds,hearts,spades].
deck () -> [{Pip,Suit} || Pip <- pips(), Suit <- suits()].

% Use deck() to generate a list of all cards...
%-poker:deck().

The "%" token is the beginning of a comment. But, if you begin your comment
with "%-" you can also execute it on the REPL by using shift+return. So you
can compile the code and try it out without editing anything. It has
improved productivity considerably!



> As for Erlang, I think it is really cool, almost bought that O'Reilly
> Erlang
> book last week, I have some concurrency problems to solve and the current C
> code is almost unmaintainable.
>


Erlang takes a little getting used to since it's functional. But the message
passing paradigm is quite powerful and the Erlang VM is unbelievably good at
handling thousands and thousands of processes running concurrently. If you
do anything with web servers, I'd recommend looking at Erlang as a web
server. It's wonderful.


Hope this helps,

Jeff M.



More information about the use-livecode mailing list