March 06, 2015
On Fri, Mar 06, 2015 at 19:55:10 +0000, Russel Winder via Digitalmars-d-announce wrote:
> On Fri, 2015-03-06 at 09:54 -0500, Ben Boeckel via Digitalmars-d-announce wrote:
> > -int foo(int bar) {
> > -	return bar;
> > -}
> > 
> >     versus (assuming 8 space indents):
> > 
> > -int foo(int bar) {
> > -        return bar;
> > -}
> 
> Is your point that in this case they have rendered identically?

Well it is now more apparent with more quoting. It now appears that the first block is using 3-space indents while the bottom looks just fine even with the quote markers.

> >   - I have yet to see an editor properly do tab-for-indent with proper
> >     space-for-alignment without manual management:
> > 
> > 	int my_long_function_name(int bar,
> > 	                          int baz)
> > ^__tab_^^_______spaces___________^
> 
> But, for me anyway, the fundamental flaw here is the idea of alignment. Find a style that eliminates all this alignment malarkey.

Well, when that means you're going to have absurdly long lines to deal with in anything other than your definition "real" editors (and I've never seen one which fits your definition).

> I really dislike the Go obsession with block style alignment of declarations.

I won't say I'm a fan of it indiscriminently, but if it's that or 200+-character lines, I'll chop argument lists up a bit to fit something more reasonable.

> The core problem here is teletype, monospace font thinking. Using a proper proportional font for you code and you rapidly lose the need for all this alignment stuff.
> 
> <Real point but expressed as a bit of a troll, mostly to expose that this is likely a bikeshed issue.>

And I find that monospace fonts tend to make it much easier to tell the difference between 'l', '1', and 'I'. Not so important in English, but it can be all the difference in code.

> In a real editor there is no hard line break, no need for this form of indentation. Should a line be too long for the rendering area either viewport or syntax directed soft line wrap are used. Having overflow is mixing content with rendering.

You're making assumptions about the features of your users' editors. These features are not trivial to implement and this basically requires things like pygments and other tools used to render code to the web with all kinds of logic to handle dynamic viewports of the shown code. IMO, it is even worse than putting #vim:, #kate:, or emacs formatting directives in your code since it is implicit.

Personally, I use Vim because it works similarly for all uses. I don't know what I'd do if I had to work with a different editor for each language I work with.

--Ben
March 07, 2015
On 3/6/2015 2:31 AM, Russel Winder via Digitalmars-d-announce wrote:
> Remember a tab is not a number of spaces, it is semantic markup.

All I can say is good luck with that. ASCII is not a markup language, and trying to reinvent it as one is doomed to failure.

I can also say from experience that removing tabs from Phobos source has removed a lot of irritation with messed up code rendering and wasted effort arguing about it. We're not going back :-)
March 07, 2015
On 3/6/2015 1:54 AM, Brian Schott wrote:
> On Friday, 6 March 2015 at 09:39:13 UTC, Walter Bright wrote:
>> True, but on the other hand, a D lexer and parser are pretty simple.
>
> Did you mean "simple compared to C++"?

It's simple in both absolute terms and relative to C++ terms. It's not as simple as Java's.


> I remember having to report/fix a LOT of
> bugs in the language specification and explore the DMD front end source code to
> get to where I am now.

True, but there have been very few bugs in the lexer/parser itself. My laziness in being pedantically correct in writing the specification is an orthogonal issue.

March 07, 2015
On 3/6/2015 2:47 AM, Stefan Koch wrote:
> I'd like to hear your definition of simple.

It's easy to understand, and one could write one from scratch over a weekend.

I haven't done any statistics, but I'd bet that that parse.c & lexer.c are among the most stable parts of dmd judging by change history.
March 07, 2015
On 3/6/2015 1:48 AM, Brian Schott wrote:
> The serious answer is that there's a lot of special casing that I'm still trying
> to figure out.

Ah. I had thought that maybe there was an obvious algorithm I didn't think of!
March 07, 2015
On 3/6/2015 11:55 AM, Russel Winder via Digitalmars-d-announce wrote:
> The core problem here is teletype, monospace font thinking. Using a
> proper proportional font for you code and you rapidly lose the need for
> all this alignment stuff.
>
> <Real point but expressed as a bit of a troll, mostly to expose that
> this is likely a bikeshed issue.>

Unlike english prose, code follows patterns. With a monospace font, one can line up those patterns which makes for easier visual checking for errors.

March 07, 2015
On Fri, 2015-03-06 at 18:31 -0800, Walter Bright via
Digitalmars-d-announce wrote:
[…]
> 
> Unlike english prose, code follows patterns. With a monospace font, one can line up those patterns which makes for easier visual checking for errors.

That works for you fine, but it doesn't work for me. I find monospace fonts and alignment of code gets in the way of reading and comprehending code.

The difficulty here is turning a personal preference into a social orthodoxy.

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


March 07, 2015
On Fri, 2015-03-06 at 18:21 -0800, Walter Bright via Digitalmars-d-announce wrote:
> On 3/6/2015 2:31 AM, Russel Winder via Digitalmars-d-announce wrote:
> > Remember a tab is not a number of spaces, it is semantic markup.
> 
> All I can say is good luck with that. ASCII is not a markup language, and trying to reinvent it as one is doomed to failure.

