May 10, 2013
On Thursday, May 09, 2013 17:32:18 Nick Sabalausky wrote:
> On Thu, 09 May 2013 10:26:46 -0400
> 
> Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
> > On 5/9/13 10:26 AM, Andrei Alexandrescu wrote:
> > > With all this focus on technicalities, we forgot to discuss the gist of it: what did you guys think of the talk?
> > 
> > That should better go in the digitalmars.D group though...
> 
> Very good talk! And good production quality, too. This would be a great thing to point people towards to introduce them to D.

Indeed.

> And Walter does a good job on stage. *Never* comes across as pretentious, or cocky or full-of-...various things...like *cough*a certain former Apple leader*cough* always did.

Walter may be very stubborn and opinionated, but he definitely isn't pretentious.

- Jonathan M Davis
May 10, 2013
On 5/10/2013 4:09 AM, deadalnix wrote:
> One of them is the plane metaphor. I now know that Walter is a big fan of plane
> (and he knows quite a lot about that !) but the problem is that the point is
> very subjective (the plane want to fly).

It's not that subjective. An airplane that "wants to fly" is well known among airplane designers and pilots. All you have to do is point it down the runway and open the throttle. It will take off and fly straight and level without any hands on the controls. An airplane can also endure grevious damage, and still fly.

A helicopter, on the other hand, wants to crash. It requires constant active efforts to keep it in the air, and if much of anything goes wrong, it will crash and kill you.

Have you ever driven a high performance car that "wants to go"? I have. The car clearly isn't happy being driven slowly and gently. It's only happy when your right foot is mashed all the way down :-)
May 10, 2013
On 5/10/13, H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:
> One tiny nitpick, though. In the example about sorting lines in a file, there was a syntax error in the code (missing '.' and the end of the first/second line).

Walter already used these slides for a previous talk where the missing dot was mentioned during the talk. He probably just forgot to update the pdf. :)

Actually that previous talk was a little bit more descriptive in what the code does (and people kept asking questions too). I'm not sure exactly what talk it was, maybe it was on nwcpp..
May 10, 2013
> In any case, I totally agree that if a language *needs* an IDE in order to cope with the amount of required boilerplate, then something is clearly very, very wrong at a fundamental level.

May be this is true for expert or professional programmers. But for people like me who only use D occasionally an IDE is a must.

IDE mainly helps me in reducing the amount of things I need to memorize or remember like API, building tool names, command syntaxes, etc. This is very important as my main profession is not programming.

I think lack of IDEs will prevent many beginners from trying out a new language. Especially after getting spoiled with IDEs like netbeans, visual studio etc.

Currently using DIDE, not perfect but better than nothing. VisualD seems to have good reviews but I cannot install it as it requires admin privileges.

All the above will still be true even for a "perfect" programming language.
May 10, 2013
"deadalnix" <deadalnix@gmail.com> wrote in message news:mtmtakrebylsdehnrgvx@forum.dlang.org...
>
> First good talk. Some tweaking can be done to make it better.
>
> One of them is the plane metaphor. I now know that Walter is a big fan of plane (and he knows quite a lot about that !) but the problem is that the point is very subjective (the plane want to fly).
>
> I'm sure the plane idea can be kept, but must be presented in a more factual/less subjective manner.
>

Forget planes, this code quite obviously wants to fly! http://www.ioccc.org/1998/banks.c


May 10, 2013
On Fri, 10 May 2013 21:55:57 +0200
"sk" <abcdefg@gmail.com> wrote:

> > In any case, I totally agree that if a language *needs* an IDE in order to cope with the amount of required boilerplate, then something is clearly very, very wrong at a fundamental level.
> 
> May be this is true for expert or professional programmers. But for people like me who only use D occasionally an IDE is a must.
> 
> IDE mainly helps me in reducing the amount of things I need to memorize or remember like API, building tool names, command syntaxes, etc. This is very important as my main profession is not programming.
> 
> I think lack of IDEs will prevent many beginners from trying out a new language. Especially after getting spoiled with IDEs like netbeans, visual studio etc.
> 
> Currently using DIDE, not perfect but better than nothing. VisualD seems to have good reviews but I cannot install it as it requires admin privileges.
> 
> All the above will still be true even for a "perfect" programming language.

While that's all true, none of it really contradicts what was said. Ie, that "The IDE can auto-generate boilerplate" is a very poor excuse for a language to lack ways of minimizing the need for boilerplate in the first place.

May 10, 2013
Ah, makes sense, sorry for the misunderstanding.
May 10, 2013
On Fri, May 10, 2013 at 09:55:57PM +0200, sk wrote:
> >In any case, I totally agree that if a language *needs* an IDE in order to cope with the amount of required boilerplate, then something is clearly very, very wrong at a fundamental level.
> 
> May be this is true for expert or professional programmers. But for people like me who only use D occasionally an IDE is a must.

