June 04, 2010
On 6/4/10, Lutger <lutger.blijdestijn@gmail.com> wrote:
> I would be interested in contract programming.

When I write my thing up, I'll have something to say about contracts too. My HTML DOM code (on which I own the copyright! -- http://arsdnet.net/dcode/dom.d ) was originally written as just a list of functions, like I've done for a long time.

But, then, a null pointer got into tree somehow, and it annoyed the hell out of me. To help track it down, I added the class invariant and piles of in/out contracts. There's almost more assert lines than actual code! Take a look at this function:

	Element appendChild(Element e)
		in {
			assert(e !is null);
			assert(e.parentNode is null);
			assert(!selfClosed);
		}
		out (ret) {
			assert(e.parentNode is this);
			assert(e is ret);
		}
	body {
		e.parentNode = this;
		children ~= e;
		return e;
	}

Lots of those are pretty obvious, and it is a trivial function, so it isn't hard to eyeball it, but putting this stuff in those contracts make it explicit as to what is expected: it takes ownership a node without a parent and returns it.

But now, if I edit this function, or subclass it and screw something up, it is caught very quickly, and right on location. This experience has made me understand the people asking for non-null types, but it has more benefit aside from that too.

For example, yesterday, I wrote this:

auto e = document.createElement("div");
auto list = document.createElement("ul");
// snip

e.appendChild(e); // BUG, should be appending the list


The compiler didn't catch this one, and I wrote this long after forgetting about the dom implementation code. But the in contract caught this as soon as I ran it.

There's a few little things that could be improved here, but it is still very nice to know stuff gets caught sooner rather than later (and I'd love if it the compiler could catch some of those asserts at compile time if it can prove it! I'm thinking that perhaps some extensions to value range propagation could to the trick.)
June 04, 2010
superdan Wrote:

> == Quote from retard (re@tard.com.invalid)'s article
> > Thu, 03 Jun 2010 16:58:03 -0700, Walter Bright wrote:
> > > D is an extremely powerful language, but when I read complaints and sighs about other languages, few seem to know that these problems are solved with D. Essentially, we have a marketing problem.
> > >
> > > One great way to address it is by writing articles about various aspects of D and how they solve problems, like http://www.reddit.com/r/programming/comments/cb14j/
> > compiletime_function_execution_in_d/
> > >   which was well received on reddit.
> > >
> > > Anyone have good ideas on topics for D articles? And anyone want to stand up and write an article?
> > >
> > > They don't have to be comprehensive articles (though of course those are better), even blog entries will do.
> > Well, I for one, like to know when the D2 will be officially published. I
> > thought there was a bugfix week and the TDPL was written because D2 is
> > almost ready and there was supposed to be a big kaboom.
> > The version number is already at 2.046 but there are maybe 100 bugs
> > waiting in the bugzilla with patches and the compiler & spec are
> > seriously broken. When will it be usable? What will be the version number
> > of the first usable D2 dmd? There was a "huge" D1 release party, but I'm
> > not sure when it's a good time to move to D2. It's not enough that the
> > examples from the book work, D needs to be ready for commercial quality
> > applications. What's the library status? Where are the official
> > milestones? Future plans? What's happening here?
> 
> http://www.youtube.com/watch?v=8r1CZTLk-Gk
> 
> thanx fer yer self entitlement asshole.

yup. too many people take D for granted and only bitch about things it lacks and never see lot of great features it already has. it is usable and it is fucking better than c and c++!
June 04, 2010
Adam Ruppe:
> (and I'd love if it the compiler could catch some of those asserts at compile time if it can prove it! I'm thinking that perhaps some extensions to value range propagation could to the trick.)

There's lot of space for improvements here. But those inferences take time, while the compiler must be fast enough. To solve this it can be useful a progressive compilation (partial compilation while you type the code, as some IDEs do).

Bye,
bearophile
June 04, 2010
Walter Bright wrote:
> D is an extremely powerful language, but when I read complaints and sighs about other languages, few seem to know that these problems are solved with D. Essentially, we have a marketing problem.
> 
> One great way to address it is by writing articles about various aspects of D and how they solve problems, like http://www.reddit.com/r/programming/comments/cb14j/compiletime_function_execution_in_d/  which was well received on reddit.
> 
> Anyone have good ideas on topics for D articles? And anyone want to stand up and write an article?
> 
> They don't have to be comprehensive articles (though of course those are better), even blog entries will do.

Great idea .. an article in Linux Journal about how D is the ideal language for producing shared object (.so) libraries on *nix would be a cool topic to assist the marketing effort.

June 04, 2010
On 6/4/10, bearophile <bearophileHUGS@lycos.com> wrote:
> There's lot of space for improvements here.

