LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Writing source code: VT or GUI? (https://www.linuxquestions.org/questions/programming-9/writing-source-code-vt-or-gui-896960/)

MTK358 08-12-2011 01:54 PM

I tried proportional fonts for programming, and maybe they are more readable, but the fact that it's not like a 2D grid any more just has too many disadvantages. For example, here are some things that I do often in my code that aren't possible (or look really ugly) with proportional fonts:

Headers like this can't be made all the same length:

Code:

// Example ////////////////////////////////////////////
You can't neatly align long function parameters on multiple lines, like this:

Code:

someFunction(reallyLongParameter,
            example,
            test);

And you can't align comments that are to the right of your code, like this:

Code:

i=0;                  // counter variable
for (i=0; i<10; i++) { // iterate from 0 to 9 (inclusive)
    printf("%i\n");    // print the counter's value
}

And finally, Vim (the editor I use most of the time for programming) doesn't support proportional fonts.

SigTerm 08-12-2011 02:12 PM

1 Attachment(s)
Quote:

Originally Posted by MTK358 (Post 4441136)
I tried proportional fonts for programming, and maybe they are more readable, but the fact that it's not like a 2D grid any more just has too many disadvantages. For example, here are some things that I do often in my code that aren't possible (or look really ugly) with proportional fonts:

Headers like this can't be made all the same length:

Code:

// Example ////////////////////////////////////////////
You can't neatly align long function parameters on multiple lines, like this:

Code:

someFunction(reallyLongParameter,
            example,
            test);

And you can't align comments that are to the right of your code, like this:

Code:

i=0;                  // counter variable
for (i=0; i<10; i++) { // iterate from 0 to 9 (inclusive)
    printf("%i\n");    // print the counter's value
}


Can be easily done, you need IDE with elastic tabs support. See attachment. The only "trick" is to use tabs instead of spaces for idents.

Quote:

Originally Posted by MTK358 (Post 4441136)
And finally, Vim (the editor I use most of the time for programming) doesn't support proportional fonts.

Are you certain? I vaguely recall launching either gvim or xemacs with proportional font support few years ago on linux.

MTK358 08-12-2011 02:37 PM

1 Attachment(s)
Quote:

Originally Posted by SigTerm (Post 4441152)
Can be easily done, you need IDE with elastic tabs support. See attachment. The only "trick" is to use tabs instead of spaces for idents.

Can Vim support elastic tabstops?

Quote:

Originally Posted by SigTerm (Post 4441152)
Are you certain? I vaguely recall launching either gvim or xemacs with proportional font support few years ago on linux.

I attached a screenshot of GVim with the font set to DejaVu Serif. It still treats the characters as if they have the same width.

SigTerm 08-12-2011 02:54 PM

Quote:

Originally Posted by MTK358 (Post 4441170)
Can Vim support elastic tabstops?

Well, even if it doesn't support them, you could probably hack it to add support (the difficulty is hard to estimate, though - I haven't read vim's source). I don't use gvim for development (only for emergency situations), and I don't see the reason to use only vim for development.

Quote:

Originally Posted by MTK358 (Post 4441170)
I attached a screenshot of GVim with the font set to DejaVu Serif. It still treats the characters as if they have the same width.

Then I guess it was XEmacs.

jcmlq 08-12-2011 03:44 PM

Am I still considered a gui user if I mostly use the gui as a place to keep 4 or 5 urxvts running screen in order to use vim and shell tools? :)

theNbomr 08-12-2011 04:35 PM

Quote:

Am I still considered a gui user if I mostly use the gui as a place to keep 4 or 5 urxvts running screen in order to use vim and shell tools?
You make it sound like something to be ashamed of. It isn't. Those things are made for a purpose.

--- rod.

jcmlq 08-12-2011 05:05 PM

Quote:

Originally Posted by theNbomr (Post 4441258)
You make it sound like something to be ashamed of. It isn't. Those things are made for a purpose.

Yeah, I just find it funny that the latest and greatest tech seems to serve best by being used as a platform for technology that's older than dirt.

Proud 08-12-2011 05:27 PM

It's all chill, chaps, Sigterm's entitled to his curt but clear replies to my statements as much as I was entitled to make them in the first place.

He's clearly blind and wrong, but entitled to his opinion ;)
Actually, not joking 100%, dude what is that font, how can we talk about any readability when you're suffering that utter lack of anti-aliasing/sub-pixel rendering?!

As for verbose naming schemes, we can be verbose in any font so you seem to be confusing the issue by mentioning separaters like _, and I'm not sure I agree with your logic. I'd assume my brain would be tuned to best pick up these natural words when they're correctly separated in normal prose, rather than run together lines of characters. Therefore, I don't think it would be any easier to read concatenated words (assuming no separators) if they could have varying minor spacing around/between them, rather than having a consistant pixel position for their ends as with a monospaced font. As with that trick of shuffling a word's inner characters, leaving only the first and last ones unchanged, and the word still being almost as readable, if you remove the end hints, you brain surely has far more permutations to search/match.

Perhaps a bad example:
togetherthereherheretheirtogather
togetherthereherheretheirtogather

