a new editor could help scala's tooling situation

93 views
Skip to first unread message

James Keats

unread,
Aug 2, 2011, 6:01:25 PM8/2/11
to scala-debate

Hi all. I debated myself for a minute whether this belongs in scala
tools or the debate list here, but decided to go for the debate list
as I wish to argue that with scala being such a concise language a
heavyweight IDE may not all that necessary. With regard to editors,
vim and emacs are fine with those who know them already but are a
steep learning curve for those who don't. There's a new little scite-
like editor that I believe could possibly help with scala's tooling
situation, as it follows modern keyboard/ide conventions, is quite
small, is very open and scriptable (it's mostly written in lua, which
has a very scala-like syntax!), and best of all it uses lua's parser
expression grammars, which may be able to cope better with parsing
scala code. (or perhaps integrating the scala compiler with the editor
somehow, or a client (editor) server (compiler) design might work ala
emacs ensime). The editor has an MIT license and it's code (mostly lua
code with less than 2000 c lines) is very well commented.

Please have a look at these

http://code.google.com/p/textadept/
http://caladbolg.net/luadoc/textadept/manual/1_Introduction.html
http://www.inf.puc-rio.br/~roberto/lpeg/
https://github.com/stevej/sctags
http://groups.google.com/group/textadept/browse_frm/thread/f2885009488ad2cc

James Keats

unread,
Aug 2, 2011, 6:08:58 PM8/2/11
to scala-debate


On Aug 2, 11:01 pm, James Keats <james.w.ke...@gmail.com> wrote:
> Hi all. I debated myself for a minute whether this belongs in scala
> tools or the debate list here, but decided to go for the debate list
> as I wish to argue that with scala being such a concise language a
> heavyweight IDE may not all that necessary.

Hmmm, I'm now wondering whether I should've actually posted it to
tooling. Well, a main reason I posted it here is the recent thread
about jetbrain's kotlin in this group. This is a far more active list
and I thought this post may get more attention here as tooling support
for scala is a barrier to its wider adoption. Maybe I should cross-
post it, or maybe not, as this is probably frowned upon. :-)

Philippe Lhoste

unread,
Aug 3, 2011, 6:21:02 AM8/3/11
to scala-...@googlegroups.com

I know the existence of TextAdept, although I haven't tried it yet.
For the record, it is based on Scintilla, a source code editing
component written in C++, working on all major platforms (with perhaps
some restrictions for Mac ones, although professional/paid support is
coming). Well, to say that display is thus fast and good (Scintilla is
used by lot of editors, like Geany (AFAIK) and Notepad++).

The problem is that nobody (to my knowledge) wrote a Scala lexer in
Lpeg, so it remains a work to be done...

For the record, I mentioned a couple of times (without much reactions)
that I wrote a (classical, in C++) lexer for Scala for Scintilla, which
I currently use with SciTE. The latter being another of those
lightweight editors you mention: it allows me to compile the current
file with fsc with a single keystroke. BTW, there is an annoying problem
with fsc, I will come back to it later.

My lexer is incomplete, that's why I haven't released it yet: the XML
literals with Scala code in placeholders is a bit hard to tackle. I
should rewrite it in the moderner style of Scintilla lexers (I used the
old style because I am more used to it, and I wanted a quick job to hack
Scala).

I have looked a bit at Esime, it would be great to integrate it with
SciTE, but even if some people were successful in integrating with other
editors, I find the information to do it (ie. to use Ensime as a pure
information server) a bit lacking (or I just failed at finding it).


About fsc: it has a surprising behavior, quite annoying. I won't jump
and call it bug, but if that's a feature, it is under documented and not
very useful...

When I compile a small file (so far I don't have big projects in Scala,
mostly small experiments here and there) in directory A with fsc, if I
move to directory B (eg. sharing the same parent than A) and try to
compile another small file, it tells me that this file doesn't exist,
even if I can list it. Looks like the first time it is launched, it
memorize the current path (setting it as classpath?), and refuses to
acknowledge the current path has changed. I suppose I can reset it, but
it is just plain annoying.

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

James Keats

unread,
Aug 3, 2011, 10:43:40 AM8/3/11
to scala-debate