I try to use Unicode (UTF-8 encoded) languages, restricting to ASCII is
very 1970s.

The use of tab as the indent character is far from failing. Many C++ projects are returning to it, Go enforces it if you let it, many Python projects are starting to use it in spite of PEP-8. OK so Go enforced format does alignment as well on the assumption of monospace font. I dislike that so just carry on with proportional fonts.

ASCII per se is not a markup language, and it retains all the quirks of teletypes, but that should not stop progress. Unicode replacing ASCII is one step forward. Rethinking old established rules is always worthwhile: just because a thing has always been done some way does not make it the right way, nor should it hinder change.
> 
> I can also say from experience that removing tabs from Phobos source has removed a lot of irritation with messed up code rendering and wasted effort arguing about it. We're not going back :-)

And I am not going to work on Phobos for exactly the same reasons. My loss, not yours.

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


March 07, 2015
On Fri, 2015-03-06 at 15:22 -0500, Ben Boeckel via
Digitalmars-d-announce wrote:
[…]
> 
> Well it is now more apparent with more quoting. It now appears that the first block is using 3-space indents while the bottom looks just fine even with the quote markers.

But there is no semantic difference in the code and it is all being replaced anyway. I think the fact that a codebase should have a formatter run over any change before being committed, to enforce the rules of the codebase, will get round the issue anyway. Pythons pep-8, gofmt, dfmt,… the use of such a tool, enforcing the standard of the codebase is a good thing.

[…]
> Well, when that means you're going to have absurdly long lines to deal with in anything other than your definition "real" editors (and I've never seen one which fits your definition).

Such editors were being researched and created in the 1980s but computers were a bit too slow for the necessary infrastructure and, more importantly, a vocal section of the development community screamed, these things are wasteful of resources, and we must have ASCII encoded files as the storage of our code. This attitude has, in my view, been the biggest stumbling block to progress in software development for the last 30 years.

Now with suitably fast processors and graphics, we are seeing all the technology of the 1980s reentering the arena, but instead of doing it right, IDEs are having to spend huge resources continually reconstructing AST data from the flat file input. Some of them do it better than others, but if only it had been accepted that AST is the correct unit of editing in the 1980s we would be a lot further forward today.

> > I really dislike the Go obsession with block style alignment of declarations.
> 
> I won't say I'm a fan of it indiscriminently, but if it's that or 200+-character lines, I'll chop argument lists up a bit to fit something more reasonable.

There is more than one way of chopping things up, and even aligning them. Stepping away from monospace fonts, and the obsession with 2D rendering of 1D data, gives a different view on chopping up which ends up no better, but no worse.

[…]
> 
> And I find that monospace fonts tend to make it much easier to tell the difference between 'l', '1', and 'I'. Not so important in English, but it can be all the difference in code.

Important point. Fonts are context dependent. A font for easy reading of plain English novels, may not be appropriate for other uses exactly because the different uses and contexts of the characters mean the glyphs must have different relationships. But this is a font design thing and monospace versus proportional is not the major determinant.

> > In a real editor there is no hard line break, no need for this form of indentation. Should a line be too long for the rendering area either viewport or syntax directed soft line wrap are used. Having overflow is mixing content with rendering.
> 
> You're making assumptions about the features of your users' editors. These features are not trivial to implement and this basically requires things like pygments and other tools used to render code to the web with all kinds of logic to handle dynamic viewports of the shown code. IMO, it is even worse than putting #vim:, #kate:, or emacs formatting directives in your code since it is implicit.
> 
> Personally, I use Vim because it works similarly for all uses. I don't know what I'd do if I had to work with a different editor for each language I work with.

I do not disagree. The problem is that Emacs, VIM, IntelliJ IDEA, Eclipse, Netbeans, are editors based fundamentally on a 1970s view of editing and resources and the world has changed. Fortunately, I am hearing that some of the ideas of the SOE and AST editors of the 1980s are being re-raised, now with the resources to deal with it. Should this go forward, I can see VIM dying, Emacs dying or being rewritten, and IntelliJ IDEA, Eclipse, Netbeans, etc. losing at least half their code or more. The IDEs with all their "refactoring support" are almost reproducing what comes for free with SOE and AST focused editors.

As actors, dataflow, CSP were rejected by programmers in the 1970s and 1980s because they had processes and threads and really enjoyed shared-memory multi-threaded programming (*), SOE and AST based editors of the 1980s are effectively being recreated by the IDEs of the 2010s. They are hamstrung by the continued obsession with the text file as the primary unit of editing. As soon as they and programmer users get over this, the sooner we can get on with better UX for development. (**)


(*) OK so operating system developers are allowed to do this stuff because they have to, but applications people should not be doing any such thing.

(**) And yes the very foundation of version control will have to change
as well.
-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


March 07, 2015
On 3/6/2015 10:43 PM, Russel Winder via Digitalmars-d-announce wrote:
> The difficulty here is turning a personal preference into a social
> orthodoxy.

A consistent style is necessary for Phobos. For your own projects, D doesn't dictate any particular style.