neovim / neovim

Vim-fork focused on extensibility and usability
https://neovim.io
Other
80.28k stars 5.5k forks source link

Vote on coding conventions #104

Closed davidzchen closed 10 years ago

davidzchen commented 10 years ago

Vote here (See results below)

As discussed in #66, we are holding a vote for the coding style that we will use as the basis as the coding convention for neovim. Let's keep this vote open until 11:59 PM PST on Wednesday, February 26.

How to vote

Please view the following Gists to view code samples in each of the coding styles. We are using ranked voting. To vote, rank the coding styles in order of preference and add a comment to this thread with your ranking. For example:

Google > Hybrid > LLVM > Python > Linux

After the vote closes, we will tally up the rankings and choose a winner using Borda count. @ZyX-I's script will be used to scrape these comments and compute the results using the Borda count algorithm.

Results

Short Name Name and Link Indent style Vote Score
Hybrid Hybrid coding style 2 spaces 158
LLVM LLVM coding style 2 spaces 152
Google Google C++ coding style 2 spaces 150
Linux Linux Kernel coding style tabs (width 8) 88
Python Python C coding style 4 spaces 85
Lua Lua C coding style 2 spaces 58

Update: per @tarruda's request, I have added the Lua C style to the ballot. If you prefer the Lua style, please update your votes.

Notes

davidzchen commented 10 years ago

Hybrid > Google > Python > Linux > LLVM

naseer commented 10 years ago

Hybrid > Google > LLVM > Python > Linux

(slight update - mistook Hybrid for mixed tabs + spaces, which it is not)

flugsio commented 10 years ago

Hybrid > Google > LLVM > Lua > Linux > Python

0X1A commented 10 years ago

Linux > Hybrid > LLVM > Google > Python

darthdeus commented 10 years ago

Linux > Hybrid > Google > LLVM > Python

scott-linder commented 10 years ago

Hybrid > Google > LLVM > Python > Linux

jiripospisil commented 10 years ago

Linux > Hybrid > Google > LLVM > Python

tarruda commented 10 years ago

@davidzchen I think you forgot to add the style of the cleanest codebase I've seen

AcidLeroy commented 10 years ago

Google > Hybrid > LLVM > Python > Linux

ghost commented 10 years ago

Linux -> LLVM -> Hybrid -> Python

fhahn commented 10 years ago

LLVM -> Linux -> Hybrid

davidzchen commented 10 years ago

@tarruda - I have added an entry for the Lua style. I'm not sure if I have time to make a sample code Gist for it this morning since I could not find a documentation describing the style, and as a result, added a link to the online Lua sources. If you would like to make a Gist for it, I can can add a link to it.

Everyone else - if you prefer the Lua style, please feel free to update your votes.

thynson commented 10 years ago

Hybrid -> Python

mdenchev commented 10 years ago

Hybrid -> Google

mtayler commented 10 years ago

LLVM > Lua > Google > Linux > Python > Hybrid

justinmk commented 10 years ago

The formatting of Lua's lmathlib.c is different than luac.c.

I think all of the styles are acceptable, except the 1-space indent of luac.c.

aktau commented 10 years ago

Lua > Google > Hybrid > LLVM > Linux > Python

So either Lua or Google-style with C-style comments (/* */).

I put Lua first but I'd actually like more newlines between logically separate parts of the code, like Google-style. I think I'm allowed to make this provision because I don't think it's usually part of the style conventions (tabs/spaces, braces-first, ...). An example:

Lua style without newlines (original)

int luaH_next (lua_State *L, Table *t, StkId key) {
  int i = findindex(L, t, key);  /* find original element */
  for (i++; i < t->sizearray; i++) {  /* try first array part */
    if (!ttisnil(&t->array[i])) {  /* a non-nil value? */
      setnvalue(key, cast_num(i+1));
      setobj2s(L, key+1, &t->array[i]);
      return 1;
    }
  }
  for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
    if (!ttisnil(gval(gnode(t, i)))) {  /* a non-nil value? */
      setobj2s(L, key, key2tval(gnode(t, i)));
      setobj2s(L, key+1, gval(gnode(t, i)));
      return 1;
    }
  }
  return 0;  /* no more elements */
}

