www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Marketing of D - article topic ideas?

reply Walter Bright <newshound1 digitalmars.com> writes:
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_func
ion_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.
Jun 03 2010
next sibling parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 04/06/10 00:58, 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.

Given some ideas I'm happy to write an article or two. I guess the best thing to write articles on are the problems D solves which other languages have, or how D makes something easier to do - we'd need to pick out some specific areas though. Robert
Jun 03 2010
next sibling parent Brad Roberts <braddr puremagic.com> writes:
On 6/3/2010 5:15 PM, Robert Clipsham wrote:
 On 04/06/10 00:58, 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.

Given some ideas I'm happy to write an article or two. I guess the best thing to write articles on are the problems D solves which other languages have, or how D makes something easier to do - we'd need to pick out some specific areas though. Robert

Rewording that a little: How D solved a problem particularly well for you. Demonstrations are FAR more effective than statements. Also, not responding to you but rather the general topic, getting the word out in other venues would help too. There's been many posts that hit reddit. That venue isn't bad, but also has already built up a set of automatic detractors. Later, Brad
Jun 03 2010
prev sibling next sibling parent reply Lutger <lutger.blijdestijn gmail.com> writes:
Robert Clipsham wrote:

 On 04/06/10 00:58, 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.

Given some ideas I'm happy to write an article or two. I guess the best thing to write articles on are the problems D solves which other languages have, or how D makes something easier to do - we'd need to pick out some specific areas though. Robert

I would be interested in contract programming. Taking a small example app and illustrating how to add pre- and postconditions, invariants, contract inheritance and perhaps notrow and pure. Or start with the contracts as advocated by the Eiffel method. Perhaps do the same with .NET 4.0 contracts and compare the results.
Jun 04 2010
parent bearophile <bearophileHUGS lycos.com> writes:
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
Jun 04 2010
prev sibling next sibling parent Adam Ruppe <destructionator gmail.com> writes:
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.)
Jun 04 2010
prev sibling parent Adam Ruppe <destructionator gmail.com> writes:
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!
Jun 04 2010
prev sibling next sibling parent reply retard <re tard.com.invalid> writes:
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/

   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?
Jun 03 2010
parent reply superdan <super dan.org> writes:
== 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/

   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.

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.
Jun 03 2010
parent Bane <branimir.milosavljevic gmail.com> writes:
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/

   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.

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++!
Jun 04 2010
prev sibling next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Walter Bright:
 Anyone have good ideas on topics for D articles?

Here are 7 possible articles: 1) We can write some cool larghish library/program and then show the results of the program, something like a small 2D or 3D game, a numerical plotting lib, etc. Graphics is very good because it catches the eye even if it's something simple. For example I'd like to translate a small CPS (Constraint Problem Solver) like this into a single D2 module: http://labix.org/python-constraint Once written such module can be the basis for a "cool" article about one D2 usage (and then I can use the CPS module in various ways). I have other ideas for useful/nice single modules for D2, there are plenty of ideas to copy from in repositories of modules/programs written in Python, Perl, Ruby, Clojure, etc. 2) Another possibility is to appeal to the C++ crowd, for example translating this C++ to D2: http://accu.org/index.php/journals/1422 A literal translation of the C++ code of this article to D2 is possible, but at the end of the D2 article it can show that there is a better solution in D2, like using variable-argument templated structs to implement n-way trees of types, as I have discussed a bit with Downs (keeping in mind that C++0x too has variable-argument templates. If you want to compare D2 with C++ to show D2 then you *must* use C++0x otherwise people will say you are cheating). 3) This is another awesome small C++ program that must be translated to D2 (but I am not certain this is the most updated version of this program), it's just a single C++ file about 24 KB of code and heavely templated, and in my opinion no other language beside C++ and D (and maybe Lisp) can be used to write a program so fast and so short to solve this: http://www.codeguru.com/cpp/misc/samples/games/article.php/c13607/ It's textual and console-based code, so almost no libs are required. Once translated, this can be the basis for a good article that explains the D2 code, templates, etc. 4) Another quite interesting article can show how to implement Expression templates in D2, like the ones used in Blitz++ and successive libs: http://en.wikipedia.org/wiki/Expression_templates (If this article uncovers problems in D2 language then it's better to find them now than later :-) ). 5) You have noticed that I write a lot in this newsgroup. My recent "Huffman coding comparison" post can be seen as an article that shows D2 and Phobos2 because the D2 code I've shown there is nice looking. 6) You can find C++0x variadic templates articles that can be translated to D2: http://www.jot.fm/issues/issue_2008_02/article2/ http://mlangc.wordpress.com/2010/04/18/using-c0x-variadic-templates-to-pretty-print-types/ 7) This is one of the changes in G++ 4.5: http://gcc.gnu.org/gcc-4.5/changes.html
Compilation time for code that uses templates should now scale linearly with
the number of instantiations rather than quadratically, as template
instantiations are now looked up using hash tables.<

http://cpptruths.blogspot.com/2010/03/faster-meta-programs-using-gcc-45-and.html Bye, bearophile
Jun 03 2010
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/03/2010 08:34 PM, Adam Ruppe wrote:
 I recently rewrote a huge PHP application in D2. It isn't a completely
 fair comparison, since the PHP was written by, well to be polite, PHP
 "programmers", but the results were pretty astounding.

 90% reduction in lines of code [!], 200% improvement in speed under
 heavy load (only 50% improvement under light load, still good, but not
 as good), and the code is actually maintainable! Also, the original
 took about a year for the first team to write. My D rewrite took 6
 weeks. Oh yeah, and the PHP is riddled with security holes. Not so
 much with the D.

 The best part about the speed is that it is just running as plain old
 CGI and my code does a lot of inefficient looping through XML. I could
 probably double the speed again by improving that.


 I might be able to write this into an article, but what I've done so
 far is just showed it off to other coders in some private messages on
 forums. A complication in publically showing it off is it is closed
 source though. The speed advantage isn't apparent until the code
 actually does something; PHP is much faster for hello world, but gets
 spanked when it comes to the actual work.

I think this is the best way to approach writing, and I strongly encourage you to just plow through whatever IP issues there are and go for it. (In my experience, nobody will come after you for writing an article that doesn't outright give the code away.) I'm repeating myself, but writing a good piece should at best start with a desire to share something you genuinely believe is interesting (as opposed to starting with a desire for developing an article and consequently looking for a topic idea). You seem to be right on the money. In related news... For what it's worth, I plan to write about memory-isolated containers (those that can use malloc/free for their allocation strategy without being unsafe). I believe there are a number of fine points to be made and that such containers solve an important class of problems. InformIT.com considers the idea interesting and commissioned me to write that article. I've also read again today this piece by Oleg Kiselyov: http://okmij.org/ftp/papers/LL3-collections-enumerators.txt Oleg is pretty awesome and makes great points, but I think also missed a few. The abstract is a bit difficult to get into (and I haven't understood his enumerator inversion trick without using continuations). I have a pretty good retort in my mind, but that would take quite a long time to write. Andrei
Jun 03 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Andrei Alexandrescu wrote:
 On 06/03/2010 08:34 PM, Adam Ruppe wrote:
 I recently rewrote a huge PHP application in D2. It isn't a completely
 fair comparison, since the PHP was written by, well to be polite, PHP
 "programmers", but the results were pretty astounding.

 90% reduction in lines of code [!], 200% improvement in speed under
 heavy load (only 50% improvement under light load, still good, but not
 as good), and the code is actually maintainable! Also, the original
 took about a year for the first team to write. My D rewrite took 6
 weeks. Oh yeah, and the PHP is riddled with security holes. Not so
 much with the D.

 The best part about the speed is that it is just running as plain old
 CGI and my code does a lot of inefficient looping through XML. I could
 probably double the speed again by improving that.


 I might be able to write this into an article, but what I've done so
 far is just showed it off to other coders in some private messages on
 forums. A complication in publically showing it off is it is closed
 source though. The speed advantage isn't apparent until the code
 actually does something; PHP is much faster for hello world, but gets
 spanked when it comes to the actual work.

I think this is the best way to approach writing, and I strongly encourage you to just plow through whatever IP issues there are and go for it. (In my experience, nobody will come after you for writing an article that doesn't outright give the code away.) I'm repeating myself, but writing a good piece should at best start with a desire to share something you genuinely believe is interesting (as opposed to starting with a desire for developing an article and consequently looking for a topic idea). You seem to be right on the money.

I agree with Andrei - write the article!
 In related news... For what it's worth, I plan to write about 
 memory-isolated containers (those that can use malloc/free for their 
 allocation strategy without being unsafe). I believe there are a number 
 of fine points to be made and that such containers solve an important 
 class of problems. InformIT.com considers the idea interesting and 
 commissioned me to write that article.

This is exactly what I'm talking about.
Jun 03 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
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. People like articles about real world meat & potatoes language work. So I think your PHP => D experience would make for most interesting reading.
Jun 03 2010
next sibling parent Lutger <lutger.blijdestijn gmail.com> writes:
Walter Bright wrote:

 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. People like articles about real world meat & potatoes language work. So I think your PHP => D experience would make for most interesting reading.

A post-mortem style article or blog is nice, reading about the whole experience of the development process is often interesting. I remember one such an article at gamedev.net about D which was highly appreciated, while normally gamedev.net has a very critical crowd. Showing off cool features generally only works on people already convinced or in the know, for critics it usually evokes a 'so what' response. More questions and answers on stackoverflow might help too. I will try to make more use of that myself.
Jun 04 2010
prev sibling parent reply BCS <none anon.com> writes:
Hello Walter,

 Walter Bright wrote:
 
 I agree with Andrei - write the article!
 

assembler code to C, based on my ongoing trenchwork actually doing it with optlink.

BTW: how does that go? -- ... <IXOYE><
Jun 04 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
BCS wrote:
 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?

veeeeeerrrrrreeeee sssssslllllllooooooollllllllyyyyyyy
Jun 04 2010
parent BCS <none anon.com> writes:
Hello Walter,

 BCS wrote:
 
 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.
 



if(progress > 0) Ok(); -- ... <IXOYE><
Jun 04 2010
prev sibling next sibling parent reply Eric Poggel <dnewsgroup yage3d.net> writes:
On 6/3/2010 9:34 PM, Adam Ruppe wrote:
 I recently rewrote a huge PHP application in D2. It isn't a completely
 fair comparison, since the PHP was written by, well to be polite, PHP
 "programmers", but the results were pretty astounding.

 90% reduction in lines of code [!], 200% improvement in speed under
 heavy load (only 50% improvement under light load, still good, but not
 as good), and the code is actually maintainable! Also, the original
 took about a year for the first team to write. My D rewrite took 6
 weeks. Oh yeah, and the PHP is riddled with security holes. Not so
 much with the D.

 The best part about the speed is that it is just running as plain old
 CGI and my code does a lot of inefficient looping through XML. I could
 probably double the speed again by improving that.


 I might be able to write this into an article, but what I've done so
 far is just showed it off to other coders in some private messages on
 forums. A complication in publically showing it off is it is closed
 source though. The speed advantage isn't apparent until the code
 actually does something; PHP is much faster for hello world, but gets
 spanked when it comes to the actual work.

I've spent years in both D and PHP, and most of my php code is a little shorter than what the equivalent would be in D, mostly due to an enormous standard library. Now D is much better designed and much faster, but most php programs are trash because the language attracts so many noobs. I've spent a lot of time rewriting PHP apps in PHP that ended up being 10% of the length of the original. 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. However, the speedup you got with D is a good angle to push.
Jun 04 2010
parent reply Eric Poggel <dnewsgroup yage3d.net> writes:
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.
Jun 04 2010
parent "Nick Sabalausky" <a a.a> writes:
"Eric Poggel" <dnewsgroup yage3d.net> wrote in message 
news:huck02$1rel$1 digitalmars.com...
 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.

A lot of clients I know wouldn't know the difference anyway, and thus wouldn't misinterpret it as lock-in. (Guess I've been lucky in that regard :) ) Although, if a client is really savvy (not that that's common), they'd know that 1. While PHP developers are abundant, *good* PHP developers are about as rare as any non-mainstream language and 2. When you know how to code in a language, transferring those skills to a similar language (for example, imperative-to-imperative) is fairly easy (That's a fact that, unfortunately, seems to be completely unknown by non-programmers, especially HR people...which is one of the reasons I consider HR people to be nothing but worthless morons that collect a paycheck without contributing anything worthwhile to society, and in fact, only serve to drag society down. It *should* be their job to know such things, but they don't, and those societal leeches get paid anyway...I even talked to one headhunter (they're like HR people but even worse) who was actually stupid enough to blurt out "I don't know anything about programming, but I can identify people who are good at it"...riiiight, like that's even conceivably possible outside her hometown of looneyville...but I'm veering waaay offtopic...). Regarding support for custom cgi on shared hosts: I looked into that recently on the shared hosts I typically deal with, and it turned out to be more widely supported than I thought. Maybe I've just been lucky on that too, but it could be you're underestimating the support for it like I was. Also, even if support for a language among shared hosts is small, the only way that's ever going to change is if a lot of developers want it. And the only way that's ever going to happen (these days) is if there's a good web library for the language. (Not that that'll guarantee success, but it would be a necessary step.)
Jun 04 2010
prev sibling next sibling parent Adam Ruppe <destructionator gmail.com> writes:
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.
Jun 04 2010
prev sibling next sibling parent reply retard <re tard.com.invalid> writes:
Thu, 03 Jun 2010 21:34:05 -0400, Adam Ruppe wrote:

 I recently rewrote a huge PHP application in D2. It isn't a completely
 fair comparison, since the PHP was written by, well to be polite, PHP
 "programmers", but the results were pretty astounding.
 
 90% reduction in lines of code [!], 200% improvement in speed under
 heavy load (only 50% improvement under light load, still good, but not
 as good), and the code is actually maintainable! Also, the original took
 about a year for the first team to write. My D rewrite took 6 weeks. Oh
 yeah, and the PHP is riddled with security holes. Not so much with the
 D.