My point was that while an IDE is helpful (e.g. for people who aren't professional programmers, just want to get the job done, etc.), a language should not *depend* on an IDE to insert boilerplate. I concede that IDEs are helpful and needed for newbies and non-professional programmers, but the *language* itself should be usable without one. Requiring one because otherwise the amount of required boilerplate would be unmanagable, is a symptom that there is something wrong with the language's design.


[...]
> I think lack of IDEs will prevent many beginners from trying out a new language. Especially after getting spoiled with IDEs like netbeans, visual studio etc.
[...]

Agreed. But my point was that the language shouldn't *depend* on an IDE in order to be usable. If a language requires an IDE because you need to insert 100 lines of boilerplate in every program you write, then one has to wonder, why not make those 100 lines *implicit*? They are not conveying anything useful about the program, because they will be identical (or mostly identical) every single time. The fact that the language did *not* make it implicit then begs the question of what went wrong in its design that you have to repeatedly specify what should already be obvious to the language/compiler.

As they say in information theory: it is the stuff that stands out, that is different from the rest, that carries the most information. The stuff that's pretty much repeated every single time conveys very little information. This is why newspaper headings tend to leave out very common words like "the", "a", "is", etc., because these words take up space but convey little to no additional information -- you can drop them and still get the gist of what the headlines are saying.

A good programming language is one where the code says all the important things, and leaves out most of the unimportant or obvious things. It's just like Walter said in the talk: the file-reading function without scope guards was full of goto's and error-checking, stuff that pretty much is (or should be) done everywhere. It clutters the code and obscures the salient points. It's a headline with all the "the"'s, "a"'s, "is"'s. In contrast, the version with scope guards can be read sequentially -- all the peripheral if's and goto's are nicely abstracted away, leaving only the salient points of the code: allocate a buffer, read the data, return the data. A glance at the code immediately tells you its key points. No distracting sidelines of error-checking, goto's, labels, or any of that nonsense.

In contrast, consider a language like C. The *correct* way of writing C code is something like this:

	int myfunc(struct A *a, struct B *b, struct C *c) {
		/* Boilerplate: to avoid slip-ups with uninitialized
		 * pointers, must always set them to NULL. */
		void *buf = NULL;
		struct D *d = NULL;

		/* Boilerplate: check for NULL pointers */
		if (!a || !b || !c)
			/* Boilerplate: everybody and their neighbour's
			 * dog defines their own set of macros for
			 * return values; how do you remember which one
			 * goes with which function(s)? */
			return INVALID_ARGS_ERROR;

		buf = malloc(some_size);

		/* Boilerplate: must check NULL return from malloc,
		 * every single time. */
		if (!buf)
			return MEMORY_ERROR;

		/* Boilerplate: every function call must be wrapped in
		 * an if-goto, because the function may have returned an
		 * error. */
		if (anotherfunc(a, buf) != OK)
			goto ERROR;

		/* And yes, technically, you need to do this for things
		 * like printf too! Guess how many C coders do this?
		 * That's right, nobody does. It's wrong, and leads to
		 * hilarious problems when stdout isn't pointing to what
		 * the programmer thought it was. Or not-so-hilarious,
		 * if stdout was closed and a database handle was
		 * reopened and reused stdout's file descriptor
		 * number...
		 */
		if (printf("Hello, world!\n") != 0)
			goto ERROR;

		/* More boilerplate */
		if ((d = create_instance_of_d()) == NULL)
			goto ERROR;

		/* Now our boilerplate needs to use a different goto
		 * label, 'cos now we have to cleanup d, whereas we
		 * didn't need to before! Can you imagine the hilarity
		 * after 20 people change this code later on in the
		 * project's life, and one of them forgets the fact that
		 * after this point a different goto label is needed? */
		if (yetanotherfunc(b, d) != OK)
			goto ERROR2;

		if (yesmoreboilerplate(c, buf) != OK)
			goto ERROR2;

		/* Finally, success! */

		/* Um... not just yet, need more boilerplate: cleanup
		 * after ourselves */
		free(d);
		free(buf);

		/* Sigh... about time we got done */
		return OK;

		/* Caveat: the order of labels must be the *reverse* of
		 * the order they appear in the code, to ensure things
		 * are destroyed in the right order. Don't laugh -- I've
		 * seen "enterprise" code that gets this wrong. */
	ERROR2:
		/* Problem: by this point in the code, do you remember
		 * that d was supposed to be freed? */
		free(d);
	ERROR:
		/* Or buf? */
		free(buf);

		/* Problem: what if the caller forgets to check our
		 * return code? Or checks it against the wrong set of
		 * error macros? */
		return ERROR_CODE;

		/* Hope and pray the program won't crash when it gets
		 * back to the caller who forgets to check for error
		 * codes and just barges ahead blindly. */
	}

Note how much boilerplate is necessary to make the code work *correctly*. (Yes I know you can merge the error and non-error returns by checking for NULL in *buf and *d, thereby getting rid of the duplicated calls to free(), but that doesn't get rid of the problem, just dresses it differently.) The most obvious way to write this code leaks memory and doesn't handle errors.  In fact, the above code actually isn't good enough: printf sets errno, and to *really* get the code right, you should be checking and possibly propagating, the value of errno after the printf call fails.  Yes, more boilerplate. Lots more. Every single time you call a system function.

This is one of the things I can't stand about C. Seriously, C coders should use an IDE to get basic things like this right, even if most of them are too macho to admit it.

This is what I mean when the language is basically unusable without an IDE. Yes, IDEs can help adoption of a language, and I don't dispute that, but when code in that language cannot be written correctly without an IDE (or at least, not easily), then something is horribly, horribly wrong with that language.

(The D version of the above function, by contrast, is vastly more readable and maintainable on almost every count, and requires no IDE to get it right.)


T

-- 
"640K ought to be enough" -- Bill G., 1984. "The Internet is not a primary goal for PC usage" -- Bill G., 1995. "Linux has no impact on Microsoft's strategy" -- Bill G., 1999.
May 10, 2013
On 5/10/2013 2:31 PM, H. S. Teoh wrote:
> Note how much boilerplate is necessary to make the code work
> *correctly*.

It's worse than that. Experience shows that this rat's nest style of code often is incorrect because it is both complex and never tested. While D doesn't make it more testable, at least it makes it simple, and hence more likely to be correct.
May 10, 2013
On Friday, May 10, 2013 14:31:00 H. S. Teoh wrote:
> As they say in information theory: it is the stuff that stands out, that is different from the rest, that carries the most information. The stuff that's pretty much repeated every single time conveys very little information.

This is an excellent way of looking at language design (and program design for that matter).

- Jonathan M Davis