You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@esme.apache.org by Vassil Dichev <vd...@apache.org> on 2009/11/12 12:44:37 UTC

Scala style guide

There is an extensive and amazing Scala style guide offered by Daniel Spiewak:

http://permalink.gmane.org/gmane.comp.lang.scala/18295

I didn't find anything I disagree with, so I propose to adopt it as
the official ESME style guide. The guide seems to be just the first
draft, so proposals are welcome too.

Re: Scala style guide

Posted by David Pollak <fe...@gmail.com>.
On Tue, Nov 17, 2009 at 2:11 AM, Vassil Dichev <vd...@apache.org> wrote:

> > What I don't like about IDEs is that they often gratuitously format
> > your code, assuming everyone must have the same preferences, and
> > there's no way to configure it (or at least few people do). For
> > instance, in several of the ESME files I can already see that
> > indentation spaces are substituted by 8 tabs, which looks pretty awful
> > with my settings (tab=2 spaces). Besides, this is against any Scala
> > conventions that I've seen.
>
> To clarify, I don't mean that I don't recommend IDEs, I just think
> it's harder to solve the problem of more or less uniform style. Many
> IDEs are flexible enough to configure formatting details on a
> fine-grained level. The problem is, we can't force everyone to use the
> same IDE, or to use an IDE at all, for that matter :)
>
> It would be interesting to have a command-line tool to do optional
> formatting. I don't see anything like that for Scala, which is similar
> to what e.g. Jalopy did for Java.
>

Yeah... I'd love a command-line Scala formatting tool.



-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Re: Scala style guide

Posted by Vassil Dichev <vd...@apache.org>.
> What I don't like about IDEs is that they often gratuitously format
> your code, assuming everyone must have the same preferences, and
> there's no way to configure it (or at least few people do). For
> instance, in several of the ESME files I can already see that
> indentation spaces are substituted by 8 tabs, which looks pretty awful
> with my settings (tab=2 spaces). Besides, this is against any Scala
> conventions that I've seen.

To clarify, I don't mean that I don't recommend IDEs, I just think
it's harder to solve the problem of more or less uniform style. Many
IDEs are flexible enough to configure formatting details on a
fine-grained level. The problem is, we can't force everyone to use the
same IDE, or to use an IDE at all, for that matter :)

It would be interesting to have a command-line tool to do optional
formatting. I don't see anything like that for Scala, which is similar
to what e.g. Jalopy did for Java.

Re: Scala style guide

Posted by Vassil Dichev <vd...@apache.org>.
What I don't like about IDEs is that they often gratuitously format
your code, assuming everyone must have the same preferences, and
there's no way to configure it (or at least few people do). For
instance, in several of the ESME files I can already see that
indentation spaces are substituted by 8 tabs, which looks pretty awful
with my settings (tab=2 spaces). Besides, this is against any Scala
conventions that I've seen.


On Thu, Nov 12, 2009 at 4:39 PM, David Pollak
<fe...@gmail.com> wrote:
> On Thu, Nov 12, 2009 at 4:41 AM, Richard Hirsch <hi...@gmail.com>wrote:
>
>> What about doing the formatting in two steps. The first step is
>> automatic and includes dealing with stuff like identing and creating
>> empty  method headers.  You could probably use existing IDE formatters
>> for that.  The second step would be the manual process and would
>> reflect the Style Guide suggestions.
>>
>
> I'm thinking that the style guide's recommendations will likely be
> integrated with IntelliJ 9's Scala plugin.  Ilya has been looking for
> something to build his code formatter on and I think this document may
> provide the best guide for him.
>
> If we can build new code going forward based on the style guide and then
> "backport" the rest of the code when the tooling is available, I think that
> may be the best use of resources.
>
> Thanks,
>
> David
>
> PS -- I think the style guide is stellar!
>
>
>>
>> D.
>>
>> On Thu, Nov 12, 2009 at 1:30 PM, Vassil Dichev <vd...@apache.org> wrote:
>> >> Took a look at the guide and it looks good. The question is: do we
>> >> wait for code beautifier that is based on the guide or do we do format
>> >> our code ourselves?
>> >
>> > I'm not sure there's a non-interactive code beautifier which we can
>> > configure (formatting in IDEs hardcodes many configurations). Besides,
>> > since Scala syntax is still a moving target, I'm not sure anyone has
>> > focused on creating such a beautifier just yet. In a word: we should
>> > format ourselves.
>> >
>> > But a great idea for a hobby project ;-)
>> >
>>
>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>