News at eleven! A rewrite of a shitty old version is better than the original. Now this proves that especially D2 should be used for rewriting everything! How surprising.
Jun 05 2010
parent reply Jeff Nowakowski <jeff dilacero.org> writes:
On 06/05/2010 09:10 AM, Adam Ruppe wrote:
 The really interesting thing is how D on plain old CGI also performed
 better than fairly popular PHP applications as well, like phpBB3,
 WordPress and MediaWiki (determined by comparing individual pages that
 did basically the same thing. Not exactly though, so not a fully fair
 comparison)

Why is this interesting? D is a static, compiled, "system" language designed to be near the speed of C. PHP is a scripting language, similar to Perl, but built to make web coding easier. And I agree with "retard" that if you rewrite something crappy (or even not so crappy), the new version will be better than the original. If you want your article to be taken seriously, you'll have to show code written in idiomatic PHP that benefits from being written in idiomatic D.
Jun 05 2010
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 06/06/10 00:06, Adam Ruppe wrote:
 On 6/5/10, Jeff Nowakowski<jeff dilacero.org>  wrote:
 Why is this interesting? D is a static, compiled, "system" language
 designed to be near the speed of C. PHP is a scripting language, similar
 to Perl, but built to make web coding easier.

The reason I did the benchmarks was because I was talking to someone about it, and he said "yeah, php sucks, but isn't CGI really slow?" It isn't, not with D.

It isn't anyway, at least not with fastcgi - take mod_php vs php in fcgi, fcgi is far *far* faster.
 If you don't address request speed and scalability, nobody's going to
 listen to the other benefits. Opening with a statement like "200%
 faster" keeps their attention.

That is a huge speed improvement, always a good opening statement!
 The biggest benefit, however, isn't running speed, but instead code
 maintainability.

Being the only two languages I'd call myself fluent in, I'd definitely call D easier to maintain than PHP... I guess this is easily debatable though.
 If you
 want your article to be taken seriously, you'll have to show code
 written in idiomatic PHP that benefits from being written in idiomatic D.

That's the plan. I'm hoping to write this up next weekend.

Jun 05 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Robert Clipsham" <robert octarineparrot.com> wrote in message 
news:huembk$2660$1 digitalmars.com...
 Being the only two languages I'd call myself fluent in, I'd definitely 
 call D easier to maintain than PHP... I guess this is easily debatable 
 though.

Easily debatable? Not without an existing brain injury ;) I've used a lot of different languages. PHP's maintainability is one of the worst I've ever seen. The whole design of it *begs* for bugs. Hell, PHP is the only (*cough*) modern (*cough*) language I can think of where bugs can actually be introduced without any programmer involvement and without even touching a single line of code. The sysadmin just needs to change any one of certain PHP server settings (or move the code to another server that isn't configured exactly the same), and suddenly random parts of the code are silently broken and the programmer is screwed. An old example is magic quotes - your code will magically (and silently) break if the setting is changed without adjusting the code to compensate. Yea, I know they're deprecated in PHP5 and removed in PHP6, but it's just one off-the-top-of-my-head example of a bigger theme: It's standard practice by PHP's creators to toss in language-changing server settings, and without even having predictable defaults (the *defaults* can be configured. Seriously, WTF?). These settings often either can't be adjusted in the code itself (ex: magic quotes) or can only *sometimes* be adjusted in the code depending on how the server settings are configured (I think some session-management stuff falls into this category...and speaking of PHP's session-management...well, better *not* to speak of it). So not only does stuff change from one PHP version to another, but even within a *single exact* version of PHP you *still* have 2^^n number of what are essentially different languages, and no realistic way to work around it. So to write good reliable code in PHP: First, you have to have a deep understanding of every fucking setting offered by every version of PHP that you use. Of course, many of the important gotchas are completely undocumented and you have to go by hearsay and anecdotal advice. So good luck with that. Then you have to identify which of those settings might cause problems depending on how they're set and make sure to set them properly at the start of every single page (not always easy when your "package" system is one step away from the C preprocessor). Then, for the ones you can't change (because of either your sysadmin or PHP itself), you have to find the common "safe" subset and not venture beyond it (Ex: goodbye '<%%>' and '<??>', it's '<?php ?>' or nothing). When there isn't a safe common subset you can rely on (ex: magic quotes) you have to detect the active setting (if possible) and adapt. Of course, even doing that isn't always possible. Then when the server's PHP is upgraded, you have to check everything all over again (or just pray). Oh, and did I mention sometimes the OS and OS-configuration abstractions leek? Needless to say, writing good reliable code in PHP is realistically impossible (frankly, I don't even bother to try anymore). And if you want to make a re-usable library...hah! Ha ha ha!! Ah ha ha ha ha ha!!! So, PHP maintainability? Welcome to hell. PHP is evilness itself, given form as a programming language. Given a choice, I would seriously consider writing classic-ASP in VBScript on a WinME workstation running Microsoft Bob with an IDE that included Clippy if the only alternative was to do a big project in hand-written PHP.
Jun 05 2010
next sibling parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 06/06/10 03:02, Nick Sabalausky wrote:
 "Robert Clipsham"<robert octarineparrot.com>  wrote in message
 news:huembk$2660$1 digitalmars.com...
 Being the only two languages I'd call myself fluent in, I'd definitely
 call D easier to maintain than PHP... I guess this is easily debatable
 though.

Easily debatable? Not without an existing brain injury ;) I've used a lot of different languages. PHP's maintainability is one of the worst I've ever seen. The whole design of it *begs* for bugs.

Or worse, security issues - heck, the examples on php.net are so easy for someone new to the language to use to introduce a large number of security issues with it's unbelievable. It doesn't take much to find a number of SQL injections in the code most PHP devs write - it's so easy to do! If only there were a language that made safe operations easy to do and harder more bug prone things harder to do :3
 Hell, PHP is the only (*cough*) modern (*cough*) language I can think of
 where bugs can actually be introduced without any programmer involvement and
 without even touching a single line of code. The sysadmin just needs to
 change any one of certain PHP server settings (or move the code to another
 server that isn't configured exactly the same), and suddenly random parts of
 the code are silently broken and the programmer is screwed.

 An old example is magic quotes - your code will magically (and silently)
 break if the setting is changed without adjusting the code to compensate.
 Yea, I know they're deprecated in PHP5 and removed in PHP6, but it's just
 one off-the-top-of-my-head example of a bigger theme:

My favourite is register_globals - not only does it introduce bugs, it allows for remote code execution! Gotta love that ;)
 It's standard practice by PHP's creators to toss in language-changing server
 settings, and without even having predictable defaults (the *defaults* can
 be configured. Seriously, WTF?). These settings often either can't be
 adjusted in the code itself (ex: magic quotes) or can only *sometimes* be
 adjusted in the code depending on how the server settings are configured (I
 think some session-management stuff falls into this category...and speaking
 of PHP's session-management...well, better *not* to speak of it). So not
 only does stuff change from one PHP version to another, but even within a
 *single exact* version of PHP you *still* have 2^^n number of what are
 essentially different languages, and no realistic way to work around it.

Fortunately you can detect what's disabled/how it's configured etc in the script, it means you have to write 1000LoC of checks etc before every php app you write if you want it to be supported by a selection of hosts. Refusing anything less than PHP 5.2 helps here, there's still loads of checks you've gotta do though. I generally find the best way to avoid bugs due to different configs/PHP versions is to use error_reporting( E_ALL | E_STRICT | E_DEPRECATED ); at the start of all my code, even that has to check the PHP version though thanks to E_DEPRECATED... and there'll still be some bugs that manage to slip through :3
 So to write good reliable code in PHP:

I was gonna make a witty remark here, I found it turning into a rant so I removed it though :3
 First, you have to have a deep understanding of every fucking setting
 offered by every version of PHP that you use. Of course, many of the
 important gotchas are completely undocumented and you have to go by hearsay
 and anecdotal advice. So good luck with that.

This is completely true. Using some kind of PHP framework usually solves this problem for you as they do all the checks etc generally, it's still not perfect though, and the developer still has to be aware of what the framework actually checks for.
 Then you have to identify which of those settings might cause problems
 depending on how they're set and make sure to set them properly at the start
 of every single page (not always easy when your "package" system is one step
 away from the C preprocessor).

If you can set them properly that is :3 Gotta hate safe mode/the ability of clueless admins to disable functions which don't pose any security vulnerability to the server but they're adamant they do.
 Then, for the ones you can't change (because of either your sysadmin or PHP
 itself), you have to find the common "safe" subset and not venture beyond it
 (Ex: goodbye '<%%>' and'<??>', it's'<?php ?>' or nothing). When there
 isn't a safe common subset you can rely on (ex: magic quotes) you have to
 detect the active setting (if possible) and adapt. Of course, even doing
 that isn't always possible.

trigger_error( "Your setup sucks, damned if I'm writing code that supports it :3", E_USER_ERROR ); I love not having to write commercial code where supporting idiots is mandatory, I'd rather not spend 90% of my time making sure my code works on different setups :3
 Then when the server's PHP is upgraded, you have to check everything all
 over again (or just pray). Oh, and did I mention sometimes the OS and
 OS-configuration abstractions leek? Needless to say, writing good reliable
 code in PHP is realistically impossible (frankly, I don't even bother to try
 anymore). And if you want to make a re-usable library...hah! Ha ha ha!! Ah
 ha ha ha ha ha!!!

Fat chance of that if they've got register_globals enabled or magic_quotes etc. You'll be lucky if they upgrade in a few years :3 This said, there are people who are *that* stupid.
 So, PHP maintainability? Welcome to hell. PHP is evilness itself, given form
 as a programming language. Given a choice, I would seriously consider
 writing classic-ASP in VBScript on a WinME workstation running Microsoft Bob
 with an IDE that included Clippy if the only alternative was to do a big
 project in hand-written PHP.

I guess I'm lucky here, all the PHP I ever have to write now is supported by a framework/CMS that some guy who knows what he's doing made, I've yet to have any issues with it anywhere it's been run fortunately. I'd put money on this not being the case for most people though. I would be curious as to how well D/FastCGI works, guess I'll have to have a play at some point. Robert
Jun 06 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Robert Clipsham" <robert octarineparrot.com> wrote in message 
news:hufr5k$vnd$1 digitalmars.com...
 On 06/06/10 03:02, Nick Sabalausky wrote:

 So to write good reliable code in PHP:

I was gonna make a witty remark here, I found it turning into a rant so I removed it though :3

Heh heh. "good reliable code in PHP" *is* a contradiction of terms, after all ;)
 I guess I'm lucky here, all the PHP I ever have to write now is supported 
 by a framework/CMS that some guy who knows what he's doing made, I've yet 
 to have any issues with it anywhere it's been run fortunately. I'd put 
 money on this not being the case for most people though.

As much as I prefer to write Haxe (and then compile it down to PHP), one of the [many] things that bugs me about Haxe is that it doesn't appear to do any of those checks automatically. Big missed opportunity there.
 I would be curious as to how well D/FastCGI works, guess I'll have to have 
 a play at some point.

I've been positively salivating at the idea of combining D, FastCGI and a D-ified rails-like framework. Haven't gotten around to it though. Fortunately, I did recently find out that the hosts I'm currently using allow custom-made CGI. Unfortunately, I can't use FastCGI on them, although I've been getting so fed up with PHP lately (both the PHP language and the PHP platform - Haxe only sheilds you from [parts of] the language, not the platform), that I think I can live perfectly happily without FastCGI.
Jun 06 2010
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 06/06/10 18:26, Nick Sabalausky wrote:
 Heh heh. "good reliable code in PHP" *is* a contradiction of terms, after
 all ;)