I have written some C++, and use similarly-styled imperative languages (Java, C#, PHP, JS, etc), but also done functional programming like Haskell, and fear how one of the most fun languages, Python, would appear without monospaced fonts. Perhaps not an issue, but I don't think I'm about to try it.

Would proportional fonts really interfere with e.g. 4space tabs aligning things? Because that does sound 'game-breaking' for programming.
I seemed to have missed you clarifying in post 17 that it would not, unless I'm mistaken.

Block selection/edit mode is beast when you need it.

konsolebox, you know Notepad++ is Scintilla-based, and that there are cross-platform varients so that you don't need Wine, right?

MrCode 08-12-2011 06:16 PM

I voted GUI, since Geany is my main editor/IDE for what little tinkering I do (though I compile in a separate X terminal), but I occasionally use nano for quick editing.

I can use vi(m), but I don't really know all the ins and outs of it; all I really know are the basic line/word manipulation comands (d(n)w, dd, p), and (w)q(!).

Yes, I'm an editor weenie.

SigTerm 08-12-2011 07:01 PM

Quote:

Originally Posted by Proud (Post 4441286)
Actually, not joking 100%, dude what is that font, how can we talk about any readability when you're suffering that utter lack of anti-aliasing/sub-pixel rendering?!

That's matter of taste. I HATE font antialiasing - it nearly makes me feel nauseous, so I prefer fonts to be crisp.

Quote:

Originally Posted by Proud (Post 4441286)
if you remove the end hints, you brain surely has far more permutations to search/match.

Not exactly. I use "camelCase", so in addition to end hints, capital letters signal beginning of a new word. (CapitalLettersSignalBeginningOfANewWord). Certain letters "stick out"(f,p,h,l,y,q,i) or form recognizeable character combinations combinations that are easy to pinpoint.

Quote:

Originally Posted by Proud (Post 4441286)
Perhaps a bad example:
togetherthereherheretheirtogather
togetherthereherheretheirtogather

IMO, even in this example, monospaced font is harder to read. In proprtional-font example "th" and "h" provide a visual cues that allows you to quickly break down this mess into words. Those cues are much harder to notice with fixed-width font which turns everything into letter soup, plus entire word is longer, so I see less letters per block of pixels.

Quote:

Originally Posted by Proud (Post 4441286)
I have written some C++,

I'm not sure that I should discuss usage of proportional fonts in C++ with you. C++ is NOT java, C#, PHP, or JS.

Quote:

Originally Posted by Proud (Post 4441286)
Would proportional fonts really interfere with e.g. 4space tabs aligning things? Because that does sound 'game-breaking' for programming.
I seemed to have missed you clarifying in post 17 that it would not, unless I'm mistaken.

Not sure if I understand you. With proportional font it is recommended to use IDE/editor that supports "elastic tabs". "Elastic tab" means that instead of inserting 4 spaces, tab character moves "cursor" to a next tabstop ("column"). Each tabstop is located at fixed interval from the left side of text field (roughly at 4 spaces, 8 spaces, 12 spaces from the left etc). In case of proportional fonts, you'll never use more than one space, but you'll use a lot of tabs when you need to align things. You can work without elastic tabs, but you won't be able to align text/tables as with MTK358's example.

Quote:

Originally Posted by Proud (Post 4441286)
Block selection/edit mode is beast when you need it.

I needed block selection (rectangular selection) 2 or 3 times in my entire life, and in all those cases problem wasn't related to programming. Not sure what kind of C++ program would need block selection. "Search/replace within selection" using regular expressions should always work better than that. Block selection is useful only for grids. Program text is not a 2D grid, it is a list of lines of variable length.

Tinkster 08-12-2011 07:02 PM

I voted CLI (vim, w/ syntax highlighting, code-completion suggestions,
in-line help support and all that goodness).

konsolebox 08-12-2011 07:38 PM

@Proud: You mean other software that's based from Scintilla? I haven't known any good alternative to Notepad++ so far. At least it should be able to provide syntax highlighting and is able to use themes. For other features I think at least it includes a vertical bar, wrapping/unwrapping with custom columns, trimming of trailing spaces, imaginary markers (the mirrored P-like thing) and searching and replacing with regular expressions. The search mechanism of Notepad++ is also very useful i.e. find/replace all in all opened files/current document/directory. Not mentioning EOL conversions and switching of encoding formats like ANSI, UTF*, and other character sets like Shift-JIS ;)

I also thought about possibility of having Notepad++ directly built in Linux if Scintilla was portable but I've thought about the many features of it and its dependent implementation with DOS paths instead of UNIX paths. There are also plugins in it that's very usable to me in which I doubt is usable in Linux (AFAIK they could be DLLs only) e.g. Light Explorer (finds it better than the newer Notepad++ Explorer) which could only traverse DOS paths.

When Notepad++ was starting to get popular with Linux-Windows users, I also thought about trying to port the application to Linux sometime but I haven't had the chance, time or motivation. I also thought that someone will really make a port of it (esp. the developer) out of many requests but no one did.

MTK358 08-12-2011 07:50 PM

Quote:

Originally Posted by konsolebox (Post 4441343)
At least it should be able to provide syntax highlighting and is able to use themes. For other features I think at least it includes a vertical bar, wrapping/unwrapping with custom columns, trimming of trailing spaces, imaginary markers (the mirrored P-like thing) and searching and replacing with regular expressions. The search mechanism of Notepad++ is also very useful i.e. find/replace all in all opened files/current document/directory. Not mentioning EOL conversions and switching of encoding formats like ANSI, UTF*, and other character sets like Shift-JIS ;)

Except for "vertical bar" and "imaginary markers" (since I have no idea what they mean), Vim can do all that as far as I know.

MrCode 08-12-2011 07:58 PM

Quote:

Originally Posted by konsolebox
imaginary markers (the mirrored P-like thing)

The pilcrow sign (¶)?

konsolebox 08-12-2011 08:05 PM

1 Attachment(s)
@MTK358: yeah it sure does :) vertical bar is just a blue/cyan imaginary line on the right side of the document that marks the end of the custom number of columns. I always use 72 for that. For the imaginary markers I mean these (see attached file)

@MrCode yes that one lol :D


All times are GMT -5. The time now is 02:25 PM.