Lua style with a few newlines for clarity:

int luaH_next (lua_State *L, Table *t, StkId key) {
  int i = findindex(L, t, key);  /* find original element */

  for (i++; i < t->sizearray; i++) {  /* try first array part */
    if (!ttisnil(&t->array[i])) {  /* a non-nil value? */
      setnvalue(key, cast_num(i+1));
      setobj2s(L, key+1, &t->array[i]);

      return 1;
    }
  }

  for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
    if (!ttisnil(gval(gnode(t, i)))) {  /* a non-nil value? */
      setobj2s(L, key, key2tval(gnode(t, i)));
      setobj2s(L, key+1, gval(gnode(t, i)));

      return 1;
    }
  }

  return 0;  /* no more elements */
}

I also dislike mixing comment styles a bit. In my own codebases I tend to use the default C /* */ style, which makes for aesthetically pleasing multiline comments that don't take extra space:

/* processes count items in array */
int func(void * arr, size_t count) {
    if (arr == NULL || count == 0) {
        return 0;
    }

    /* so, we're just going to return the count and act as if we've actually
     * done all the items, let's implement this later */
    return count;
}
ghost commented 10 years ago

Google > LLVM > Lua > Hybrid > Python > Linux

mtayler commented 10 years ago

Like @justinmk said, I really like lmathlib.c's style, but I'm not sure if we're voting based on the default style in most of them (1 space indentation), or of lmathlib.c (2 space indent). Other than that, all the options are good.

vheon commented 10 years ago

Hybrid > LLVM > Python > Google > Lua > Linux

tarruda commented 10 years ago

Isn't there some free service that simplifies conducting these kind of polls? Ideally it would have a date limit and one we could easily see the results.

simendsjo commented 10 years ago

@tarruda: There are hundreds. Search for "online poll" or something.

rjw57 commented 10 years ago

Hybrid > Python > Google > LLVM > Linux

scaduto1 commented 10 years ago

Linux > Hybrid > Google > LLVM > Python

davidzchen commented 10 years ago

@tarruda @simendsjo - Yes, there certainly are a lot of online poll services, but I think it would be ideal to have the vote data will be easily visible afterwards and in some way attached to this project. There are not that many rank poll services, but it would be possible to create a poll with a Google Doc form, but it may be a good idea to create an official neovim Google Group and use that account to create the Google Doc poll. We should go with that route in the future.

For this poll in particular, I suggested a deadline of 12 AM PST this Wednesday and will close the issue then. I think I'm going to write a Python script and scrape these comments and compute results and will post both the script and the results as Gists. Since many people have already responded, should we just continue here?

aktau commented 10 years ago

If somebody makes an online poll that's easy to use and where it's easy to login (perhaps with gh account), that'd be neat. Failing that, the scraping sounds like a good solution. The advantages are as mentioned: it's tied to github, where all code editing happens, and the voters all have a github account, probably/hopefully avoiding people spamming their favourite styles.

0x0L commented 10 years ago

Having an automated tool for style checking would make things easier for everyone whatever the chosen coding style is

commonquail commented 10 years ago

Hybrid > Google > LLVM > Lua > Python > Linux

ZyX-I commented 10 years ago

Python > Lua > Linux > LLVM > Hybrid > Google

0X1A commented 10 years ago

@x0l That could easily be done with a shell script

gilligan commented 10 years ago

@tarruda I put together a form using google docs https://docs.google.com/forms/d/1cOQPSUFBV5DWZebROiJIX-BaL_YJhKK6luEGXHpaTtQ/viewform

Are we going to have a poll if we should use that poll now ? ;-)

davidzchen commented 10 years ago

Guys, let's not adopt the Apache ways too quickly. ;)