<?php echo 'Not true! D:', "\n"; ?> This said, I bet we could find a case where that doesn't work properly :3
 As much as I prefer to write Haxe (and then compile it down to PHP), one of
 the [many] things that bugs me about Haxe is that it doesn't appear to do
 any of those checks automatically. Big missed opportunity there.

I've never really looked into haxe, but I agree, if it doesn't do those checks it's fairly useless - have you made a bug report? Your dreams could come true... Or you could forget and be forced to use D.. Dang!
 I've been positively salivating at the idea of combining D, FastCGI and a
 D-ified rails-like framework. Haven't gotten around to it though.
 Fortunately, I did recently find out that the hosts I'm currently using
 allow custom-made CGI. Unfortunately, I can't use FastCGI on them, although
 I've been getting so fed up with PHP lately (both the PHP language and the
 PHP platform - Haxe only sheilds you from [parts of] the language, not the
 platform), that I think I can live perfectly happily without FastCGI.

I've been toying with the same idea, the framework I've been looking at porting uses a lot of runtime reflection though which I'm not sure is easy enough to do in D1. I've strayed away from D2 now after a couple of unsuccessful attempts at using it. Robert
Jun 06 2010
parent "Nick Sabalausky" <a a.a> writes:
"Robert Clipsham" <robert octarineparrot.com> wrote in message 
news:hugmcq$2e8b$1 digitalmars.com...
 On 06/06/10 18:26, Nick Sabalausky wrote:
 Heh heh. "good reliable code in PHP" *is* a contradiction of terms, after
 all ;)

<?php echo 'Not true! D:', "\n"; ?> This said, I bet we could find a case where that doesn't work properly :3

I was thinking the same thing!
 As much as I prefer to write Haxe (and then compile it down to PHP), one 
 of
 the [many] things that bugs me about Haxe is that it doesn't appear to do
 any of those checks automatically. Big missed opportunity there.

I've never really looked into haxe, but I agree, if it doesn't do those checks it's fairly useless -

You can still do the checks yourself. And the language itself, while certainly no D, is at least an improvement over using PHP directly. So it's still a net win, just not as big of a win as it could be.
 have you made a bug report? Your dreams could come true...

Yes, probably worth a shot, but I think I like your other idea below better... ;)
 Or you could forget and be forced to use D.. Dang!

 I've been positively salivating at the idea of combining D, FastCGI and a
 D-ified rails-like framework. Haven't gotten around to it though.
 Fortunately, I did recently find out that the hosts I'm currently using
 allow custom-made CGI. Unfortunately, I can't use FastCGI on them, 
 although
 I've been getting so fed up with PHP lately (both the PHP language and 
 the
 PHP platform - Haxe only sheilds you from [parts of] the language, not 
 the
 platform), that I think I can live perfectly happily without FastCGI.

I've been toying with the same idea, the framework I've been looking at porting uses a lot of runtime reflection though which I'm not sure is easy enough to do in D1. I've strayed away from D2 now after a couple of unsuccessful attempts at using it.

Haxe already has a rails-like framework I've been using (Haxe Igniter). It does have room for improvement, though. In fact I ended up hacking up a few things in it. But yea, I've been really itching to make one in D. But hell, with more immediate paid(-ish) work in the way, it's taking me long enough just to get the next version of my Goldie project out.
Jun 06 2010
prev sibling parent Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
You just made me feel much less guilty that PHP's syntax turned me off 
back in my java days.
Jun 06 2010
prev sibling next sibling parent Adam Ruppe <destructionator gmail.com> writes:
On 6/5/10, retard <re tard.com.invalid> wrote:
 A rewrite of a shitty old version is better than the
 original.

The really interesting thing is how D on plain old CGI also performed better than fairly popular PHP applications as well, like phpBB3, WordPress and MediaWiki (determined by comparing individual pages that did basically the same thing. Not exactly though, so not a fully fair comparison)
Jun 05 2010
prev sibling next sibling parent reply Adam Ruppe <destructionator gmail.com> writes:
On 6/5/10, Jeff Nowakowski <jeff dilacero.org> wrote:
 Why is this interesting? D is a static, compiled, "system" language
 designed to be near the speed of C. PHP is a scripting language, similar
 to Perl, but built to make web coding easier.

The reason I did the benchmarks was because I was talking to someone about it, and he said "yeah, php sucks, but isn't CGI really slow?" It isn't, not with D. If you don't address request speed and scalability, nobody's going to listen to the other benefits. Opening with a statement like "200% faster" keeps their attention. The biggest benefit, however, isn't running speed, but instead code maintainability.
 If you
 want your article to be taken seriously, you'll have to show code
 written in idiomatic PHP that benefits from being written in idiomatic D.

That's the plan. I'm hoping to write this up next weekend.
Jun 05 2010
parent "Nick Sabalausky" <a a.a> writes:
"Adam Ruppe" <destructionator gmail.com> wrote in message 
news:mailman.111.1275779198.24349.digitalmars-d puremagic.com...
 On 6/5/10, Jeff Nowakowski <jeff dilacero.org> wrote:
 Why is this interesting? D is a static, compiled, "system" language
 designed to be near the speed of C. PHP is a scripting language, similar
 to Perl, but built to make web coding easier.

The reason I did the benchmarks was because I was talking to someone about it, and he said "yeah, php sucks, but isn't CGI really slow?" It isn't, not with D.

Yea, justified or not, it's a very prevailant belief in the web dev world that CGI == slow (since the whole process is reloaded on every request). In fact, until Adam mentioned his results, I had been wondering how CGI's overhead compared to the speed hit from using something like PHP (Of course, it probably depends on other things too, like Win vs Unix, Apache vs IIS, how much processing is actually done to generate the page, etc). And there's a lot of web devs and managers out there who would never even think to question their ingrained belief that CGI is slow. There's fastcgi, of course, but a lot of web devs (and managers) have never even heard of that.
Jun 05 2010
prev sibling parent Adam Ruppe <destructionator gmail.com> writes:
On 6/5/10, Robert Clipsham <robert octarineparrot.com> wrote:
 It isn't anyway, at least not with fastcgi - take mod_php vs php in
 fcgi, fcgi is far *far* faster.

My numbers are all plain old vanilla CGI; fcgi would probably be better yet. My hypothesis is that CGI gets its reputation because it has a relatively high start up cost, so it gets horrible numbers for hello world benchmarks. But, start up is a small percentage of a real world program's actual running time, so for most non-trivial programs, having faster code quickly erases CGI's initial deficit.
Jun 05 2010
prev sibling next sibling parent reply Adam Ruppe <destructionator gmail.com> writes:
I recently rewrote a huge PHP application in D2. It isn't a completely
fair comparison, since the PHP was written by, well to be polite, PHP
"programmers", but the results were pretty astounding.

90% reduction in lines of code [!], 200% improvement in speed under
heavy load (only 50% improvement under light load, still good, but not
as good), and the code is actually maintainable! Also, the original
took about a year for the first team to write. My D rewrite took 6
weeks. Oh yeah, and the PHP is riddled with security holes. Not so
much with the D.

The best part about the speed is that it is just running as plain old
CGI and my code does a lot of inefficient looping through XML. I could
probably double the speed again by improving that.


I might be able to write this into an article, but what I've done so
far is just showed it off to other coders in some private messages on
forums. A complication in publically showing it off is it is closed
source though. The speed advantage isn't apparent until the code
actually does something; PHP is much faster for hello world, but gets
spanked when it comes to the actual work.
Jun 03 2010
parent "Nick Sabalausky" <a a.a> writes:
"Adam Ruppe" <destructionator gmail.com> wrote in message 
news:mailman.103.1275615255.24349.digitalmars-d puremagic.com...
I recently rewrote a huge PHP application in D2. It isn't a completely
 fair comparison, since the PHP was written by, well to be polite, PHP
 "programmers", but the results were pretty astounding.

 90% reduction in lines of code [!], 200% improvement in speed under
 heavy load (only 50% improvement under light load, still good, but not
 as good), and the code is actually maintainable! Also, the original
 took about a year for the first team to write. My D rewrite took 6
 weeks. Oh yeah, and the PHP is riddled with security holes. Not so
 much with the D.

 The best part about the speed is that it is just running as plain old
 CGI and my code does a lot of inefficient looping through XML. I could
 probably double the speed again by improving that.

Comparing D to PHP is like comparing a 747 to the Hindenburg. :)
Jun 03 2010
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:hu9fic$24ic$1 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_func
ion_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.

More of a long term-thing, but D needs a couple of "killer libs" (for instance, a really good D version of something Rails-like). Then, of course, an article walking through the use of it to easily create something fancy.
Jun 03 2010
parent JMRyan <nospam nospam.com> writes:
"Nick Sabalausky" <a a.a> wrote in news:hu9na8$2hho$1 digitalmars.com:

 More of a long term-thing, but D needs a couple of "killer libs" (for 
 instance, a really good D version of something Rails-like). Then, of
 course, an article walking through the use of it to easily create
 something fancy. 

I think I've said this before, but D needs a two killer apps plus one medical journal article. One of the killer apps needs to be commercial/proprietary so that people can see money being made with D. The other killer app needs to be open source so that contributors have to use D to work on it. The medical journal article needs to report that contributing to the open source app cures erectile dysfunction disorder.
Jun 03 2010
prev sibling next sibling parent Trass3r <un known.com> writes:
 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_func
ion_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?

What about a followup article about more sophisticated CTFE, maybe in combination with string mixins to generate complex code? For example, if std.regex is evaluatable at compile time I will probably use it create some skeleton code out of an interface definition.
Jun 03 2010
prev sibling next sibling parent Alex Makhotin <alex bitprox.com> writes:
Walter Bright wrote:
 
 Anyone have good ideas on topics for D articles?
 

Yes, I think the relevant themes are: 1. High, comparable to C performance, unlike C# or Java, preserving features from such competitor languages. 2. D does not require the programmer to use only one particular paradigm, at the option of imperative, object oriented, and metaprogramming; does not require significant change of syntax, helps migrating to D quickly from C/C++, while significantly increasing productivity; direct linking with C libraries; direct access to the native OS interface. I also should mention, these need improvement in D: 1. Concurrency support and optimization for multicore/multiprocessor/GPGPU systems. 2. Better toolchain support. The first two inspired me to try the D. The second two should inspire the others. -- Alex Makhotin, the founder of BITPROX, http://bitprox.com
Jun 04 2010
prev sibling next sibling parent =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench robertmuench.de> writes:
On 2010-06-04 01:58:03 +0200, Walter Bright said:

 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_func
ion_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.

I will write a blog article how I used D to write an extension DLL for the Rebol-3 language. I used the C stuff and ported it over in a couple of hours. Being now able to use D on the compile side give totally new possibilities. On the other hand those articles should focus on those complaints and sighs topics from other languages and show how elegant D can solve it. To keep the link. -- Robert M. M黱ch http://www.robertmuench.de
Jun 04 2010
prev sibling next sibling parent reply Justin Johansson <no spam.com> writes:
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_func
ion_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.
Jun 04 2010
parent Graham Fawcett <fawcett uwindsor.ca> writes:
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/


  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
Jun 04 2010
prev sibling next sibling parent Long Chang <changedalone gmail.com> writes:
--0015177416b823044904883d6693
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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 gener=
ate
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=E3=80=82
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 wi=

 D. Essentially, we have a marketing problem.

 One great way to address it is by writing articles about various aspects =

 D and how they solve problems, like
 http://www.reddit.com/r/programming/comments/cb14j/compiletime_function_e=

 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.

