Re: D component programming is a joke (Was: Re: Component programming)

2013-08-12 Thread Jacob Carlborg
On 2013-08-04 06:53, Jonathan M Davis wrote: std.datetime has something like that internally for some of what it does (in particular, toSimpleString, which I wouldn't even put in there now if I could go back), but we explicitly didn't make anything like that public, because it's English-specific

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-06 Thread H. S. Teoh
On Tue, Aug 06, 2013 at 06:20:23PM +0200, bearophile wrote: > H. S. Teoh: > > >It looks like I may have to sort out some issues with compiler bugs > >before officially posting this article, though, since the code > >apparently fails to compile with many versions of DMD. :-( > > If not already pre

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-06 Thread bearophile
H. S. Teoh: It looks like I may have to sort out some issues with compiler bugs before officially posting this article, though, since the code apparently fails to compile with many versions of DMD. :-( If not already present, I suggest you to put a reduced version of the problems you have fo

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 02:11:32PM +0200, Dejan Lekic wrote: [...] > Good work! I've read the article yesterday. Very educational! Thanks! I did actually make a major revision to the article last night based on some feedback I got; I rewrote much of the first part of it, so if you're interested y

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-05 Thread Dejan Lekic
On Friday, 2 August 2013 at 05:26:05 UTC, H. S. Teoh wrote: On Thu, Aug 01, 2013 at 10:34:24AM -0700, Walter Bright wrote: On 8/1/2013 2:23 AM, John Colvin wrote: >On Thursday, 1 August 2013 at 00:47:43 UTC, H. S. Teoh wrote: >Add in some code examples and that could make a nice article. Yes, p

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread H. S. Teoh
On Sun, Aug 04, 2013 at 05:02:05AM +0200, bearophile wrote: [...] > A bit improved chunkBy could go in Phobos. Yeah I'll look into that sometime. It'll definitely be a useful thing to have, I think. > --- > > >For our purposes, though, we can't just do this in a loop, because > >it

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread Jonathan M Davis
On Sunday, August 04, 2013 06:20:57 Andre Artus wrote: > > Bearophile: > > If not already present this array should go in std.datetime or > > > > core.time: > > static immutable string[] monthNames = [ > > > > "January", "February", "March", "April", "May", "June", > > "Ju

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread Andre Artus
Bearophile: If not already present this array should go in std.datetime or core.time: static immutable string[] monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; It should probab

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread bearophile
H. S. Teoh: OK, here's a draft of the article: http://wiki.dlang.org/User:Quickfur/Component_programming_with_ranges Most of the code below is not tested. So my suggestions may contain bugs or mistakes. A bit improved chunkBy could go in Phobos. --- For our purposes

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread H. S. Teoh
On Fri, Aug 02, 2013 at 03:02:24PM -0700, H. S. Teoh wrote: > On Thu, Aug 01, 2013 at 10:49:00PM -0700, Walter Bright wrote: [...] > > I think this is awesome, and this + your previous post are > > sufficient to create a great article! > > OK, here's a draft of the article: > > http://wiki.

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread Jonathan M Davis
On Saturday, August 03, 2013 01:27:20 Timon Gehr wrote: > Also, you may want to replace some of the manually implemented ranges > where this makes sense. > > Eg, datesInYear can be expressed more to the point as: > > > auto datesInYear(int year){ > return Date(year,1,1).recurrence!((a,n)=>a

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread H. S. Teoh
On Sat, Aug 03, 2013 at 04:12:58AM +0200, Timon Gehr wrote: > On 08/03/2013 01:05 AM, H. S. Teoh wrote: > > > >Actually, I just pulled git HEAD again, and it's still working fine. > >Maybe you just need to update your repo? > >... > > I think it pulled in the wrong version of druntime. OK, I've w

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread Walter Bright
On 8/3/2013 6:46 AM, David Nadlinger wrote: In this example, no, as all involved ranges are evaluated lazily. (I see your general point, though.) The rules for ranges do not specify if they are done eagerly, lazily, or in parallel. Meaning, of course, that a library writer could provide all th

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread H. S. Teoh
On Fri, Aug 02, 2013 at 06:07:02PM -0700, Andrei Alexandrescu wrote: > On 2013-08-02 23:27:20 +, Timon Gehr said: > >Also, you may want to replace some of the manually implemented > >ranges where this makes sense. > > > >Eg, datesInYear can be expressed more to the point as: > > > > > >auto dat

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread Andre Artus
On Saturday, 3 August 2013 at 13:46:38 UTC, David Nadlinger wrote: On Saturday, 3 August 2013 at 13:35:56 UTC, Andre Artus wrote: import std.stdio; import std.algorithm; void main() { auto values = [ 1, 2, 3, 4, 5 ]; writeln(values .map!(a => a * 10) .map!(a => a / 3) .filter!(a => !(

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread David Nadlinger
On Saturday, 3 August 2013 at 13:35:56 UTC, Andre Artus wrote: import std.stdio; import std.algorithm; void main() { auto values = [ 1, 2, 3, 4, 5 ]; writeln(values .map!(a => a * 10) .map!(a => a / 3) .filter!(a => !(a % 2))); } As stated this implies 3 separate traversals of th

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-03 Thread Andre Artus
On Thursday, 1 August 2013 at 22:45:10 UTC, bearophile wrote: Walter Bright: But consider that optimizers are built to optimize typical code patterns. Component programming is fairly non-existent in C and C++, and is new in D. Hence, optimizers are not set up to deal with those patterns (yet)

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread Timon Gehr
On 08/03/2013 01:05 AM, H. S. Teoh wrote: Actually, I just pulled git HEAD again, and it's still working fine. Maybe you just need to update your repo? ... I think it pulled in the wrong version of druntime.

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread Andrei Alexandrescu
On 2013-08-02 23:27:20 +, Timon Gehr said: Also, you may want to replace some of the manually implemented ranges where this makes sense. Eg, datesInYear can be expressed more to the point as: auto datesInYear(int year){ return Date(year,1,1).recurrence!((a,n)=>a[n-1]+1.dur!"days")

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread Timon Gehr
On 08/03/2013 12:02 AM, H. S. Teoh wrote: On Thu, Aug 01, 2013 at 10:49:00PM -0700, Walter Bright wrote: On 8/1/2013 10:24 PM, H. S. Teoh wrote: Once this last bit worked, though, everything fell into place quickly. After all unittests were passing, no more bugs were found!! The program can pri

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread Walter Bright
On 8/2/2013 3:02 PM, H. S. Teoh wrote: OK, here's a draft of the article: http://wiki.dlang.org/User:Quickfur/Component_programming_with_ranges It looks like I may have to sort out some issues with compiler bugs before officially posting this article, though, since the code apparently f

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread H. S. Teoh
On Fri, Aug 02, 2013 at 03:00:01PM -0700, H. S. Teoh wrote: > On Fri, Aug 02, 2013 at 08:49:30PM +0200, Timon Gehr wrote: [...] > > I get the dreaded forward reference errors with at least DMD 2.060, > > DMD 2.063 and DMD 2.063.2 and the 2.x build on dpaste. > > Can you send me the error messages?

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread H. S. Teoh
On Thu, Aug 01, 2013 at 10:49:00PM -0700, Walter Bright wrote: > On 8/1/2013 10:24 PM, H. S. Teoh wrote: > >Once this last bit worked, though, everything fell into place quickly. > >After all unittests were passing, no more bugs were found!! The program > >can print beautifully laid out calendars w

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread H. S. Teoh
On Fri, Aug 02, 2013 at 08:49:30PM +0200, Timon Gehr wrote: > On 08/02/2013 07:24 AM, H. S. Teoh wrote: > >... > >Anyway. Enough hand-waving in the air. Let the actual code speak for > >itself: > > > > https://github.com/quickfur/dcal/blob/master/dcal.d > >... > > Which version of the compiler

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread Timon Gehr
On 08/02/2013 07:24 AM, H. S. Teoh wrote: ... Anyway. Enough hand-waving in the air. Let the actual code speak for itself: https://github.com/quickfur/dcal/blob/master/dcal.d ... Which version of the compiler are you using? I get the dreaded forward reference errors with at least DMD

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread bearophile
H. S. Teoh: It would be nice to collect these custom ranges and see if there's some common functionality that can be added to Phobos. chunkBy seems OK for Phobos. Bye, bearophile

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread H. S. Teoh
On Fri, Aug 02, 2013 at 04:06:46PM +, Justin Whear wrote: > On Thu, 01 Aug 2013 22:24:32 -0700, H. S. Teoh wrote: > > Now, w.r.t. the roadblocks I alluded to. > > > > When I first started working on the code, my goal was to maximize > > usage of existing Phobos facilities in order to show how

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-02 Thread Justin Whear
On Thu, 01 Aug 2013 22:24:32 -0700, H. S. Teoh wrote: > Now, w.r.t. the roadblocks I alluded to. > > When I first started working on the code, my goal was to maximize usage > of existing Phobos facilities in order to show how many batteries D > already comes with. As it turned out, I could only us

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Walter Bright
On 8/1/2013 10:24 PM, H. S. Teoh wrote: Once this last bit worked, though, everything fell into place quickly. After all unittests were passing, no more bugs were found!! The program can print beautifully laid out calendars with no problems whatsoever. I'm so in love with D right now... If I'd do

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread H. S. Teoh
On Thu, Aug 01, 2013 at 10:34:24AM -0700, Walter Bright wrote: > On 8/1/2013 2:23 AM, John Colvin wrote: > >On Thursday, 1 August 2013 at 00:47:43 UTC, H. S. Teoh wrote: > >Add in some code examples and that could make a nice article. > > Yes, please! Alright, so I decided to prove my point about

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread bearophile
Walter Bright: But consider that optimizers are built to optimize typical code patterns. Component programming is fairly non-existent in C and C++, and is new in D. Hence, optimizers are not set up to deal with those patterns (yet). I agree. GHC also works with a LLVM back-end, so those opt

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Walter Bright
On 8/1/2013 2:35 PM, Brad Anderson wrote: How difficult would it be to make sure stuff like this gets inlined and optimized more thoroughly? I'm very ignorant of compiler internals but it's kind of disheartening that LDC can't inline them well despite being a fairly good optimizing compiler. Is

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Brad Anderson
On Wednesday, 31 July 2013 at 22:23:54 UTC, bearophile wrote: Currently this code inlines nothing (the allocations, the difference and the product): If you write it in component-style (using doubles here): Resident compiler guys, How difficult would it be to make sure stuff like this g

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread bearophile
anonymous observer: ERROR 404 - PAGE NOT FOUND Andrei This one, perhaps? http://www.leafpetersen.com/leaf/publications/ifl2013/haskell-gap.pdf Yes, it's the same, thank you. Another comparison (I have not yet read this): http://www.leafpetersen.com/leaf/publications/hs2013/hrc-paper.pdf

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Walter Bright
On 8/1/2013 2:23 AM, John Colvin wrote: On Thursday, 1 August 2013 at 00:47:43 UTC, H. S. Teoh wrote: Add in some code examples and that could make a nice article. Yes, please!

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread anonymous observer
On Thursday, 1 August 2013 at 16:13:55 UTC, Andrei Alexandrescu wrote: On 7/31/13 6:40 PM, bearophile wrote: According to this article it seems better, but I have no direct experience of it: http://www.leafpetersen.com/leaf/publications/hs2013/haskell-gap.pdf ERROR 404 - PAGE NOT FOUND Andre

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Dejan Lekic
On Thursday, 1 August 2013 at 00:47:43 UTC, H. S. Teoh wrote: On Wed, Jul 31, 2013 at 11:52:35PM +, Justin Whear wrote: On Thu, 01 Aug 2013 00:23:52 +0200, bearophile wrote: > > The situation should be improved for D/dmd/Phobos, otherwise > such D > component programming remains partially

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Andrei Alexandrescu
On 7/31/13 6:40 PM, bearophile wrote: According to this article it seems better, but I have no direct experience of it: http://www.leafpetersen.com/leaf/publications/hs2013/haskell-gap.pdf ERROR 404 - PAGE NOT FOUND Andrei

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Joseph Rushton Wakeling
On 08/01/2013 03:40 AM, bearophile wrote: > Take a look at this thread in D.learn: > > http://forum.dlang.org/thread/mailman.304.1375190212.22075.digitalmars-d-le...@puremagic.com Yea, this was a frustration. :-( It was really nice to be able to write simple, clean, elegant code using D -- it wa

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread John Colvin
On Thursday, 1 August 2013 at 00:47:43 UTC, H. S. Teoh wrote: On Wed, Jul 31, 2013 at 11:52:35PM +, Justin Whear wrote: On Thu, 01 Aug 2013 00:23:52 +0200, bearophile wrote: > > The situation should be improved for D/dmd/Phobos, otherwise > such D > component programming remains partially

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Chris
On Thursday, 1 August 2013 at 00:47:43 UTC, H. S. Teoh wrote: Most non-trivial loops in imperative code have both, which makes them doubly prone to bugs. In the example I gave above, the mismatch between the code structure (a single loop) and the file structure (three sequential sections) ofte

Re: D component programming is a joke (Was: Re: Component programming)

2013-08-01 Thread Dejan Lekic
On Wednesday, 31 July 2013 at 22:23:54 UTC, bearophile wrote: Justin Whear: If anything, component programming is just functional programming + templates and some nice syntactic sugar. And a healthy dose of pure awesome. What D calls "component programming" is very nice and good, but in D i

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread bearophile
Walter Bright: Speed is only one measure of utility. I agree, I program often in Python, and it can be very useful, despite being sometimes not fast at all. But as Haskell folks sometimes say, a modern language should try to allow a high level style of coding while still keeping a "good e

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread Walter Bright
On 7/31/2013 5:46 PM, H. S. Teoh wrote: > [...] Thank you for an excellent and concise summary of what component programming is all about!

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread H. S. Teoh
On Wed, Jul 31, 2013 at 11:52:35PM +, Justin Whear wrote: > On Thu, 01 Aug 2013 00:23:52 +0200, bearophile wrote: > > > > The situation should be improved for D/dmd/Phobos, otherwise such D > > component programming remains partially a dream, or a toy. > > > > Bye, > > bearophile > > I disag

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread Andrei Alexandrescu
On 7/31/13 4:17 PM, bearophile wrote: Walter Bright: Ironically, the component program from the article I wrote: ... is 2x faster than the Haskell version: Benchmarking code written in two different languages is tricky, there are so many sources of mistakes, even if you know well both languag

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread Justin Whear
On Thu, 01 Aug 2013 00:23:52 +0200, bearophile wrote: > > The situation should be improved for D/dmd/Phobos, otherwise such D > component programming remains partially a dream, or a toy. > > Bye, > bearophile I disagree with your "toy" assessment. I've been using this chaining, component style

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread Walter Bright
On 7/31/2013 4:17 PM, bearophile wrote: Walter Bright: Ironically, the component program from the article I wrote: ... is 2x faster than the Haskell version: Benchmarking code written in two different languages is tricky, there are so many sources of mistakes, even if you know well both langu

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread bearophile
Walter Bright: Ironically, the component program from the article I wrote: ... is 2x faster than the Haskell version: Benchmarking code written in two different languages is tricky, there are so many sources of mistakes, even if you know well both languages. But I accept your timing. And I s

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread Ali Çehreli
On 07/31/2013 03:46 PM, Walter Bright wrote: > is 2x faster What do you mean exactly? :p Ali

Re: D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread Walter Bright
On 7/31/2013 3:23 PM, bearophile wrote: The situation should be improved for D/dmd/Phobos, otherwise such D component programming remains partially a dream, or a toy. Ironically, the component program from the article I wrote: void main() { stdin.byLine(KeepTerminator.yes)// 1

D component programming is a joke (Was: Re: Component programming)

2013-07-31 Thread bearophile
Justin Whear: If anything, component programming is just functional programming + templates and some nice syntactic sugar. And a healthy dose of pure awesome. What D calls "component programming" is very nice and good, but in D it's almost a joke. Currently this code inlines nothing (the a