Create account / Log in

End-of-line (newline) characters for files

Discussion area for the development team.

Moderator: bsmith

Re: End-of-line (newline) characters for files

Postby pgeerkens » October 29th, 2011, 9:02 am

re:
The right way to do this is to set your Windows' font size. If you're using Windows 7, just open a "Windows Explorer" window, and enter for its address this: "Control Panel\Appearance and Personalization\Display" (without quotes). You can then get Windows to display fonts larger (say 150%).
There's a reason for 2-space code format policy. Traditionally, it is to produce more compact code pages; having a printout showing wide tabs/indents will mean more paper to carry around for a given amount of code. But that is moot now, since we are "paperless". We need to respect the project owner's preference, given that it is reasonable, when it comes to code formatting. Personally, I think 4-space indents is better for most people (my eyes are keen, so I don't care).

There is no need to be insulting or rude. If you don't brand me a heretic for 3-space indents, I won't brand you one for insisting on ridiculously large margins and font sizes.

Actually, I believe the real reason for narrow newspaper columns is to disguise that they are written at a grade-5 reading level.
Pieter
-----------------------------------------
"Even on the attack, I found the spade [to be] the equal of the rifle."
Erwin Rommel, Infantry Attacks
User avatar
pgeerkens
 
Posts: 228
Joined: September 12th, 2010, 4:33 am
Location: Hamilton, Ontario, Canada

Re: End-of-line (newline) characters for files

Postby viewofheaven » October 29th, 2011, 2:16 pm

pgeerkens wrote:re:
The right way to do this is to set your Windows' font size. If you're using Windows 7, just open a "Windows Explorer" window, and enter for its address this: "Control Panel\Appearance and Personalization\Display" (without quotes). You can then get Windows to display fonts larger (say 150%).
There's a reason for 2-space code format policy. Traditionally, it is to produce more compact code pages; having a printout showing wide tabs/indents will mean more paper to carry around for a given amount of code. But that is moot now, since we are "paperless". We need to respect the project owner's preference, given that it is reasonable, when it comes to code formatting. Personally, I think 4-space indents is better for most people (my eyes are keen, so I don't care).

There is no need to be insulting or rude. If you don't brand me a heretic for 3-space indents, I won't brand you one for insisting on ridiculously large margins and font sizes.

Yikes! I must have expressed myself wrong! I didn't mean to be insulting at all!

But seriously, the right way to do it is to increase the Windows font size. I do that all the time with my smaller 21-inch monitors (am too used to 32-inch monitors when at home, good for eyes, won't cause strain which leads to myopia, I believe).

I'm not sure if we're on the same page regarding SVN (and other version-control) repository management. But there really are valid reasons for spaces (not tabs), as Joel had mentioned. These reasons are here to stay because most all of us have learned our lessons, and learned them painfully in most cases. A straightforward way to understand that painful lesson is this: anything that can be interpreted in more ways than one isn't written right. In short, such a thing is called "vague". For eg, a tab can be interpreted as 1-inch or 4-inches, depending on the editor.

Likewise, to further illustrate that "anything that can be interpreted in more ways than one isn't written right", and that also means "vague"... I'll attempt to apologize for any possibility that my message was rude or insulting. As can be seen, my message was possibly vague enough that it is construed as rude by you, though construed as well-meaning by myself. (That is, I meant to make things easier for Joel, as well as assist you in adjusting to a tried-and-true practice). And that's that! My previous message was a perfect example of a message that is just not right, since it can be interpreted in more ways than one!

If you're thinking that my explaining how to use Windows is being condescending, you should know that I just recently learned Windows 7! No, I never went to Vista. I stuck with WinXP and avoided Vista like the plague. I thought you might be as unfamiliar with Windows 7 as I am! Many people avoided Vista like the plague. Plus, I never was much good with Windows.

About 4-space indents, it actually is a norm for Java code. I don't know why. Maybe it has a reason tied to being Object-Oriented, not sure. I only know that most people I work with hate 2-space indents (except hardcore masochistic veteran coders, I think).

As for 3-space indents, I don't know why 2-space and 4-space were the norms in the first place. Maybe 2-space was better than 1-space, and the new exercise to "increase the indent" simply doubled the 2-space (equals 4-space) indent?

pgeerkens wrote:Actually, I believe the real reason for narrow newspaper columns is to disguise that they are written at a grade-5 reading level.

Oh. So that's why grammar errors are the norm there? Hmm. I always thought newspaper folks were rushed for time, and language mistakes were somewhat forgivable. Gosh, my grade-5 English must be bad. Even now, most words in newspapers are beyond me. (I'm not a native English-speaker, by the way).
viewofheaven
 
Posts: 80
Joined: October 14th, 2011, 6:24 am

Re: [messages] [Developers] Re: End-of-line (newline) charac

Postby uckelman » October 31st, 2011, 9:50 pm

Thus spake pgeerkens:
>
> Agreed that Notepad is suitable only for very quick and very dirty work,
> given other choices, but it is occasionally useful. I once was a __vi__
> pro, but that was almost before you were born. :D My finger still
> understand h-j-k-l though.
>

I use Vim more than any other single application. Why'd you stop using
vi?

--
J.
User avatar
uckelman
Site Admin
 
Posts: 7228
Joined: December 10th, 2007, 9:48 am
Location: Heidelberg, DE

Re: [messages] [Developers] Re: End-of-line (newline) charac

Postby uckelman » October 31st, 2011, 9:53 pm

Thus spake viewofheaven:
>
> "pgeerkens" wrote:
> > I will remember harder to to only use tabs for block indentation, and
> > not internal to a line.
>
> It will be fine if you set Eclipse to "convert tabs to spaces", then you
> can tab all you want! That way, you can have all the spacing you want
> (eg 4 spaces) within any line, between any code elements, which makes
> for easier viewing.

If I understand what "convert tabs to spaces does", then this doesn't
address Pieter's point. He'd like to have 3-space indentation, but this
setting will have no effect if there are no tabs in our files.

--
J.
User avatar
uckelman
Site Admin
 
Posts: 7228
Joined: December 10th, 2007, 9:48 am
Location: Heidelberg, DE

Re: [messages] [Developers] Re: End-of-line (newline) charac

Postby uckelman » October 31st, 2011, 9:57 pm

Thus spake viewofheaven:
>
> There's a reason for 2-space code format policy. Traditionally, it is to
> produce more compact code pages; having a printout showing wide
> tabs/indents will mean more paper to carry around for a given amount of
> code. But that is moot now, since we are "paperless". We need to respect
> the project owner's preference, given that it is reasonable, when it
> comes to code formatting. Personally, I think 4-space indents is better
> for most people (my eyes are keen, so I don't care).

My reason for 2-space indent is that it keeps indentation from becoming
too deep too quickly. Two spaces is by far the most common indentation
policy in code I see these days.

> There's also another code format policy mandating "max width of lines".
> Usually, this is 79 characters thereabouts. Again, it makes for easy
> printouts. But more importantly, it makes for easy reading even when on
> screen. Note how newspapers print columns narrow, so our eyes don't have
> to scan a mile across! Now, this I feel strongly about.
>
> So, in short:
>
>
> * Spaces for tabs (MUST)
> * 2-space vs 4-space indents (OPTIONAL)
> * 79-character max line width (MUST)

I'm pretty adamant about having 2-space indentation in the code as
stored in the repo. I think the solution to Pieter's problem is a code
formatter.

--
J.
User avatar
uckelman
Site Admin
 
Posts: 7228
Joined: December 10th, 2007, 9:48 am
Location: Heidelberg, DE

Re: [messages] [Developers] Re: [Developers] Re: Edit: [Deve

Postby uckelman » October 31st, 2011, 10:09 pm

Thus spake viewofheaven:
>
> "uckelman" wrote:
> >
> > "viewofheaven" wrote:
> > > The file for which I just submitted a suggested patch:
> > > EnumeratedPropertyPrompt.java
> >
> > I checked this file from trunk@7961 in a hex editor and found no 0x0D
> > anywhere. Where exacty is the \r you're seeing?
>
> Every single line! I used XVI32 (hex editor) to check it too, and found
> the same thing that my Emacs showed me.
>
> Is anyone else seeing this? Is my TortoiseSVN doing a number on me? My
> checkout of trunk shows a good 50% of files with CRLF and the other 50%
> with LF. No mixture of CRLF and LF within any single file, though.
>

I checked again just to be sure. I see no CRs there at all.

> "pgeerkens" wrote:
> > I recently stumbled on some html files in the tree recently that must
> > have had only LF after downloading
>
> This is a vital clue! On Windows 7 TortoiseSVN, a checkout does not seem
> to auto-convert all line endings to anything else. On Windows 7 Cygwin
> SVN, there __does seem__ to be an auto-conversion of line endings to LF.
> So that could explain why Joel isn't seeing the CRLF on checkout?

I'm not using Cygwin. I'm not even using Subversion everywhere. I am for
3.1, but for the trunk, I'm using git as a Subversion client. I see no
CRs in either one.

> We should put up comprehensive code formatting policies, and HowTo(s)
> (for various IDEs) to adhere to such policies. That should make it easy
> for every developer to adhere to the code formatting policy.

I intend to do this for V4.

--
J.
User avatar
uckelman
Site Admin
 
Posts: 7228
Joined: December 10th, 2007, 9:48 am
Location: Heidelberg, DE

Re: End-of-line (newline) characters for files

Postby pgeerkens » October 31st, 2011, 11:08 pm

Nothing against vi - I would still use it in the right circumstance, and have once or twice installed it (and sed) to windows - but I stopped working for companies that coded for UNIX. Also, the functionality gap between vi and other code editors narrowed.
Pieter
-----------------------------------------
"Even on the attack, I found the spade [to be] the equal of the rifle."
Erwin Rommel, Infantry Attacks
User avatar
pgeerkens
 
Posts: 228
Joined: September 12th, 2010, 4:33 am
Location: Hamilton, Ontario, Canada

Re: [messages] [Developers] Re: [Developers] Re: Edit: [Deve

Postby viewofheaven » November 1st, 2011, 12:19 pm

uckelman wrote:I'm not using Cygwin. I'm not even using Subversion everywhere. I am for 3.1, but for the trunk, I'm using git as a Subversion client. I see no CRs in either one.

Well, how about Windows 7 with TortoiseSVN? Have you checked that? I really am sure there are CRLF in 50% of the files.

If it were all CRLF, I would think there's been some auto-conversion upon check out. But there are CRLF in just 50% of the files.

Anyway, I'll just commit my changes using LF for whatever files I'm committing.

Was just trying to give you a heads up regarding possible corruption of line endings in SVN repos.
viewofheaven
 
Posts: 80
Joined: October 14th, 2011, 6:24 am

Re: [messages] [Developers] Re: [Developers] Re: [Developers

Postby uckelman » November 1st, 2011, 12:41 pm

Thus spake viewofheaven:
>
> "uckelman" wrote:
> > I'm not using Cygwin. I'm not even using Subversion everywhere. I am
> > for 3.1, but for the trunk, I'm using git as a Subversion client. I
> > see no CRs in either one.
>
> Well, how about Windows 7 with TortoiseSVN? Have you checked that? I
> really am sure there are CRLF in 50% of the files.

I can't, I don't have access to Windows 7.

> Anyway, I'll just commit my changes using LF for whatever files I'm
> committing.
>
> Was just trying to give you a heads up regarding possible corruption of
> line endings in SVN repos.

I appreciate the notice, but this should be ok, really, since every text
editor that anyone codes in can handle it.

--
J.
User avatar
uckelman
Site Admin
 
Posts: 7228
Joined: December 10th, 2007, 9:48 am
Location: Heidelberg, DE

Re: [messages] [Developers] Re: [Developers] Re: [Developers

Postby viewofheaven » November 1st, 2011, 10:58 pm

uckelman wrote:
viewofheaven wrote:Was just trying to give you a heads up regarding possible corruption of line endings in SVN repos.

I appreciate the notice, but this should be ok, really, since every text
editor that anyone codes in can handle it.

Actually, I was worried about inconsistent character codes (for line endings) in SVN repos. That could throw us some problems later on. At the least, it means a systemic irregularity that should be resolved, much like how "tabs must always be represented by spaces, or vice versa, all the time, choose one or the other".

Another file that has CRLF: PieceMover.java in package "VASSAL.build.module.map".

I'll commit my changes in LF, as per the standard SVN repos practice.
viewofheaven
 
Posts: 80
Joined: October 14th, 2011, 6:24 am

Re: End-of-line (newline) characters for files

Postby uckelman » November 2nd, 2011, 8:59 pm

I think astyle might be the code formatter we're looking for.
User avatar
uckelman
Site Admin
 
Posts: 7228
Joined: December 10th, 2007, 9:48 am
Location: Heidelberg, DE

Previous

Return to Developers

Who is online

Users browsing this forum: Google [Bot] and 1 guest