--0015177416b823044904883d6693 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <span id=3D"result_box" class=3D"short_text"><span style=3D"" title=3D"">ho= w to generate a header file in the source files dir?</span></span> when i w= an&#39;t get a big project like dwtx headers, i like push all source file t= o dmd and <span id=3D"result_box" class=3D"short_text"><span style=3D"" tit= le=3D"">generate=C2=A0 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=E3=80=82 <br></span></span><span = id=3D"result_box" class=3D"short_text"><span style=3D"background-color: rgb= (255, 255, 255);" title=3D"">This is very inconvenient for such a large=20 projects</span></span>,=C2=A0 <span id=3D"result_box" class=3D"short_text">= <span style=3D"" title=3D"">Is=20 there any way to avoid this problem?</span></span><br><br><div class=3D"gma= il_quote">2010/6/4 Walter Bright <span dir=3D"ltr">&lt;<a href=3D"mailto:ne= wshound1 digitalmars.com">newshound1 digitalmars.com</a>&gt;</span><br><blo= ckquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-le= ft: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> D is an extremely powerful language, but when I read complaints and sighs a= bout other languages, few seem to know that these problems are solved with = D. Essentially, we have a marketing problem.<br> <br> One great way to address it is by writing articles about various aspects of= D and how they solve problems, like <a href=3D"http://www.reddit.com/r/pro= gramming/comments/cb14j/compiletime_function_execution_in_d/" target=3D"_bl= ank">http://www.reddit.com/r/programming/comments/cb14j/compiletime_functio= n_execution_in_d/</a> =C2=A0which was well received on reddit.<br> <br> Anyone have good ideas on topics for D articles? And anyone want to stand u= p and write an article?<br> <br> They don&#39;t have to be comprehensive articles (though of course those ar= e better), even blog entries will do.<br> </blockquote></div><br> --0015177416b823044904883d6693--
Jun 04 2010
prev sibling next sibling parent sybrandy <sybrandy gmail.com> writes:
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
Jun 04 2010
prev sibling next sibling parent reply "ArnoldSSchwartz" <asschwann usenet.com> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:hu9fic$24ic$1 digitalmars.com...
D is an extremely powerful language,

Like OxyClean! (?)
  but when I read complaints and sighs about other languages, few seem 
 to know that these problems are solved with D.

So will this snakeoil solve my rheumatoid arthritis?
 Essentially, we have a marketing problem.

Go (go pun intended) figure?.
 One great way to address it

Whoa, you presented a "hypothesis", and are now "embarking off on it" and soliciting others to do the same and take it for granted that your "hypothesis" (or whatever it was) is good. It's one thing to throw good money after bad. It's quite another to draw other people into your losing game.
Jun 05 2010
parent BCS <none anon.com> writes:
ArnoldSSchwartz wrote,

[nothing of value]
Jun 06 2010
prev sibling next sibling parent reply "ArnoldSSchwartz" <asschwann usenet.com> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:hu9fic$24ic$1 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_func
ion_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.

I think you have and have had good intent (that is not necessarily a reality, just a hope, I don't trust anyone or believe anything). I don't diss you. If I had a compiler to build, I'd send out an RFP to you, maybe. If I had a "task" to fill that required a "language builder", I wouldn't call on you, knowing what I know about you and this place. I know you're old, so I won't task you with riddles, so I'll give that answer: "building a language", is not a task on a project manager's schedule. You have kids (I hope!). I think you should put D in maintenance mode (like C and C++ are).
Jun 05 2010
parent reply eles <eles eles.com> writes:
I think Walter has been doing a great job with D. I do not like all
the choices he has made (I am more radical when it is about breaking
old habits from C) but, overall, D is an admirable and well-balanced
language. And dmd a quite nice compiler. I hope it will be on 64-bits
asap.

I admire and use Walter's work.

eles

== Quote from ArnoldSSchwartz (asschwann usenet.com)'s article
 "Walter Bright" <newshound1 digitalmars.com> wrote in message
 news:hu9fic$24ic$1 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


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/


 which was well received on reddit.

 Anyone have good ideas on topics for D articles? And anyone want


 stand up and write an article?

 They don't have to be comprehensive articles (though of course


 are better), even blog entries will do.

reality, just a hope, I don't trust anyone or believe anything). I

 diss you. If I had a compiler to build, I'd send out an RFP to you,
 maybe. If I had a "task" to fill that required a "language

 wouldn't call on you, knowing what I know about you and this place.

 know you're old, so I won't task you with riddles, so I'll give that
 answer: "building a language", is not a task on a project manager's
 schedule.
 You have kids (I hope!). I think you should put D in maintenance

 (like C and C++ are).

Jun 06 2010
parent "ArnoldSSchwartz" <asschwann usenet.com> writes:
"eles" <eles eles.com> wrote in message 
news:hufl4b$mkf$1 digitalmars.com...
 but, overall, D is an admirable and well-balanced
 language.

Why?
 And dmd a quite nice compiler.

ech. That's just technical detail.
 I hope it will be on 64-bits asap.

It doesn't seem so hard to do. I am surprised to hear that there was no such forsight. I don't build any 32-bit computers anymore. Win 7 64-bit only.
Jun 06 2010
prev sibling next sibling parent reply dennis luehring <dl.soluz gmx.net> writes:
Am 04.06.2010 01:58, schrieb Walter Bright:
 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.

what about writing an "connect" example of D featureset usage in an C, or C++ and the way back - something that shows Ds interoperability - with some compiler (like intel/microsoft and borland) related tools, example what is needed to bring the different object-formats together
Jun 06 2010
parent reply Alex Makhotin <alex bitprox.com> writes:
dennis luehring wrote:
  
 with some compiler (like intel/microsoft and borland) related tools, 
 example what is needed to bring the different object-formats together

I experienced a runtime access violation on Windows when interoperating with the DLL created with the MSVC, which attempted to callback DMD executable. Mingw32 GCC is doing well, however cannot interoparate with XPCOM. Unless I'm doing something wrong, crosscompiler interoperability is a problem for me, however such issue have other languages. If there's a reference on how to face this kind of problems, I would be glad to have it, like other people which supposed to work with the D. -- Alex Makhotin, the founder of BITPROX, http://bitprox.com
Jun 06 2010
parent reply dennis luehring <dl.soluz gmx.net> writes:
Am 06.06.2010 14:41, schrieb Alex Makhotin:
 dennis luehring wrote:
  with some compiler (like intel/microsoft and borland) related tools,
  example what is needed to bring the different object-formats together

I experienced a runtime access violation on Windows when interoperating with the DLL created with the MSVC, which attempted to callback DMD executable. Mingw32 GCC is doing well, however cannot interoparate with XPCOM. Unless I'm doing something wrong, crosscompiler interoperability is a problem for me, however such issue have other languages. If there's a reference on how to face this kind of problems, I would be glad to have it, like other people which supposed to work with the D.

perfekt scenario! can you provide us with some "small" example of working/non-working constructs? that combined with an more real example of the ABI-Usage will have the needed low-level-style for an good article/blog entry - Zarathustra got currently some ABI description problems in the D.learn group under the delegates with C linkage topic maybe we can all put together nice examples, talking about objs,assembler,call-styles etc.
Jun 06 2010
parent dennis luehring <dl.soluz gmx.net> writes:
Am 06.06.2010 19:49, schrieb dennis luehring:
 Am 06.06.2010 14:41, schrieb Alex Makhotin:
  dennis luehring wrote:
   with some compiler (like intel/microsoft and borland) related tools,
   example what is needed to bring the different object-formats together

I experienced a runtime access violation on Windows when interoperating with the DLL created with the MSVC, which attempted to callback DMD executable. Mingw32 GCC is doing well, however cannot interoparate with XPCOM. Unless I'm doing something wrong, crosscompiler interoperability is a problem for me, however such issue have other languages. If there's a reference on how to face this kind of problems, I would be glad to have it, like other people which supposed to work with the D.

perfekt scenario! can you provide us with some "small" example of working/non-working constructs? that combined with an more real example of the ABI-Usage will have the needed low-level-style for an good article/blog entry - Zarathustra got currently some ABI description problems in the D.learn group under the delegates with C linkage topic maybe we can all put together nice examples, talking about objs,assembler,call-styles etc.

what about a large (splitted into smaller ones) article about 1. absolute low level D -> how to call C (maybe also small C++) examples using mingw,gcc,vs (different obj formats) and intel - and back (variables, functions, delegates, strings, etc...) 2. higher abstraction using Dll-Callbacks, Dll-Calling etc., Win-Api, COM 3. application leven XPCOM, JNI etc., Dot.Net? all combined with small "thats the detailed look in assembler, c-style" "what does microsoft, intel, etc. compiler do" good idea?
Jun 06 2010
prev sibling next sibling parent reply dsimcha <dsimcha yahoo.com> writes:
== Quote from Walter Bright (newshound1 digitalmars.com)'s article
 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

   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.

This probably won't be replied to because I'm starting a new sub-thread in a mature discussion, but I wonder if we could write about the advantages and disadvantages of duck typing vs. static typing, comparing Python vs. Java at first, then bring D into the picture to show how, to a greater extent than C++ templates or C#/Java generics, it solves may of the problems of static typing without introducing the pitfalls of duck typing. Here's a simple example of something that would be awkward to impossible to do efficiently in any other language: /**Finds the largest element present in any of the ranges passed in.\ */ CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) { // Quick and dirty impl ignoring error checking: typeof(return) ret = args[0].front(); foreach(arg; args) { foreach(elem; arg) { ret = max(elem, ret); } } return ret; } Do this in C++ -> FAIL because there are no variadics. (Yes, C++1x will have them, but I might die of old age by the time C++1x exists.) Do this in any dynamic language -> FAIL because looping is so slow that you might die of old age before it executes. Besides, who wants to do computationally intensive, multithreaded work in a dynamic language? Do this in Java -> FAIL because arrays are primitives, not Objects and variadics only work with Objects. You can't easily make an array of arrays because the elements of args may be different but related types (e.g. int, float). Do this in C# -> FAIL because variadics aren't type-safe. You just get an array of Object, which you have to cast, and w/o some extra information you don't know what to cast them to.
Jun 06 2010
next sibling parent Justin Spahr-Summers <Justin.SpahrSummers gmail.com> writes:
On Sun, 6 Jun 2010 22:42:42 +0000 (UTC), dsimcha <dsimcha yahoo.com> 
wrote:
 
 == Quote from Walter Bright (newshound1 digitalmars.com)'s article
 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

   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.

This probably won't be replied to because I'm starting a new sub-thread in a mature discussion, but I wonder if we could write about the advantages and disadvantages of duck typing vs. static typing, comparing Python vs. Java at first, then bring D into the picture to show how, to a greater extent than C++ templates or C#/Java generics, it solves may of the problems of static typing without introducing the pitfalls of duck typing. Here's a simple example of something that would be awkward to impossible to do efficiently in any other language: /**Finds the largest element present in any of the ranges passed in.\ */ CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) { // Quick and dirty impl ignoring error checking: typeof(return) ret = args[0].front(); foreach(arg; args) { foreach(elem; arg) { ret = max(elem, ret); } } return ret; } Do this in C++ -> FAIL because there are no variadics. (Yes, C++1x will have them, but I might die of old age by the time C++1x exists.) Do this in any dynamic language -> FAIL because looping is so slow that you might die of old age before it executes. Besides, who wants to do computationally intensive, multithreaded work in a dynamic language? Do this in Java -> FAIL because arrays are primitives, not Objects and variadics only work with Objects. You can't easily make an array of arrays because the elements of args may be different but related types (e.g. int, float).

Seems like that example could be done fairly easily with Objective-C. Granted, it won't have the raw performance of D, but it might be worthwhile to point it out, since it (or rather, its superset on top of C) is duck typed. If someone were to create Objective-D, I think I'd die of happiness.
Jun 06 2010
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"dsimcha" <dsimcha yahoo.com> wrote in message 
news:huh892$agk$1 digitalmars.com...
 /**Finds the largest element present in any of the ranges passed in.\
 */
 CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
    // Quick and dirty impl ignoring error checking:
    typeof(return) ret = args[0].front();

    foreach(arg; args) {
        foreach(elem; arg) {
            ret = max(elem, ret);
        }
    }

    return ret;
 }

I clearly haven't been following D2 closely enough. Or maybe I'm just more tired than I think... Can you explain that function signature?: CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
 Do this in C++ -> FAIL because there are no variadics.  (Yes, C++1x will 
 have
 them, but I might die of old age by the time C++1x exists.)