@gilligan, thanks for setting up the Google doc!

But for the sake of keeping this as simple as possible, I am more in favor of just keeping the poll here for the reasons discussed above. Let's use Google Doc for all future polls. @tarruda, is this fine with you?

ZyX-I commented 10 years ago

Vote parser: https://bitbucket.org/ZyX_I/parsevotes/src/default/parsevotes.py.

ZyX-I commented 10 years ago

@tarruda

Please rank each style below. Note that you are not allowed to pick the same rank (1=best to 5=worst) for two different coding styles

I have successfully managed to give all ranks 1. Though I am not sure whether my vote was actually recorded there, but it did not give any error message.

gilligan commented 10 years ago

@ZyX-I There is no way to configure the poll like that. The disclaimer says 'not allowed to' as in 'you are not supposed to do this dummy' =) There is nothing that keeps you from writing a nonsense voting statement here in the comments. I was about to give an example but I guess I'd rather not because that might screw up the results of the python script..

Not ideal, but using the github issue tracker for a poll .. meh i dunno ;-) i should do something proper later but i'm on vacation in Turkey right now ... ;-}

ZyX-I commented 10 years ago

@gilligan You can write nonsense in comment, but that only means my parser will ignore such votes. Will Google Docs ignore them? Please give an example. I added protection right after complaining about Google Docs problem.

tbelaire commented 10 years ago

Hybrid > LLVM > Python > Google > Lua > Linux

ZyX-I commented 10 years ago

// Do not have a protection against duplicate votes. Will add it now.

ZyX-I commented 10 years ago

Python > Lua > Linux > LLVM > Hybrid > Google

^ For testing protection against duplicate votes. This comment should be ignored.

1100110 commented 10 years ago

LLVM > Hybrid > Python > Google > Lua > Linux

Coornail commented 10 years ago

LLVM > Hybrid > Google > Lua > Linux > Python

Gaelan commented 10 years ago

Hybrid = LLVM = Google > Lua > Linux > Python

ZyX-I commented 10 years ago

@Gaelan Your vote will be ignored. Voting system is not using =.

erinzm commented 10 years ago

Hybrid > LLVM > Lua > Python > Linux > Google

jszakmeister commented 10 years ago

Hybrid > Google > Python > Linux > Lua > LLVM

robertmeta commented 10 years ago

Ugh, Hybrid, Python and Lua are mostly useless to me (as someone trying to write automatic conversion code to actually do the cleanup in one pass). It isn't that I mind the styles but the ambiguity is DOOM.

Can we please reduce this list to the very well documented ones (LLVM, Linux, Google C++) AND add links to the full documentation. So that whoever has to do the reformatting has a chance in HELL of being successful without endless future debates. Additionally, the big ones often are baked into style lint and other tooling.

Drafting off well written, complete, tested in the wild standards (and in the case of LLVM, even related ideals) makes a lot of sense for a project already going against the grain and swimming upstream.

0X1A commented 10 years ago

@robertmeta I don't see the issue, most of it would be able to be converted with a script and regexp and the original post already has format examples

mdenchev commented 10 years ago

@ZyX-I Your vote parser adds any unsubmitted user rankings to the submitted ones in a way that gives them points. This isn't correct in that it's probably not what the submitters wanted and the actual winner could change when rerunning program without changing any of the input.

jesstelford commented 10 years ago

Google > LLVM > Python > Lua

mtayler commented 10 years ago

Should it be set to start at 5, and go down for each specified, with 0 for each non specified? Or should non-specified formats be set to the average so we don't skew it for others who did include it?

On Feb 24, 2014, at 8:08 PM, "Michail Denchev" notifications@github.com wrote:

@ZyX-I Your vote parser adds any unsubmitted user rankings to the submitted ones in a way that gives them points. This isn't correct in that it's probably not what the submitters wanted and the actual winner could change when rerunning program without changing any of the input.

— Reply to this email directly or view it on GitHub.