Re: Scala style guide

Posted by David Pollak <fe...@gmail.com>.
On Thu, Nov 12, 2009 at 4:41 AM, Richard Hirsch <hi...@gmail.com>wrote:

> What about doing the formatting in two steps. The first step is
> automatic and includes dealing with stuff like identing and creating
> empty  method headers.  You could probably use existing IDE formatters
> for that.  The second step would be the manual process and would
> reflect the Style Guide suggestions.
>

I'm thinking that the style guide's recommendations will likely be
integrated with IntelliJ 9's Scala plugin.  Ilya has been looking for
something to build his code formatter on and I think this document may
provide the best guide for him.

If we can build new code going forward based on the style guide and then
"backport" the rest of the code when the tooling is available, I think that
may be the best use of resources.

Thanks,

David

PS -- I think the style guide is stellar!


>
> D.
>
> On Thu, Nov 12, 2009 at 1:30 PM, Vassil Dichev <vd...@apache.org> wrote:
> >> Took a look at the guide and it looks good. The question is: do we
> >> wait for code beautifier that is based on the guide or do we do format
> >> our code ourselves?
> >
> > I'm not sure there's a non-interactive code beautifier which we can
> > configure (formatting in IDEs hardcodes many configurations). Besides,
> > since Scala syntax is still a moving target, I'm not sure anyone has
> > focused on creating such a beautifier just yet. In a word: we should
> > format ourselves.
> >
> > But a great idea for a hobby project ;-)
> >
>



-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Re: Scala style guide

Posted by Richard Hirsch <hi...@gmail.com>.
What about doing the formatting in two steps. The first step is
automatic and includes dealing with stuff like identing and creating
empty  method headers.  You could probably use existing IDE formatters
for that.  The second step would be the manual process and would
reflect the Style Guide suggestions.

D.

On Thu, Nov 12, 2009 at 1:30 PM, Vassil Dichev <vd...@apache.org> wrote:
>> Took a look at the guide and it looks good. The question is: do we
>> wait for code beautifier that is based on the guide or do we do format
>> our code ourselves?
>
> I'm not sure there's a non-interactive code beautifier which we can
> configure (formatting in IDEs hardcodes many configurations). Besides,
> since Scala syntax is still a moving target, I'm not sure anyone has
> focused on creating such a beautifier just yet. In a word: we should
> format ourselves.
>
> But a great idea for a hobby project ;-)
>

Re: Scala style guide

Posted by Vassil Dichev <vd...@apache.org>.
> Took a look at the guide and it looks good. The question is: do we
> wait for code beautifier that is based on the guide or do we do format
> our code ourselves?

I'm not sure there's a non-interactive code beautifier which we can
configure (formatting in IDEs hardcodes many configurations). Besides,
since Scala syntax is still a moving target, I'm not sure anyone has
focused on creating such a beautifier just yet. In a word: we should
format ourselves.

But a great idea for a hobby project ;-)

Re: Scala style guide

Posted by Richard Hirsch <hi...@gmail.com>.
Took a look at the guide and it looks good. The question is: do we
wait for code beautifier that is based on the guide or do we do format
our code ourselves?

D.

On Thu, Nov 12, 2009 at 12:44 PM, Vassil Dichev <vd...@apache.org> wrote:
> There is an extensive and amazing Scala style guide offered by Daniel Spiewak:
>
> http://permalink.gmane.org/gmane.comp.lang.scala/18295
>
> I didn't find anything I disagree with, so I propose to adopt it as
> the official ESME style guide. The guide seems to be just the first
> draft, so proposals are welcome too.
>