C++0x^H^H1x is starting to remind me of Duke Nukem Forever. (Except I actually gave a rat's ass about Duke ;) )
 Do this in any dynamic language -> FAIL because looping is so slow that 
 you might
 die of old age before it executes.  Besides, who wants to do 
 computationally
 intensive, multithreaded work in a dynamic language?

I bet there's a lot of people who wouldn't bat an eye at that idea. Unfortunately.
 Do this in Java -> FAIL because arrays are primitives, not Objects and 
 variadics
 only work with Objects.  You can't easily make an array of arrays because 
 the
 elements of args may be different but related types (e.g. int, float).

I actually find that funny. Something in Java that isn't an Object? I remember "Everything's an object!" being paraded around as a selling point.
Jun 06 2010
parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Nick Sabalausky wrote:
 I actually find that funny. Something in Java that isn't an Object? I=20
 remember "Everything's an object!" being paraded around as a selling po=

=20

the language "designers". There are several such design decisions in Java... Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 07 2010
parent reply "Nick Sabalausky" <a a.a> writes:
""J閞鬽e M. Berger"" <jeberger free.fr> wrote in message 
news:hujboe$tp2$1 digitalmars.com...
Nick Sabalausky wrote:
 I actually find that funny. Something in Java that isn't an Object? I
 remember "Everything's an object!" being paraded around as a selling 
 point.

the language "designers". There are several such design decisions in Java...

Yea, that's a good example of why I've grown a distaste towards hard-and-fast religious design strategies. The designer inevitably comes across cases where it just doesn't work particularly well, and then they're forced to either stay true to their misguided principles by accepting an awkward problematic design, or contradict their alleged principles and go with a better design. And when they do the latter, that runs the risk of causing problems in other areas that had been relying on the old principle being rigidly followed. ------------------------------- Not sent from an iPhone.
Jun 07 2010
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Nick Sabalausky wrote:
 Yea, that's a good example of why I've grown a distaste towards 
 hard-and-fast religious design strategies. The designer inevitably comes 
 across cases where it just doesn't work particularly well, and then they're 
 forced to either stay true to their misguided principles by accepting an 
 awkward problematic design, or contradict their alleged principles and go 
 with a better design. And when they do the latter, that runs the risk of 
 causing problems in other areas that had been relying on the old principle 
 being rigidly followed.

D has design principles, but those principles are often contradictory. I don't see a good reason to follow a design principle out of principle if it destroys the utility of the language. For example, consider: version (unittest) 'unittest' is a keyword, not an identifier. Making this work requires a special case in the grammar. But the alternatives, version (Unittest) version (unit_test) version (unittests) etc. are all much worse than simply violating a principle and putting the special case in.
Jun 07 2010
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:hujdg6$125b$1 digitalmars.com...
 Nick Sabalausky wrote:
 Yea, that's a good example of why I've grown a distaste towards 
 hard-and-fast religious design strategies. The designer inevitably comes 
 across cases where it just doesn't work particularly well, and then 
 they're forced to either stay true to their misguided principles by 
 accepting an awkward problematic design, or contradict their alleged 
 principles and go with a better design. And when they do the latter, that 
 runs the risk of causing problems in other areas that had been relying on 
 the old principle being rigidly followed.

D has design principles, but those principles are often contradictory. I don't see a good reason to follow a design principle out of principle if it destroys the utility of the language. For example, consider: version (unittest) 'unittest' is a keyword, not an identifier. Making this work requires a special case in the grammar. But the alternatives, version (Unittest) version (unit_test) version (unittests) etc. are all much worse than simply violating a principle and putting the special case in.

Great example. Of course, one could argue that we religiously follow pragmatism ;) ------------------------------- Not sent from an iPhone.
Jun 07 2010
prev sibling next sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Leandro Lucarella wrote:
 Please, document this!
 
 http://d.puremagic.com/issues/show_bug.cgi?id=4230

Done.
Jun 07 2010
prev sibling parent Justin Johansson <no spam.com> writes:
Walter Bright wrote:
 Nick Sabalausky wrote:
 Yea, that's a good example of why I've grown a distaste towards 
 hard-and-fast religious design strategies. The designer inevitably 
 comes across cases where it just doesn't work particularly well, and 
 then they're forced to either stay true to their misguided principles 
 by accepting an awkward problematic design, or contradict their 
 alleged principles and go with a better design. And when they do the 
 latter, that runs the risk of causing problems in other areas that had 
 been relying on the old principle being rigidly followed.

D has design principles, but those principles are often contradictory. I don't see a good reason to follow a design principle out of principle if it destroys the utility of the language.

Me feels that many readers of this ng would enjoy a recap of just exactly are those design principles? Of more interest though will be the ensuring discussion from your response!!! :-)
Jun 13 2010
prev sibling parent Justin Johansson <no spam.com> writes:
retard wrote:
 Mon, 07 Jun 2010 14:06:24 -0400, Nick Sabalausky wrote:
 
 ""J茅r么me M. Berger"" <jeberger free.fr> wrote in message
 news:hujboe$tp2$1 digitalmars.com...
 Nick Sabalausky wrote:
 I actually find that funny. Something in Java that isn't an Object? I
 remember "Everything's an object!" being paraded around as a selling
 point.

the language "designers". There are several such design decisions in Java...

hard-and-fast religious design strategies. The designer inevitably comes across cases where it just doesn't work particularly well, and then they're forced to either stay true to their misguided principles by accepting an awkward problematic design, or contradict their alleged principles and go with a better design. And when they do the latter, that runs the risk of causing problems in other areas that had been relying on the old principle being rigidly followed.

Part of the "religious" feel of Java comes from the fact that it runs on a VM. The safe memory model imposes some restrictions as you might have noticed in SafeD. The 'everything is an Object' idea is a bit broken, performance-wise. That's why C# added reified types. The reason they added primitive types has a rationale behind it. The decision made the VM a useful tool for real enterprise applications.

Hear, hear. The idea that "everything is a Object" is definitely broken. Java cannot fix this misidea and this leaves an opportunity for newcomer languages (or oldcomer languages in new clothes).
Jun 13 2010
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--0016e6db2dc7cebb82048869c600
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Jun 7, 2010 at 06:58, Nick Sabalausky <a a.a> wrote:

 "dsimcha" <dsimcha yahoo.com> wrote in message
 news:huh892$agk$1 digitalmars.com...
 /**Finds the largest element present in any of the ranges passed in.\
 */
 CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
    // Quick and dirty impl ignoring error checking:
    typeof(return) ret = args[0].front();

    foreach(arg; args) {
        foreach(elem; arg) {
            ret = max(elem, ret);
        }
    }

    return ret;
 }

I clearly haven't been following D2 closely enough. Or maybe I'm just more tired than I think... Can you explain that function signature?: CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {

different element types. staticMap!(ElementType, T) will map the ElementType template on each type in T and from this typetuple create another typetuple:the application of ElementType on each of them: say you have T == (int[], byte[], ulong[]) then staticMap!(ElementType, T) is (int,byte,ulong) Then, CommonType is a template that takes a typetuple and finds the common type among them. Then any element from any of the input ranges can be cast to this type. If CommonType finds no common type, it returns 'void'. Then, he use typeof(return) to create a variable with this type he just obtained. I really like this compile-time calculations on types: as David said, it allows you to stay generic while having well-defined behavior. Of course, in a real application, you would put a constraint on this template, testing for CommonType not to be void. That way, calling largest element on (string[], double[][]) wouldn't even compile. Hmm, in fact it could be put in this example, because it shows this kind of function can be safe. Philippe --0016e6db2dc7cebb82048869c600 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Mon, Jun 7, 2010 at 06:58, Nick Sabalausky <s= pan dir=3D"ltr">&lt;a a.a&gt;</span> wrote:<br><blockquote class=3D"gmail_q= uote" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 2= 04, 204); padding-left: 1ex;"> &quot;dsimcha&quot; &lt;<a href=3D"mailto:dsimcha yahoo.com">dsimcha yahoo.= com</a>&gt; wrote in message<br> news:huh892$agk$1 digitalmars.com...<br> <div class=3D"im">&gt;<br> &gt; /**Finds the largest element present in any of the ranges passed in.\<= br> &gt; */<br> &gt; CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {= <br> &gt; =A0 =A0// Quick and dirty impl ignoring error checking:<br> &gt; =A0 =A0typeof(return) ret =3D args[0].front();<br> &gt;<br> &gt; =A0 =A0foreach(arg; args) {<br> &gt; =A0 =A0 =A0 =A0foreach(elem; arg) {<br> &gt; =A0 =A0 =A0 =A0 =A0 =A0ret =3D max(elem, ret);<br> &gt; =A0 =A0 =A0 =A0}<br> &gt; =A0 =A0}<br> &gt;<br> &gt; =A0 =A0return ret;<br> &gt; }<br> &gt;<br> <br> </div>I clearly haven&#39;t been following D2 closely enough. Or maybe I&#3= 9;m just more<br> tired than I think... Can you explain that function signature?:<br> <div class=3D"im">CommonType!(staticMap!(ElementType, T)) largestElement(T.= ..)(T args) {<br><br></div></blockquote><div><br>T is a typetuple, with ran= ges as elements (types). These ranges may have different element types.=A0 = staticMap!(ElementType, T) will map the ElementType template on each type i= n T and from this typetuple create another typetuple:the application of Ele= mentType on each of them:<br> <br>say you have T =3D=3D (int[], byte[], ulong[])<br><br>then staticMap!(E= lementType, T) is (int,byte,ulong)<br><br>Then, CommonType is a template th= at takes a typetuple and finds the common type among them. Then any element= from any of the input ranges can be cast to this type. If CommonType finds= no common type, it returns &#39;void&#39;.<br> Then, he use typeof(return) to create a variable with this type he just obt= ained.<br><br>I really like this compile-time calculations on types: as Dav= id said, it allows you to stay generic while having well-defined behavior.<= br> Of course, in a real application, you would put a constraint on this templa= te, testing for CommonType not to be void. That way, calling largest elemen= t on (string[], double[][]) wouldn&#39;t even compile.<br><br><br>Hmm, in f= act it could be put in this example, because it shows this kind of function= can be safe.<br> <br><br>Philippe<br><br></div></div> --0016e6db2dc7cebb82048869c600--
Jun 06 2010
prev sibling next sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

dsimcha wrote:
 =3D=3D Quote from Walter Bright (newshound1 digitalmars.com)'s article
 D is an extremely powerful language, but when I read complaints and si=


 other languages, few seem to know that these problems are solved with =


 Essentially, we have a marketing problem.
 One great way to address it is by writing articles about various aspec=


 and how they solve problems, like


   which was well received on reddit.
 Anyone have good ideas on topics for D articles? And anyone want to st=


 write an article?
 They don't have to be comprehensive articles (though of course those a=


 better), even blog entries will do.

This probably won't be replied to because I'm starting a new sub-thread=

 mature discussion, but I wonder if we could write about the advantages =

 disadvantages of duck typing vs. static typing, comparing Python vs. Ja=

 first, then bring D into the picture to show how, to a greater extent t=

 templates or C#/Java generics, it solves may of the problems of static =

 without introducing the pitfalls of duck typing.
=20
 Here's a simple example of something that would be awkward to impossibl=

 efficiently in any other language:
=20
 /**Finds the largest element present in any of the ranges passed in.\
  */
 CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
     // Quick and dirty impl ignoring error checking:
     typeof(return) ret =3D args[0].front();
=20
     foreach(arg; args) {
         foreach(elem; arg) {
             ret =3D max(elem, ret);
         }
     }
=20
     return ret;
 }
=20
 Do this in C++ -> FAIL because there are no variadics.  (Yes, C++1x wil=

 them, but I might die of old age by the time C++1x exists.)
=20
 Do this in any dynamic language -> FAIL because looping is so slow that=

 die of old age before it executes.  Besides, who wants to do computatio=

 intensive, multithreaded work in a dynamic language?
=20

performances and is *much* more elegant... Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 07 2010
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/07/2010 12:57 PM, "J茅r么me M. Berger" wrote:
 dsimcha wrote:
 == Quote from Walter Bright (newshound1 digitalmars.com)'s article
 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

    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.

This probably won't be replied to because I'm starting a new sub-thread in a mature discussion, but I wonder if we could write about the advantages and disadvantages of duck typing vs. static typing, comparing Python vs. Java at first, then bring D into the picture to show how, to a greater extent than C++ templates or C#/Java generics, it solves may of the problems of static typing without introducing the pitfalls of duck typing. Here's a simple example of something that would be awkward to impossible to do efficiently in any other language: /**Finds the largest element present in any of the ranges passed in.\ */ CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) { // Quick and dirty impl ignoring error checking: typeof(return) ret = args[0].front(); foreach(arg; args) { foreach(elem; arg) { ret = max(elem, ret); } } return ret; } Do this in C++ -> FAIL because there are no variadics. (Yes, C++1x will have them, but I might die of old age by the time C++1x exists.) Do this in any dynamic language -> FAIL because looping is so slow that you might die of old age before it executes. Besides, who wants to do computationally intensive, multithreaded work in a dynamic language?