Aye, though let's not forget that what D has is already quite nice!
June 04, 2010
On Sat, 05 Jun 2010 02:24:40 +0930, Justin Johansson wrote:

> Walter Bright wrote:
>> D is an extremely powerful language, but when I read complaints and sighs about other languages, few seem to know that these problems are solved with D. Essentially, we have a marketing problem.
>> 
>> One great way to address it is by writing articles about various aspects of D and how they solve problems, like http://www.reddit.com/r/programming/comments/cb14j/
compiletime_function_execution_in_d/
>>  which was well received on reddit.
>> 
>> Anyone have good ideas on topics for D articles? And anyone want to stand up and write an article?
>> 
>> They don't have to be comprehensive articles (though of course those are better), even blog entries will do.
> 
> Great idea .. an article in Linux Journal about how D is the ideal language for producing shared object (.so) libraries on *nix would be a cool topic to assist the marketing effort.

+1, that is a killer feature.

Wishing for the day when I can build x86-64 shared libs with DMD2...

Graham
June 05, 2010
how to generate a header file in the source files dir? when i wan't get a
big project like dwtx headers, i like push all source file to dmd and generate
header file, but there is a lot source file have same name, and i only get
one header file in dmd run dir or Hd dir。
This is very inconvenient for such a large projects,  Is there any way to
avoid this problem?

2010/6/4 Walter Bright <newshound1@digitalmars.com>

> D is an extremely powerful language, but when I read complaints and sighs about other languages, few seem to know that these problems are solved with D. Essentially, we have a marketing problem.
>
> One great way to address it is by writing articles about various aspects of
> D and how they solve problems, like
> http://www.reddit.com/r/programming/comments/cb14j/compiletime_function_execution_in_d/ which was well received on reddit.
>
> Anyone have good ideas on topics for D articles? And anyone want to stand up and write an article?
>
> They don't have to be comprehensive articles (though of course those are better), even blog entries will do.
>


June 05, 2010
On 06/03/2010 07:58 PM, Walter Bright wrote:
> D is an extremely powerful language, but when I read complaints and
> sighs about other languages, few seem to know that these problems are
> solved with D. Essentially, we have a marketing problem.
>
> One great way to address it is by writing articles about various aspects
> of D and how they solve problems, like
> http://www.reddit.com/r/programming/comments/cb14j/compiletime_function_execution_in_d/
> which was well received on reddit.
>
> Anyone have good ideas on topics for D articles? And anyone want to
> stand up and write an article?
>
> They don't have to be comprehensive articles (though of course those are
> better), even blog entries will do.

One thing that I think will really make people really notice D is std.concurrency.  If it makes concurrency as easy as that in Erlang, that will be a huge win and definitely make it stand out vs. many other languages.

Here are some other thoughts:

- Compare D to scripting languages like Perl and Python to show how you can do similar things.  I suggest this because to me, it seems like D compares very nicely to Perl 5 in terms of getting things done.  Also, if you show that the code is about as easy to write, fast to compile, and can do the job in less time, win!

- Re-write some basic Unix utilities in D and compare the code.  grep would probably be a good one to start with since it can leverage D's built in regular expressions.

- Show how much better D is at handling errors/exceptions with some real-world examples.  A big win would be to show that D can resist some common attacks, such as buffer overflows.  That would be interesting to people who have to write secure network applications.

Casey
June 05, 2010
Hello Walter,

> Walter Bright wrote:
> 
>> I agree with Andrei - write the article!
>> 
> The most popular blog entry I wrote for DDJ, was the one on converting
> assembler code to C, based on my ongoing trenchwork actually doing it
> with optlink. 

BTW: how does that go?

-- 
... <IXOYE><



June 05, 2010
On 6/4/2010 11:13 AM, Adam Ruppe wrote:
> On 6/4/10, Eric Poggel<dnewsgroup@yage3d.net>  wrote:
>> I prefer D to PHP, but writing a web app in D would take me much longer
>> due to the lack of web-oriented libraries.
>
> What kind of stuff would you need? I admit I did spend several
> weekends doing prep work on libraries before proposing it to the
> client - had to write mysql, cgi, http get and post, my xml code, and
> some helper functions to extend std.json before I was confident enough
> in having the libraries to propose it, but now I have that, and can
> share if it sounds useful.
>
> The only place where library lacking has hit me so far is interfacing
> with Facebook. For that part of the app, I still use PHP. I'd like to
> port it eventually, implementing oauth and such in a nice, generic
> way, but I haven't gotten around to it yet... still, the vast majority
> of what I need I can do now in plain D.

It would be nice to have a web library for D, but my web development has been almost exclusively for shared hosting environments.  Also, most web developers know PHP while zero know D.  Clients would see that as lock-in.