I've heard of geany, but wasn't aware that it too was a scintilla-
scite like editor. I don't know why I'd assumed it was a gedit-like
one. When I looked at it it said it needed scala done, so I gave it a
miss. :-)

I'm really impressed by textadept so far. From what little I looked at
it appears to have a far higher lua/c-cpp ratio than scite. The code
is well documented too. I had concerns about it being too slow with
big/many files, but the just released version 4 beta seems to solve
this with much better performance; it's fast! With regard to an lpeg
lexer for scala, there is one already in textadept. It comes included
in the standard distribution, though you'll need to set a scala mime-
type configuration (look at the link I posted - its discussion group,
that's easily done and i'll submit a patch about it, it's just 3
words). It isn't much, but it'd be a good starting point for
expansion.

I also watched the lpeg talk by Roberto (of lua). He said that lpeg is
more oriented towards pattern matching than parsing. I think it'll
probably suffice nonetheless and would be far more powerful than
regular expressions. I looked at emacs' scala mode, and if i'm not
mistaken it does seem to use regular expressions (I noticed a related
defmacro there). In any case lpeg isn't much code, it could be patched
if need be.

I'm not sure about ensime. I'll want to have a look at it for sure,
its source code and et cetera, but I'm tempted to do that bit anew,
from scratch. I'll probably have an opinionated take on it.
Autocompletion aside, i'm not at all a fan of in-editor information. I
find it distracting, gets in the way, and quite likely slows things
down a lot, for for coder and the editor's performance itself. I would
much prefer an ajaxy scaladoc window that gets updated depending on
context. This would make it more amenable to proper formatting for
ease of reading and reference. Scaladoc's html is already beautifully
formatted and rendered.

I'm really tempted to do this. I'll have a look at lua, lpeg, read the
relevant sources of textadept, ensime, scala and so on. I make no
promises, I may get sidetracked by other things I have to
simultaneously juggle, but the prospect of doing this excites me a
bit. :-)

On Aug 3, 11:21 am, Philippe Lhoste <Phi...@GMX.net> wrote:
> On 03/08/2011 00:01, James Keats wrote:
>
>
>
>
>
>
>
>
>
> > Hi all. I debated myself for a minute whether this belongs in scala
> > tools or the debate list here, but decided to go for the debate list
> > as I wish to argue that with scala being such a concise language a
> > heavyweight IDE may not all that necessary. With regard to editors,
> > vim and emacs are fine with those who know them already but are a
> > steep learning curve for those who don't. There's a new little scite-
> > like editor that I believe could possibly help with scala's tooling
> > situation, as it follows modern keyboard/ide conventions, is quite
> > small, is very open and scriptable (it's mostly written in lua, which
> > has a very scala-like syntax!), and best of all it uses lua's parser
> > expression grammars, which may be able to cope better with parsing
> > scala code. (or perhaps integrating the scala compiler with the editor
> > somehow, or a client (editor) server (compiler) design might work ala
> > emacs ensime). The editor has an MIT license and it's code (mostly lua
> > code with less than 2000 c lines) is very well commented.
>
> > Please have a look at these
>
> >http://code.google.com/p/textadept/
> >http://caladbolg.net/luadoc/textadept/manual/1_Introduction.html
> >http://www.inf.puc-rio.br/~roberto/lpeg/
> >https://github.com/stevej/sctags
> >http://groups.google.com/group/textadept/browse_frm/thread/f288500948...

Adriaan Moors

unread,
Aug 3, 2011, 11:08:44 AM8/3/11
to James Keats, scala-debate
also check out sublime text 2 -- it's pretty customizable, modern and cross-platform

James Keats

unread,
Aug 3, 2011, 11:54:57 AM8/3/11
to scala-debate


Hi, thanks for the reply. It doesn't seem to be free (free to download
but continued use requries buying a license). It also doesn't seem to
be open source. So that rules it out as a starting point for a
lightweight scala IDE. I think I'll go ahead with coding one based on
textadept. :-)

Adriaan Moors

unread,
Aug 4, 2011, 8:50:07 AM8/4/11
to James Keats, scala-debate
I would think you don't actually need to change the editor itself: it should be enough to integrate ENSIME using the editor's plug-in system, as people have done for emacs and textmate
Reply all
Reply to author
Forward
0 new messages