performances and is *much* more elegant...

I very much doubt that. Andrei
Jun 07 2010
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:hujc46$v49$1 digitalmars.com...
 On 06/07/2010 12:57 PM, "J閞鬽e M. Berger" wrote:
 dsimcha wrote:
 == Quote from Walter Bright (newshound1 digitalmars.com)'s article
 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

    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.

This probably won't be replied to because I'm starting a new sub-thread in a mature discussion, but I wonder if we could write about the advantages and disadvantages of duck typing vs. static typing, comparing Python vs. Java at first, then bring D into the picture to show how, to a greater extent than C++ templates or C#/Java generics, it solves may of the problems of static typing without introducing the pitfalls of duck typing. Here's a simple example of something that would be awkward to impossible to do efficiently in any other language: /**Finds the largest element present in any of the ranges passed in.\ */ CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) { // Quick and dirty impl ignoring error checking: typeof(return) ret = args[0].front(); foreach(arg; args) { foreach(elem; arg) { ret = max(elem, ret); } } return ret; } Do this in C++ -> FAIL because there are no variadics. (Yes, C++1x will have them, but I might die of old age by the time C++1x exists.) Do this in any dynamic language -> FAIL because looping is so slow that you might die of old age before it executes. Besides, who wants to do computationally intensive, multithreaded work in a dynamic language?

performances and is *much* more elegant...

I very much doubt that. Andrei

It might be faster than using nested loops in Python. But yea, seems unlikely it would compare to the D version. Plus, can't you still do something like this? (I may not have this exactly right) CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) { static assert( !is(typeof(return) == void) ); return max( map!max(args) ); } Assuming, of course, a 'max' that works on a range, which would be easy enough to do. Probably something like: T max(T range) { return reduce!ordinaryMax(range); // Or return reduce!"a>b?a:b"(range); } ------------------------------- Not sent from an iPhone.
Jun 07 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be easy 
 enough to do. Probably something like:

ElementType!T max(T range) // Corrected
 {
    return reduce!ordinaryMax(range);
    // Or
    return reduce!"a>b?a:b"(range);
 }

Jun 07 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:hujd9m$11of$1 digitalmars.com...
 "Nick Sabalausky" <a a.a> wrote in message 
 news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be easy 
 enough to do. Probably something like:

ElementType!T max(T range) // Corrected
 {
    return reduce!ordinaryMax(range);
    // Or
    return reduce!"a>b?a:b"(range);
 }


Or: alias reduce!"a>b?a:b" max; God, I love D :)
Jun 07 2010
next sibling parent BCS <none anon.com> writes:
Hello Nick,

 "Nick Sabalausky" <a a.a> wrote in message
 news:hujd9m$11of$1 digitalmars.com...
 
 "Nick Sabalausky" <a a.a> wrote in message
 news:hujd6a$11e8$1 digitalmars.com...
 
 Assuming, of course, a 'max' that works on a range, which would be
 easy enough to do. Probably something like:
 

 {
 return reduce!ordinaryMax(range);
 // Or
 return reduce!"a>b?a:b"(range);
 }


alias reduce!"a>b?a:b" max; God, I love D :)

so we have: alias reduce!"a>b?a:b" range_max; CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) { static assert( !is(typeof(return) == void) ); return max( map!max(args) ); } Why isn't that just one line, like: alias polyMapReduce!(reduce!"a>b?a:b", "a>b?a:b") largestElelemt; I'm shure a better one could be written but I think this would do it: auto polyMapReduce(alias map, string reduce, T...)(T t) { static assert(T.length > 0); static if(T.length > 1) { auto a = map(t[0]); auto b = polyMapReduce!(map,reduce)(t[1..$]); return mixin(reduce); } else return map(t[0]); } -- ... <IXOYE><
Jun 07 2010
prev sibling next sibling parent reply KennyTM~ <kennytm gmail.com> writes:
On Jun 8, 10 15:55, retard wrote:
 Mon, 07 Jun 2010 18:16:15 -0400, Nick Sabalausky wrote:

 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd9m$11of$1 digitalmars.com...
 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be
 easy enough to do. Probably something like:

 {
     return reduce!ordinaryMax(range);
     // Or
     return reduce!"a>b?a:b"(range);
 }


alias reduce!"a>b?a:b" max; God, I love D :)

max = reduce> FSM, I love<funfunfun>. :)

If there's any language allowing defining a max like this, it has implemented reduce (a.k.a. fold) wrongly.
Jun 08 2010
parent Justin Johansson <no spam.com> writes:
retard wrote:
 Tue, 08 Jun 2010 19:43:26 +0800, KennyTM~ wrote:
 
 On Jun 8, 10 15:55, retard wrote:
 Mon, 07 Jun 2010 18:16:15 -0400, Nick Sabalausky wrote:

 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd9m$11of$1 digitalmars.com...
 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be
 easy enough to do. Probably something like:

 {
     return reduce!ordinaryMax(range);
     // Or
     return reduce!"a>b?a:b"(range);
 }


alias reduce!"a>b?a:b" max; God, I love D :)

FSM, I love<funfunfun>. :)

implemented reduce (a.k.a. fold) wrongly.

Right, I should not have used the symbol >, but last post was right after I woke up. Let's say it depends on the definition of > :)

Hey retard, you are a legend.
Jun 09 2010
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/07/2010 05:16 PM, Nick Sabalausky wrote:
 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd9m$11of$1 digitalmars.com...
 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be easy
 enough to do. Probably something like:

ElementType!T max(T range) // Corrected
 {
     return reduce!ordinaryMax(range);
     // Or
     return reduce!"a>b?a:b"(range);
 }


Or: alias reduce!"a>b?a:b" max; God, I love D :)

This is kind of funny. This works because reduce is defined as follows: template reduce(alias fun) { alias Reduce!(fun).reduce reduce; } I did that to work around some old compiler bugs that have been since fixed. I'd initially intended to define reduce like this: Unqual!E reduce(alias fun, E, R)(E seed, R r) { ... } but that wouldn't have allowed Nick's alias, which is quite useful. So it looks like we have a cool idiom. Andrei
Jun 08 2010
parent "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:huld21$15sj$1 digitalmars.com...
 On 06/07/2010 05:16 PM, Nick Sabalausky wrote:
 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd9m$11of$1 digitalmars.com...
 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be easy
 enough to do. Probably something like:

ElementType!T max(T range) // Corrected
 {
     return reduce!ordinaryMax(range);
     // Or
     return reduce!"a>b?a:b"(range);
 }


Or: alias reduce!"a>b?a:b" max; God, I love D :)

This is kind of funny. This works because reduce is defined as follows: template reduce(alias fun) { alias Reduce!(fun).reduce reduce; } I did that to work around some old compiler bugs that have been since fixed. I'd initially intended to define reduce like this: Unqual!E reduce(alias fun, E, R)(E seed, R r) { ... } but that wouldn't have allowed Nick's alias, which is quite useful. So it looks like we have a cool idiom.

Template currying ;) Maybe not as flexible as typical currying, but still. Curry...dang, now I'm hungry... Also, what's Unqual?
Jun 08 2010
prev sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Andrei Alexandrescu wrote:
 On 06/07/2010 12:57 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Do this in any dynamic language ->  FAIL because looping is so slow t=



 die of old age before it executes.  Besides, who wants to do computat=



 intensive, multithreaded work in a dynamic language?

In python: max (map (max, args)) should have reasonable performances and is *much* more elegant...

I very much doubt that. =20

more elegant? Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 07 2010
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/07/2010 04:35 PM, "J茅r么me M. Berger" wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 12:57 PM, "J茅r么me M. Berger" wrote:
 Do this in any dynamic language ->   FAIL because looping is so slow that you
might
 die of old age before it executes.  Besides, who wants to do computationally
 intensive, multithreaded work in a dynamic language?

In python: max (map (max, args)) should have reasonable performances and is *much* more elegant...

I very much doubt that.

more elegant?

That it has reasonable performance. Then, there are a number of things that can't be compared such as figuring out the tightest static types, something that Python doesn't worry about (at the expense of precision and performance). I see such examples as simple illustrations "look, if you give up X, you gain Y!" - just coming without mentioning X. Andrei
Jun 07 2010
parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Andrei Alexandrescu wrote:
 On 06/07/2010 04:35 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 12:57 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Do this in any dynamic language ->   FAIL because looping is so
 slow that you might
 die of old age before it executes.  Besides, who wants to do
 computationally
 intensive, multithreaded work in a dynamic language?

In python: max (map (max, args)) should have reasonable performances and is *much* more elegant...

I very much doubt that.



 more elegant?

That it has reasonable performance. Then, there are a number of things that can't be compared such as figuring out the tightest static types, something that Python doesn't worry about (at the expense of precision and performance). =20

 I see such examples as simple illustrations "look, if you give up X, yo=

 gain Y!" - just coming without mentioning X.
=20

down to is: "look if you do this the D way in a dynamic language it'll be dead slow" - just coming without mentioning that the D way isn't the right way in those languages... Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 08 2010
next sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

J=C3=A9r=C3=B4me M. Berger wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 04:35 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 12:57 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Do this in any dynamic language ->   FAIL because looping is so
 slow that you might
 die of old age before it executes.  Besides, who wants to do
 computationally
 intensive, multithreaded work in a dynamic language?

performances and is *much* more elegant...





 more elegant?



 that can't be compared such as figuring out the tightest static types,=


 something that Python doesn't worry about (at the expense of precision=


 and performance).

=20
 I see such examples as simple illustrations "look, if you give up X, y=


 gain Y!" - just coming without mentioning X.

down to is: "look if you do this the D way in a dynamic language it'll be dead slow" - just coming without mentioning that the D way isn't the right way in those languages... =20

spreading FUD about other languages is not the right way to promote D... Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 08 2010
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/08/2010 01:29 PM, "J茅r么me M. Berger" wrote:
 PS: I should perhaps mention that I like D. I just think that
 spreading FUD about other languages is not the right way to promote D...

Hope I didn't do that. Andrei
Jun 08 2010
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/08/2010 01:27 PM, "J茅r么me M. Berger" wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 04:35 PM, "J茅r么me M. Berger" wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 12:57 PM, "J茅r么me M. Berger" wrote:
 Do this in any dynamic language ->    FAIL because looping is so
 slow that you might
 die of old age before it executes.  Besides, who wants to do
 computationally
 intensive, multithreaded work in a dynamic language?

In python: max (map (max, args)) should have reasonable performances and is *much* more elegant...

I very much doubt that.

more elegant?

That it has reasonable performance. Then, there are a number of things that can't be compared such as figuring out the tightest static types, something that Python doesn't worry about (at the expense of precision and performance).


Within 15% of hand-optimized code specialized for the types at hand. Andrei
Jun 08 2010
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J茅r么me M. Berger" wrote:
     Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). General rules for performance improvements: 1. nobody notices a 10% improvement 2. users will start noticing speedups when they exceed 2x 3. a 10x speedup is a game changer
Jun 08 2010
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/08/2010 04:05 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J茅r么me M. Berger" wrote:
 Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). General rules for performance improvements: 1. nobody notices a 10% improvement 2. users will start noticing speedups when they exceed 2x 3. a 10x speedup is a game changer

max of n elements is O(n). Andrei
Jun 08 2010
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/08/2010 04:53 PM, Simen kjaeraas wrote:
 Simen kjaeraas <simen.kjaras gmail.com> wrote:

 Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote

 max of n elements is O(n).

T max( T )( T[] values ) { T result = values[0]; foreach ( i, e; values[1..$] ) { if ( max( values[i+1..$] ) > result ) { result = max( values[i+1..$] ); } } return result; }

Better: T max( T )( T[] values ) { if ( values.length == 1 ) { return values[0]; } else { return max( values[0..values.length/2] ) > max( values[values.length/2..$] ) ? max( values[0..values.length/2] ) : max( values[values.length/2..$] ); } }

I'm not sure I understand the point. Could you please elaborate? Andrei
Jun 08 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:humfgd$1l7$2 digitalmars.com...
 On 06/08/2010 04:53 PM, Simen kjaeraas wrote:
 Simen kjaeraas <simen.kjaras gmail.com> wrote:

 Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote

 max of n elements is O(n).

T max( T )( T[] values ) { T result = values[0]; foreach ( i, e; values[1..$] ) { if ( max( values[i+1..$] ) > result ) { result = max( values[i+1..$] ); } } return result; }

Better: T max( T )( T[] values ) { if ( values.length == 1 ) { return values[0]; } else { return max( values[0..values.length/2] ) > max( values[values.length/2..$] ) ? max( values[0..values.length/2] ) : max( values[values.length/2..$] ); } }

I'm not sure I understand the point. Could you please elaborate?

He's being a smart-ass and making implementations of max() that are worse than O(n) :) Hee hee. Obfuscation is fun :)
Jun 08 2010
parent "Nick Sabalausky" <a a.a> writes:
"Simen kjaeraas" <simen.kjaras gmail.com> wrote in message 
news:op.vd05x514vxi10f biotronic-pc.lan...
  ...I was apparently too drunk to write bad code.

That's officially my favorite sentence of the day :)
Jun 09 2010
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"retard" <re tard.com.invalid> wrote in message 
news:hun6ok$13s5$1 digitalmars.com...
 Tue, 08 Jun 2010 16:14:51 -0500, Andrei Alexandrescu wrote:

 On 06/08/2010 04:05 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J閞鬽e M. Berger" wrote:
 Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). General rules for performance improvements: 1. nobody notices a 10% improvement 2. users will start noticing speedups when they exceed 2x 3. a 10x speedup is a game changer

max of n elements is O(n).

This probably means that D 2 won't be very efficient on multicore until the authors learn some basic parallel programming skills. Now where did you get your PhD - I'm collecting a list of toy universities people should avoid.

You used to have meaningful things to say. Now you're just trolling.
Jun 08 2010
next sibling parent "Nick Sabalausky" <a a.a> writes:
"retard" <re tard.com.invalid> wrote in message 
news:hunc9t$1c9e$1 digitalmars.com...
 Wed, 09 Jun 2010 01:13:43 -0400, Nick Sabalausky wrote:

 "retard" <re tard.com.invalid> wrote in message
 news:hun6ok$13s5$1 digitalmars.com...
 Tue, 08 Jun 2010 16:14:51 -0500, Andrei Alexandrescu wrote:

 On 06/08/2010 04:05 PM, Walter Bright wrote:

 max of n elements is O(n).

This probably means that D 2 won't be very efficient on multicore until the authors learn some basic parallel programming skills. Now where did you get your PhD - I'm collecting a list of toy universities people should avoid.

You used to have meaningful things to say. Now you're just trolling.

Max of n unordered elements can be solved in O(log log n) time assuming you have enough cores and constant time memory access. Happy now?

Yes, actually :)
Jun 08 2010
prev sibling next sibling parent dsimcha <dsimcha yahoo.com> writes:
== Quote from retard (re tard.com.invalid)'s article
 Wed, 09 Jun 2010 01:13:43 -0400, Nick Sabalausky wrote:
 "retard" <re tard.com.invalid> wrote in message
 news:hun6ok$13s5$1 digitalmars.com...
 Tue, 08 Jun 2010 16:14:51 -0500, Andrei Alexandrescu wrote:

 On 06/08/2010 04:05 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J茅r么me M. Berger" wrote:
 Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). General rules for performance improvements: 1. nobody notices a 10% improvement 2. users will start noticing speedups when they exceed 2x 3. a 10x speedup is a game changer

max of n elements is O(n).

This probably means that D 2 won't be very efficient on multicore until the authors learn some basic parallel programming skills. Now where did you get your PhD - I'm collecting a list of toy universities people should avoid.

You used to have meaningful things to say. Now you're just trolling.

you have enough cores and constant time memory access. Happy now?

Technically true, but when's the last time you needed to find the max of n unordered elements, where n was large enough to justify the overhead of using even 2 threads? Even if you use some kind of pool, there's still the synchronization overhead.
Jun 09 2010
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/09/2010 01:28 AM, retard wrote:
 Wed, 09 Jun 2010 01:13:43 -0400, Nick Sabalausky wrote:

 "retard"<re tard.com.invalid>  wrote in message
 news:hun6ok$13s5$1 digitalmars.com...
 Tue, 08 Jun 2010 16:14:51 -0500, Andrei Alexandrescu wrote:

 On 06/08/2010 04:05 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J茅r么me M. Berger" wrote:
 Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). General rules for performance improvements: 1. nobody notices a 10% improvement 2. users will start noticing speedups when they exceed 2x 3. a 10x speedup is a game changer

max of n elements is O(n).

This probably means that D 2 won't be very efficient on multicore until the authors learn some basic parallel programming skills. Now where did you get your PhD - I'm collecting a list of toy universities people should avoid.

You used to have meaningful things to say. Now you're just trolling.

Max of n unordered elements can be solved in O(log log n) time assuming you have enough cores and constant time memory access. Happy now?

When calculating the complexity of an operation you don't consider cores in unlimited supply; it's a constant. Complexity being calculated in terms of the number of inputs, max of n elements is O(n) because you need to look at each element at least once. Cores being a constant k, you can then consider that max can be distributed such that each core looks at n/k elements. What's left is k intermediate results, which can be further processed in log(k) time (see below); since we consider k a constant, this approach could claim a net k-fold speedup. If available cores are proportional to n (an unusual assumption), you first compare pairs of the n elements with n/2 cores, then n/4 comparisons against pairs of the remaining elements etc. Each step halves the number of candidates so the complexity is O(log n). I'd be curious to find out how that can be reduced to O(log log n). Finally, for small values of n, you could consider the number of cores sufficiently large, but, as was pointed out, using threads for max is actually impractical, so superscalar execution may be a better venue. Practically this means exploiting ILP by reducing data dependencies between intermediate results. I suggest you take a look at a thread entitled "challenge: implement the max function" that I started on 01/21/2007. That thread discusses ILP issues, and continues with the thread "challenge #2: implement the varargs_reduce metafunction". Allow me to quote from my own post on 01/23/2007: ================== That's a good point, and goes right to the core of my solution, which (similarly to Bruno Medeiros') arranges operations in an optimal way for superscalar evaluation, e.g. max(a, b, c, d) is expanded not to: max2(max2(max2(a, b), c), d) but instead to: max2(max2(a, b), max2(c, d)) The number of operations is the same but in the latter case there is logaritmically less dependency between partial results. When max2 expands into a primitive comparison, the code is easy prey for a superscalar machine to execute in parallel. This won't count in a great deal of real code, but the fact that this will go in the standard library warrants the thought. Besides, the fact that the language makes it so easy, we can actually think of such subtlety, is very encouraging. ================== The messages that follow further discuss how associative reduce should be ordered to take advantage of superscalar execution. Andrei
Jun 09 2010
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
retard wrote:
 First, divide the problem into log(log(n)) blocks and solve them 
 sequentially, the complexity is O(log log n), because the problem size is 
 log(log(n)) and the sequential algorithm works in O(n). Then, use a 
 divide and conquer algorithm for the n/log(log(n)) maximums obtained from 
 the blocks. With the correct algorithm this stage is also O(log log n), 
 thus the overall complexity is O(log log n). And yes, it assumes you have 
 n/log(log(n)) cores.

What is the correct algorithm for the second stage? Do you have a reference at hand? Andrei
Jun 11 2010
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
retard wrote:
 Fri, 11 Jun 2010 08:37:31 -0700, Andrei Alexandrescu wrote:
 
 retard wrote:
 First, divide the problem into log(log(n)) blocks and solve them
 sequentially, the complexity is O(log log n), because the problem size
 is log(log(n)) and the sequential algorithm works in O(n). Then, use a
 divide and conquer algorithm for the n/log(log(n)) maximums obtained
 from the blocks. With the correct algorithm this stage is also O(log
 log n), thus the overall complexity is O(log log n). And yes, it
 assumes you have n/log(log(n)) cores.

reference at hand? Andrei

Unfortunately I can't remember. It was probably explained in Jaja's book, which I skimmed through when there was the last parallel programming course 7-8 years ago - I only have some notes left.

That's right. I'm now glad I followed this through; I learned a couple of things. www.cs.berkeley.edu/~satishr/cs273.03/scribe9.ps Focusing on posting more content and fewer of those bizarre outbursts would make everyone on this group happier - primarily yourself. Andrei
Jun 12 2010
prev sibling parent =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
     Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). =20

Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 09 2010
prev sibling parent =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 04:35 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Andrei Alexandrescu wrote:
 On 06/07/2010 12:57 PM, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Do this in any dynamic language ->    FAIL because looping is so
 slow that you might
 die of old age before it executes.  Besides, who wants to do
 computationally
 intensive, multithreaded work in a dynamic language?

In python: max (map (max, args)) should have reasonable performances and is *much* more elegant...

I very much doubt that.

it is more elegant?

That it has reasonable performance. Then, there are a number of thing=



 that can't be compared such as figuring out the tightest static types=



 something that Python doesn't worry about (at the expense of precisio=



 and performance).


Within 15% of hand-optimized code specialized for the types at hand. =20

Jerome PS: I should maybe point out that I also do quite a lot of Verilog development. Therefore I can hand optimize specialized code a lot better than anything you can do on a standard CPU... --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 09 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Mon, 07 Jun 2010 14:06:24 -0400, Nick Sabalausky wrote:

 ""J茅r么me M. Berger"" <jeberger free.fr> wrote in message
 news:hujboe$tp2$1 digitalmars.com...
Nick Sabalausky wrote:
 I actually find that funny. Something in Java that isn't an Object? I
 remember "Everything's an object!" being paraded around as a selling
 point.

the language "designers". There are several such design decisions in Java...

Yea, that's a good example of why I've grown a distaste towards hard-and-fast religious design strategies. The designer inevitably comes across cases where it just doesn't work particularly well, and then they're forced to either stay true to their misguided principles by accepting an awkward problematic design, or contradict their alleged principles and go with a better design. And when they do the latter, that runs the risk of causing problems in other areas that had been relying on the old principle being rigidly followed.

Part of the "religious" feel of Java comes from the fact that it runs on a VM. The safe memory model imposes some restrictions as you might have noticed in SafeD. The 'everything is an Object' idea is a bit broken, performance-wise. That's why C# added reified types. The reason they added primitive types has a rationale behind it. The decision made the VM a useful tool for real enterprise applications.
Jun 07 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Mon, 07 Jun 2010 18:16:15 -0400, Nick Sabalausky wrote:

 "Nick Sabalausky" <a a.a> wrote in message
 news:hujd9m$11of$1 digitalmars.com...
 "Nick Sabalausky" <a a.a> wrote in message
 news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be
 easy enough to do. Probably something like:

 {
    return reduce!ordinaryMax(range);
    // Or
    return reduce!"a>b?a:b"(range);
 }


alias reduce!"a>b?a:b" max; God, I love D :)

max = reduce > FSM, I love <funfunfun>. :)
Jun 08 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Tue, 08 Jun 2010 19:43:26 +0800, KennyTM~ wrote:

 On Jun 8, 10 15:55, retard wrote:
 Mon, 07 Jun 2010 18:16:15 -0400, Nick Sabalausky wrote:

 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd9m$11of$1 digitalmars.com...
 "Nick Sabalausky"<a a.a>  wrote in message
 news:hujd6a$11e8$1 digitalmars.com...
 Assuming, of course, a 'max' that works on a range, which would be
 easy enough to do. Probably something like:

 {
     return reduce!ordinaryMax(range);
     // Or
     return reduce!"a>b?a:b"(range);
 }


alias reduce!"a>b?a:b" max; God, I love D :)

max = reduce> FSM, I love<funfunfun>. :)

If there's any language allowing defining a max like this, it has implemented reduce (a.k.a. fold) wrongly.

Right, I should not have used the symbol >, but last post was right after I woke up. Let's say it depends on the definition of > :)
Jun 08 2010
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--0015174bdd3a45c96804888a36ce
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Jun 8, 2010 at 14:28, Andrei Alexandrescu <
SeeWebsiteForEmail erdani.org> wrote:
 This is kind of funny. This works because reduce is defined as follows:

 template reduce(alias fun)
 {
    alias Reduce!(fun).reduce reduce;
 }

 I did that to work around some old compiler bugs that have been since
 fixed. I'd initially intended to define reduce like this:

 Unqual!E reduce(alias fun, E, R)(E seed, R r) { ... }

 but that wouldn't have allowed Nick's alias, which is quite useful. So it
 looks like we have a cool idiom.

Currying in general is always handy to have. The possibility to say alias map!fun funMapper; would be cool also. If possible, having this in Phobos would be quite nice. Bu then, I'm one of those persons that'd like to have alias take(3) takeThree; // will then work on any range. Instead of take(range, 3). If find the former to be much more generic. I liked it so much I defined a small template to invert and curry these (R,n) functions. Philippe --0015174bdd3a45c96804888a36ce Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Tue, Jun 8, 2010 at 14:28, Andrei Alexandresc= u <span dir=3D"ltr">&lt;<a href=3D"mailto:SeeWebsiteForEmail erdani.org">Se= eWebsiteForEmail erdani.org</a>&gt;</span> wrote:<blockquote class=3D"gmail= _quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:= 1ex;"> This is kind of funny. This works because reduce is defined as follows:<br> <br> template reduce(alias fun)<br> {<br> =A0 =A0alias Reduce!(fun).reduce reduce;<br> }<br> <br> I did that to work around some old compiler bugs that have been since fixed= . I&#39;d initially intended to define reduce like this:<br> <br> Unqual!E reduce(alias fun, E, R)(E seed, R r) { ... }<br> <br> but that wouldn&#39;t have allowed Nick&#39;s alias, which is quite useful.= So it looks like we have a cool idiom.</blockquote><div><br></div><div>Cur= rying in general is always handy to have. The possibility to say=A0</div> <div><br></div><div>alias map!fun funMapper;=A0</div><div><br></div><div>wo= uld be cool also. If possible, having this in Phobos would be quite nice.</= div><div>Bu then, I&#39;m one of those persons that&#39;d like to have=A0</= div> <div><br></div><div>alias take(3) takeThree; // will then work on any range= .</div><div><br></div><div>Instead of take(range, 3). If find the former to= be much more generic.</div><div><br></div><div>I liked it so much I define= d a small template to invert and curry these (R,n) functions.</div> <div><br></div><div>Philippe</div></div> --0015174bdd3a45c96804888a36ce--
Jun 08 2010
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--00151758889661ae9704888a6361
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Jun 8, 2010 at 20:13, Nick Sabalausky <a a.a> wrote:

 Template currying ;) Maybe not as flexible as typical currying, but still.

I recenly achieved getting partially there. At least, given foo(A,B,C)(n args list) {...} curry!foo will correctly create n 1-arg templated function inside one another and deliver the result at the end. But it does not verify the compatibility of arguments while filling the arguments :( Given foo(A,B,C)(A a, Tuple!(B,A) b, C[A] c) curry!foo will accept any A a, but then should only accept b's of the correct type: Tuple!(B,A), for some B and the already defined A, and the same for c. I'm making sense there? I more or less see how to get there, but can't get motivated to do this :-)
 Also, what's Unqual?

Gets rid of any const/immutable qualifiers. Philipe --00151758889661ae9704888a6361 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote"><br></div><div class=3D"gmail_quote"><br></div><= div class=3D"gmail_quote">On Tue, Jun 8, 2010 at 20:13, Nick Sabalausky <sp= an dir=3D"ltr">&lt;a a.a&gt;</span> wrote:<br><blockquote class=3D"gmail_qu= ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex= ;"> <div class=3D"im"><br></div>Template currying ;) Maybe not as flexible as t= ypical currying, but still.<br></blockquote><div><br></div><div>I recenly a= chieved getting partially there. At least, given</div><div><br></div><div> foo(A,B,C)(n args list) {...}</div><div><br></div><div>curry!foo will corre= ctly create n 1-arg templated function inside one another and deliver the r= esult at the end.</div><div>But it does not verify the compatibility of arg= uments while filling the arguments :(</div> <div><br></div><div>Given=A0</div><div><br></div><div>foo(A,B,C)(A a, Tuple= !(B,A) b, C[A] c)=A0</div><div><br></div><div>curry!foo will accept any A a= , but then should only accept b&#39;s of the correct type: Tuple!(B,A), for= some B and the already defined A, and the same for c. I&#39;m making sense= there?</div> <div><br></div><div>I more or less see how to get there, but can&#39;t get = motivated to do this :-)</div><div><br></div><div>=A0</div><blockquote clas= s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad= ding-left:1ex;"> Also, what&#39;s Unqual?<br></blockquote><div><br></div><div>Gets rid of an= y const/immutable qualifiers.</div><div><br></div><div>Philipe=A0</div></di= v><br> --00151758889661ae9704888a6361--
Jun 08 2010
prev sibling next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote

 max of n elements is O(n).

T max( T )( T[] values ) { T result = values[0]; foreach ( i, e; values[1..$] ) { if ( max( values[i+1..$] ) > result ) { result = max( values[i+1..$] ); } } return result; } -- Simen
Jun 08 2010
prev sibling next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Simen kjaeraas <simen.kjaras gmail.com> wrote:

 Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote

 max of n elements is O(n).

T max( T )( T[] values ) { T result = values[0]; foreach ( i, e; values[1..$] ) { if ( max( values[i+1..$] ) > result ) { result = max( values[i+1..$] ); } } return result; }

Better: T max( T )( T[] values ) { if ( values.length == 1 ) { return values[0]; } else { return max( values[0..values.length/2] ) > max( values[values.length/2..$] ) ? max( values[0..values.length/2] ) : max( values[values.length/2..$] ); } } -- Simen
Jun 08 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Tue, 08 Jun 2010 16:14:51 -0500, Andrei Alexandrescu wrote:

 On 06/08/2010 04:05 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J茅r么me M. Berger" wrote:
 Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). General rules for performance improvements: 1. nobody notices a 10% improvement 2. users will start noticing speedups when they exceed 2x 3. a 10x speedup is a game changer

max of n elements is O(n).

This probably means that D 2 won't be very efficient on multicore until the authors learn some basic parallel programming skills. Now where did you get your PhD - I'm collecting a list of toy universities people should avoid.
Jun 08 2010
prev sibling next sibling parent "Yao G." <nospamyao gmail.com> writes:
  :D Wow. This troll is getting increasingly desperate. Now it resorts t=
o  =

straw man.

On Tue, 08 Jun 2010 23:53:41 -0500, retard <re tard.com.invalid> wrote:

 Tue, 08 Jun 2010 16:14:51 -0500, Andrei Alexandrescu wrote:

 On 06/08/2010 04:05 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J=E9r=F4me M. Berger" wrote:
 Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand=




 I would have said O(n) or O(log n), as opposed to, say, O(n*n).

 General rules for performance improvements:

 1. nobody notices a 10% improvement

 2. users will start noticing speedups when they exceed 2x

 3. a 10x speedup is a game changer

max of n elements is O(n).

This probably means that D 2 won't be very efficient on multicore unti=

 the authors learn some basic parallel programming skills. Now where di=

 you get your PhD - I'm collecting a list of toy universities people
 should avoid.

-- = Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jun 08 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Wed, 09 Jun 2010 01:13:43 -0400, Nick Sabalausky wrote:

 "retard" <re tard.com.invalid> wrote in message
 news:hun6ok$13s5$1 digitalmars.com...
 Tue, 08 Jun 2010 16:14:51 -0500, Andrei Alexandrescu wrote:

 On 06/08/2010 04:05 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 06/08/2010 01:27 PM, "J茅r么me M. Berger" wrote:
 Please define "reasonable performance"...

Within 15% of hand-optimized code specialized for the types at hand.

I would have said O(n) or O(log n), as opposed to, say, O(n*n). General rules for performance improvements: 1. nobody notices a 10% improvement 2. users will start noticing speedups when they exceed 2x 3. a 10x speedup is a game changer

max of n elements is O(n).

This probably means that D 2 won't be very efficient on multicore until the authors learn some basic parallel programming skills. Now where did you get your PhD - I'm collecting a list of toy universities people should avoid.

You used to have meaningful things to say. Now you're just trolling.

Max of n unordered elements can be solved in O(log log n) time assuming you have enough cores and constant time memory access. Happy now?
Jun 08 2010
prev sibling next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Nick Sabalausky <a a.a> wrote:

 He's being a smart-ass and making implementations of max() that are worse
 than O(n) :)

Well, I tried. Second try I was apparently too drunk to write bad code. -- Simen
Jun 09 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Wed, 09 Jun 2010 09:37:51 -0500, Andrei Alexandrescu wrote:

 On 06/09/2010 01:28 AM, retard wrote:
 Max of n unordered elements can be solved in O(log log n) time assuming
 you have enough cores and constant time memory access. Happy now?

When calculating the complexity of an operation you don't consider cores in unlimited supply; it's a constant. Complexity being calculated in terms of the number of inputs, max of n elements is O(n) because you need to look at each element at least once. Cores being a constant k, you can then consider that max can be distributed such that each core looks at n/k elements. What's left is k intermediate results, which can be further processed in log(k) time (see below); since we consider k a constant, this approach could claim a net k-fold speedup.

With this logic, all parallel algorithms have the same time complexity as their sequential versions.
 If available cores are proportional to n (an unusual assumption), you
 first compare pairs of the n elements with n/2 cores, then n/4
 comparisons against pairs of the remaining elements etc. Each step
 halves the number of candidates so the complexity is O(log n). I'd be
 curious to find out how that can be reduced to O(log log n).

First, divide the problem into log(log(n)) blocks and solve them sequentially, the complexity is O(log log n), because the problem size is log(log(n)) and the sequential algorithm works in O(n). Then, use a divide and conquer algorithm for the n/log(log(n)) maximums obtained from the blocks. With the correct algorithm this stage is also O(log log n), thus the overall complexity is O(log log n). And yes, it assumes you have n/log(log(n)) cores.
 Finally, for small values of n, you could consider the number of cores
 sufficiently large, but, as was pointed out, using threads for max is
 actually impractical, so superscalar execution may be a better venue.
 Practically this means exploiting ILP by reducing data dependencies
 between intermediate results. I suggest you take a look at a thread
 entitled "challenge: implement the max function" that I started on
 01/21/2007. That thread discusses ILP issues, and continues with the
 thread "challenge #2: implement the varargs_reduce metafunction".

I believe this is true in practice. I only mentioned the time complexity of the parallel version, I didn't make any claims about its real world performance. If the problem is small enough, I'd use Python instead.
Jun 11 2010
prev sibling parent retard <re tard.com.invalid> writes:
Fri, 11 Jun 2010 08:37:31 -0700, Andrei Alexandrescu wrote:

 retard wrote:
 First, divide the problem into log(log(n)) blocks and solve them
 sequentially, the complexity is O(log log n), because the problem size
 is log(log(n)) and the sequential algorithm works in O(n). Then, use a
 divide and conquer algorithm for the n/log(log(n)) maximums obtained
 from the blocks. With the correct algorithm this stage is also O(log
 log n), thus the overall complexity is O(log log n). And yes, it
 assumes you have n/log(log(n)) cores.

What is the correct algorithm for the second stage? Do you have a reference at hand? Andrei

Unfortunately I can't remember. It was probably explained in Jaja's book, which I skimmed through when there was the last parallel programming course 7-8 years ago - I only have some notes left.
Jun 11 2010
prev sibling next sibling parent Leandro Lucarella <llucax gmail.com> writes:
Walter Bright, el  7 de junio a las 11:24 me escribiste:
 Nick Sabalausky wrote:
Yea, that's a good example of why I've grown a distaste towards
hard-and-fast religious design strategies. The designer inevitably
comes across cases where it just doesn't work particularly well,
and then they're forced to either stay true to their misguided
principles by accepting an awkward problematic design, or
contradict their alleged principles and go with a better design.
And when they do the latter, that runs the risk of causing
problems in other areas that had been relying on the old principle
being rigidly followed.

D has design principles, but those principles are often contradictory. I don't see a good reason to follow a design principle out of principle if it destroys the utility of the language. For example, consider: version (unittest) 'unittest' is a keyword, not an identifier. Making this work requires a special case in the grammar. But the alternatives, version (Unittest) version (unit_test) version (unittests) etc. are all much worse than simply violating a principle and putting the special case in.

Please, document this! http://d.puremagic.com/issues/show_bug.cgi?id=4230 -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- 驴Qu茅 ser谩 lo que hace que una br煤jula siempre marque el norte? - Ser aguja, nada m谩s, y cumplir su misi贸n. -- Ricardo Vaporeso
Jun 07 2010
prev sibling parent Leandro Lucarella <llucax gmail.com> writes:
Walter Bright, el  7 de junio a las 14:42 me escribiste:
 Leandro Lucarella wrote:
Please, document this!

http://d.puremagic.com/issues/show_bug.cgi?id=4230

Done.

Thanks =) -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Es mejor probar el sabor de sapo y darse cuenta que es feo, antes que no hacerlo y creer que es una gran gomita de pera. -- Dr Ricardo Vaporesso, Malta 1951
Jun 07 2010