digitalmars.D - Lisp vs. C++ (not off-topic)
- Josh Stern (11/11) Oct 10 2006 This old blog doesn't mention D, but I think it is good and really
- Makaan (8/8) Oct 10 2006 I think the number of lines is over rated. This is a very simple example...
- Josh Stern (25/35) Oct 10 2006 I guess it depends on who is rating and how they do it. The most obviou...
- Walter Bright (5/18) Oct 10 2006 It is a very interesting article for anyone wanting to carefully look at...
- Lionello Lunesu (7/30) Oct 11 2006 It was sooo easy in D! I got it done in 1 hour 15 minutes.. But, my
- Lionello Lunesu (5/5) Oct 11 2006 I give up. I can't figure out why those phone numbers are missing from
- AndBre (6/19) Oct 11 2006 I just looked in the dictionary and "etch" isn't there. Maybe you are
- AndBre (2/7) Oct 11 2006 Sorry I mispelled the word, you are right, it is in the dictionary.
- Walter Bright (1/1) Oct 12 2006 How does the speed stack up with the C++ version?
- Lionello Lunesu (8/10) Oct 13 2006 My version in D seems more straightforward than either C++ version on
- Lionello Lunesu (8/8) Oct 13 2006 While trying to understand the c++ implementation, I found out what the
- Don Clugston (3/13) Oct 13 2006 So the C++ version wasn't merely more complicated and slower than D, it
- Lionello Lunesu (9/22) Oct 13 2006 I would say: yes :)
- Walter Bright (3/8) Oct 13 2006 Could you put together a web page with the results? Or just text, I can
- Lionello Lunesu (2/11) Oct 15 2006 Sure thing!
- Lionello Lunesu (92/94) Oct 19 2006 Here it is!
- Walter Bright (2/8) Oct 19 2006 Cool!
- Walter Bright (12/12) Oct 19 2006 I've taken the liberty of:
- Lionello Lunesu (8/20) Oct 19 2006 Of couse, I'd be honoured! :)
- Walter Bright (3/7) Oct 19 2006 I think it looks fine.
- Chris Miller (4/11) Oct 19 2006 Looks pretty bad to me,
- Walter Bright (3/19) Oct 20 2006 Yowsa! I guess that's the problem with style sheets. They aren't
- Chris Miller (3/21) Oct 20 2006 Opera.
- Walter Bright (2/4) Oct 20 2006 I tried it in Mozilla, it looks different from both IE and Opera.
- Kyle Furlong (2/7) Oct 20 2006 You, sir, must not be a web programmer. :-D
- Walter Bright (2/10) Oct 20 2006 Uh-oh, he's on to me!
- Unknown W. Brackets (23/43) Oct 20 2006 Actually, they are portable... but what you're doing is technically
- Walter Bright (2/9) Oct 20 2006 I shall apply the fix. Thanks!
- Lionello Lunesu (5/26) Oct 20 2006 Wouldn't the same effect be achieved by setting "margin" instead of
- Unknown W. Brackets (13/52) Oct 20 2006 I'm afraid not. Margin controls the amount of spacing outside the box,
- Lionello Lunesu (9/17) Oct 20 2006 Well, why would anyone (Walter in this case) want to use "width"? Probab...
- Walter Bright (3/9) Oct 21 2006 I used the "width" so that multiple code boxes lined up neatly. It just
- Bill Baxter (6/14) Oct 20 2006 The same overflow problem exists in many of the D languages pages, too.
- Walter Bright (3/15) Oct 20 2006 I wouldn't be surprised at all at that, since they all use the same
- Lionello Lunesu (3/5) Oct 20 2006 That's how it looks in FireFox as well.
- Walter Bright (2/21) Oct 20 2006
- Brad Anderson (2/35) Oct 20 2006 To rephrase Brandon's response: D pwnz!!!
- Dave (4/28) Oct 11 2006 I see the dictionary and input files at the link below, but can't find t...
- Lionello Lunesu (6/15) Oct 13 2006 Ah, I could have posted that file, sorry.. Don't have it here, but it's ...
- Sean Kelly (49/49) Oct 11 2006 It's an interesting analysis, but I think some of the points of
- Walter Bright (2/13) Oct 11 2006 D just needs a foreach_reverse statement.
- Derek Parnell (7/8) Oct 12 2006 Ain't that the truth!
- clayasaurus (3/17) Oct 12 2006 old thread on the subject:
- James Dunne (12/30) Oct 16 2006 Thanks Clay. I was about to post an "I told you so..." post, but you
- Walter Bright (4/22) Oct 16 2006 I know, lots of good ideas in that thread. I was hoping to find a way to...
- Sean Kelly (18/18) Oct 11 2006 Oh, a quick comment on loops, since the article mentions those as well.
- Lionello Lunesu (4/32) Oct 12 2006 Perhaps foreach could always check for 'null' if you pass it a pointer
This old blog doesn't mention D, but I think it is good and really relevant anyway: http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.html IMO, it points to a set of issues that relate to how D (and its libraries) have the potential to allow developers to be a lot more productive than they are with C++. Particularly relevant D features related to the points mentioned there include but are not limited to GC, mixins, regex, and elimination of header/instantiation separation. The point about the productivity benefits of creating interfaces that return the most interesting value (maybe alongside the interface that allows the greatest efficiency when optimizing) is a good one to remember in practice.
Oct 10 2006
I think the number of lines is over rated. This is a very simple example and doesn't really compare anything useful. Lisp may have fewer lines but the number of parenthesis counter balances this. It really needs to compare something more complicated like a telephone PBX exchange. Lisp has a number of advantages including built in lists and this is a list problem. It doesn't compare anything except the implementation of lists of data and should focus on something much more complex with larger variables like a 3d game engine.
Oct 10 2006
On Tue, 10 Oct 2006 20:01:10 +0000, Makaan wrote:I think the number of lines is over rated.I guess it depends on who is rating and how they do it. The most obvious problem with line counting is that it doesn't insure an apples-to-apples comparison unless there is some way to hold quality relatively constant. Using small explicit tasks is one way to try to achieve the latter.This is a very simple example and doesn't really compare anything useful. Lisp may have fewer lines but the number of parenthesis counter balances this.What they actually measured in the referenced study was the amount of time the coding took to complete the task. If problems with LISP syntax still hurt productivity of experienced developers then that would have already been factored into the comparison. Looking at lines of code wasn't the base measure of productivity - it was rather the blog author's attempt to try and explain the amount of time it took. But my understanding parallels his in the sense that studies which have looked at larger projects still found number of lines of code required to be about the best predictor of the amount of time required for a given type of project - i.e. you can't compare app coding to real-time embedded coding, but you can you can compare across similar tasks, and some say lines of similar quality across similar task is a way to look at the effect of the programming language on productivity. That doesn't mean it's a great predictor - but it seems as good as anything else people have come up with.It really needs to compare something more complicated like a telephone PBX exchange. Lisp has a number of advantages including built in lists and this is a list problem. It doesn't compare anything except the implementation of lists of data and should focus on something much more complex with larger variables like a 3d game engine.At least the author of the blog was taking library data structures like lists and hashmaps for granted, so that wasn't the issue per se, though he finds fault with the existing interfaces from a productivity point of view.
Oct 10 2006
Josh Stern wrote:This old blog doesn't mention D, but I think it is good and really relevant anyway: http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.html IMO, it points to a set of issues that relate to how D (and its libraries) have the potential to allow developers to be a lot more productive than they are with C++. Particularly relevant D features related to the points mentioned there include but are not limited to GC, mixins, regex, and elimination of header/instantiation separation. The point about the productivity benefits of creating interfaces that return the most interesting value (maybe alongside the interface that allows the greatest efficiency when optimizing) is a good one to remember in practice.It is a very interesting article for anyone wanting to carefully look at language differences. Anyone care to try a D version following the original challenge? http://www.flownet.com/ron/papers/lisp-java/
Oct 10 2006
Walter Bright wrote:Josh Stern wrote:It was sooo easy in D! I got it done in 1 hour 15 minutes.. But, my results differ from theirs and I can't figure out why. For example, my prog comes up with "3-/0--69-4: 3 echt", which seems correct ("echt" is in the dictionary and is coded as "0694"), but their output.txt has nothing for the phone number "3-/0--69-4" ??? L.This old blog doesn't mention D, but I think it is good and really relevant anyway: http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.html IMO, it points to a set of issues that relate to how D (and its libraries) have the potential to allow developers to be a lot more productive than they are with C++. Particularly relevant D features related to the points mentioned there include but are not limited to GC, mixins, regex, and elimination of header/instantiation separation. The point about the productivity benefits of creating interfaces that return the most interesting value (maybe alongside the interface that allows the greatest efficiency when optimizing) is a good one to remember in practice.It is a very interesting article for anyone wanting to carefully look at language differences. Anyone care to try a D version following the original challenge? http://www.flownet.com/ron/papers/lisp-java/
Oct 11 2006
I give up. I can't figure out why those phone numbers are missing from their output. I've attached what I have so far. It's pretty nice, readable, and uses quite a few of D goodies ;) L.
Oct 11 2006
On Wed, 11 Oct 2006 13:45:29 +0300, Lionello Lunesu wrote:I give up. I can't figure out why those phone numbers are missing from their output. I've attached what I have so far. It's pretty nice, readable, and uses quite a few of D goodies ;) L. It was sooo easy in D! I got it done in 1 hour 15 minutes.. But, my results differ from theirs and I can't figure out why. For example, my prog comes up with "3-/0--69-4: 3 echt", which seems correct ("echt" is in the dictionary and is coded as "0694"), but their output.txt has nothing for the phone number "3-/0--69-4" ??? L.I just looked in the dictionary and "etch" isn't there. Maybe you are searching for "etch" and find "Sketch", "Ketchup"? If this is the case you can just look for the word preceeded by \n. Hope this helps. Can you repost your code I cannot see your attachment. AndBre
Oct 11 2006
I just looked in the dictionary and "etch" isn't there. Maybe you are searching for "etch" and find "Sketch", "Ketchup"? If this is the case you can just look for the word preceeded by \n. Hope this helps. Can you repost your code I cannot see your attachment. AndBreSorry I mispelled the word, you are right, it is in the dictionary. AndBre
Oct 11 2006
How does the speed stack up with the C++ version?
Oct 12 2006
Walter Bright wrote:How does the speed stack up with the C++ version?My version in D seems more straightforward than either C++ version on that site, so they can't really be compared. I'd have to port my D version to C++, but I don't know enough STL and am reluctant to learn it. Doing the task in D was just incredible easy and straightforward. And the result runs faster than that C++ version, which is not really saying much about D, knowing the excess string conversions in the C++ version. L.
Oct 13 2006
While trying to understand the c++ implementation, I found out what the problem was. The c++ version does not allow a digit at position k if there's a word in the dictionary that matches the digits at k..n, even if that word cannot actually be used in the encoding because of a mismatch anywhere after n. For example 30694, there IS a word matching "306", "sei" and therefor, the result "3-/0--69-4: 3 echt" is not considered.. L.
Oct 13 2006
Lionello Lunesu wrote:While trying to understand the c++ implementation, I found out what the problem was. The c++ version does not allow a digit at position k if there's a word in the dictionary that matches the digits at k..n, even if that word cannot actually be used in the encoding because of a mismatch anywhere after n. For example 30694, there IS a word matching "306", "sei" and therefor, the result "3-/0--69-4: 3 echt" is not considered.. L.So the C++ version wasn't merely more complicated and slower than D, it was also wrong??
Oct 13 2006
"Don Clugston" <dac nospam.com.au> wrote in message news:egoc9c$lfm$1 digitaldaemon.com...Lionello Lunesu wrote:I would say: yes :) But, I don't really know what's right and what's wrong, since the description could be interpreted either way. I'd say the way the C++ version is doing it makes no sense logically.. The fact that there's a word "sei" in the dictionary should not prevent a good result "3 echt" from being considered. L.While trying to understand the c++ implementation, I found out what the problem was. The c++ version does not allow a digit at position k if there's a word in the dictionary that matches the digits at k..n, even if that word cannot actually be used in the encoding because of a mismatch anywhere after n. For example 30694, there IS a word matching "306", "sei" and therefor, the result "3-/0--69-4: 3 echt" is not considered.. L.So the C++ version wasn't merely more complicated and slower than D, it was also wrong??
Oct 13 2006
Lionello Lunesu wrote:But, I don't really know what's right and what's wrong, since the description could be interpreted either way. I'd say the way the C++ version is doing it makes no sense logically.. The fact that there's a word "sei" in the dictionary should not prevent a good result "3 echt" from being considered.Could you put together a web page with the results? Or just text, I can turn it into a web page.
Oct 13 2006
Walter Bright wrote:Lionello Lunesu wrote:Sure thing!But, I don't really know what's right and what's wrong, since the description could be interpreted either way. I'd say the way the C++ version is doing it makes no sense logically.. The fact that there's a word "sei" in the dictionary should not prevent a good result "3 echt" from being considered.Could you put together a web page with the results? Or just text, I can turn it into a web page.
Oct 15 2006
Could you put together a web page with the results? Or just text, I can turn it into a web page.Here it is! Feel free to check my english and fix it :) L. begin 666 lisp-java-d.zip M;+5:;7/;N!'^WIG^AXW;N4 ]F;3D=\M6)V?G6E]SN6OB-FT33X<2(8EGBF ) MTHZ;YGY[GUWP!:3DV&VG\EB42&"QV'UV]P& TV<7/YQ?_?7'E[3,5S']^*=O M7EV>T]:V[[_;/??]BZL+^OW5]Z]HS]L9TE46)";*(YT$L>^_?+WURU\07EO+ M/$]/?/_N[LZ[V_5TMO"OWO L;\^/M3;*"_-P:_++7YSRO8GM=+I405A^EN]Y ME,=J\BHR*=T:C[X+; //\^CBMW3JVV=.8Y/?QXKR^U2=;>7J8^[/C-F:T%2' M]_2)9CK6V0E-XV!V,Z8IWA>9+I+PA.Z64:[&]-F*FKIMB^9^T=S/51"/B8?8 M#M5,9P'/_H02G33-HZ;Y(E,JJ1^DF<(C=_Q?*7F-:15DBPB"1COIQ\X;--99 M6D1Y$&.:QIOIE1_Z039;1K?*^,XC_\*/DE!]]! 86XY&U<L5<T&)NC-LR?34 M#R8 M9 L]J +WI5"9619->>8!W*KAC]6*O\V601RK9*%8)5 CR.DN,*0S*(XHB>\) MXX<P'?JU99N\`%CQ`)B<+6GWB,X'!(5 Z5!<58^C, /?`$N!N;&SO,L`8[K% M$S;R 30>9$E,(8N<I[C%,:A6:R"C.ZB)(&^&M9IIMR6S :X6T+]4C+\&*I; M%>MTI1+(BU9*> %<2JP[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J^_SC>Q2]ZBD:XMV-238TZ9 M959DF9*-8V?V0OF[H=3A-.MBR^TL/M>&4KPYG49JAH5;P/$49'DIUV*_7KXU MKXV6: -U-&Y%6.6DW/-^?3UPS27=6RGG8;F]`*#YS2-.*U\E,PB&]+.E-3:Y M_4Q0K=WI\YK#ZH7'QKF6DEMZC!OKRJZX;)H9M>879[G37<A=97* =Z-4BN)5 M+12J&_240P.C$B/;-HGL&$K3&OE; TTBI\67SOV,4JORD$>.$7 CS'MP\5FE MWZ^"53J6-WI6#X_0L4,VNG.ZV\']:I73\:P5NSD2AT^(Q,HQK<"K2UC%#C/A M.$X "3KJ: *A:N] K=MD?0=A;04 S3J$I&<W!,N3"MF$CQ+>(:CW$MWS9-XJ M=W=B_A-6XQ[=K8NP9RKFI*&$Y<F3T]2MR^L$1N3_O:27I7,_;0RK9V[3, S6 M.84U'Q2.XVY9%P_))IS,[\O[<.Z\93MX4]9(P6#X]P[\(P;[ Y,B,\R=:\_T M/TTGG2WY`>E9[M'P",ELM+-ST.ST0V7[B[U3O_QQY+\!4$L!`A0`% ```` ` ;+FAT;6Q02P4&``````$``0`^````N X````` ` end
Oct 19 2006
Lionello Lunesu wrote:Cool!Could you put together a web page with the results? Or just text, I can turn it into a web page.Here it is! Feel free to check my english and fix it :)
Oct 19 2006
I've taken the liberty of: 1) Converting it to use Ddoc and the macros used to create the Digital Mars site. 2) Added a link to this thread. 3) Took out the bit about compiling html, as I need to fix Ddoc so that works! 4) Hosting it. If you object to any of this, or have any corrections, please let me know and I'll take care of it! http://www.digitalmars.com/d/lisp-java-d.html If it meets with your approval, I'll add it to the 'Comparisons' links. Thanks!
Oct 19 2006
"Walter Bright" <newshound digitalmars.com> wrote in message news:eh9fib$ve9$1 digitaldaemon.com...I've taken the liberty of: 1) Converting it to use Ddoc and the macros used to create the Digital Mars site. 2) Added a link to this thread. 3) Took out the bit about compiling html, as I need to fix Ddoc so that works! 4) Hosting it. If you object to any of this, or have any corrections, please let me know and I'll take care of it! http://www.digitalmars.com/d/lisp-java-d.html If it meets with your approval, I'll add it to the 'Comparisons' links.Of couse, I'd be honoured! :)Thanks!No, thank you! ; ) L. PS. I don't like the way the longer lines of code exceed the code-box. I had the same thing and fixed it using 'margin' instead of 'width' in the style sheet. Might work?
Oct 19 2006
Lionello Lunesu wrote:Of couse, I'd be honoured! :)Ok!PS. I don't like the way the longer lines of code exceed the code-box. I had the same thing and fixed it using 'margin' instead of 'width' in the style sheet. Might work?I think it looks fine.
Oct 19 2006
On Fri, 20 Oct 2006 02:47:40 -0400, Walter Bright <newshound digitalmars.com> wrote:Lionello Lunesu wrote:Looks pretty bad to me, http://img148.imageshack.us/img148/5238/t4h8t4g3ev7.pngOf couse, I'd be honoured! :)Ok!PS. I don't like the way the longer lines of code exceed the code-box. I had the same thing and fixed it using 'margin' instead of 'width' in the style sheet. Might work?I think it looks fine.
Oct 19 2006
Chris Miller wrote:On Fri, 20 Oct 2006 02:47:40 -0400, Walter Bright <newshound digitalmars.com> wrote:Yowsa! I guess that's the problem with style sheets. They aren't portable. (It looks fine in Explorer, what are you using?)Lionello Lunesu wrote:Looks pretty bad to me, http://img148.imageshack.us/img148/5238/t4h8t4g3ev7.pngOf couse, I'd be honoured! :)Ok!PS. I don't like the way the longer lines of code exceed the code-box. I had the same thing and fixed it using 'margin' instead of 'width' in the style sheet. Might work?I think it looks fine.
Oct 20 2006
On Fri, 20 Oct 2006 03:12:44 -0400, Walter Bright <newshound digitalmars.com> wrote:Chris Miller wrote:Opera.On Fri, 20 Oct 2006 02:47:40 -0400, Walter Bright <newshound digitalmars.com> wrote:Yowsa! I guess that's the problem with style sheets. They aren't portable. (It looks fine in Explorer, what are you using?)Lionello Lunesu wrote:Looks pretty bad to me, http://img148.imageshack.us/img148/5238/t4h8t4g3ev7.pngOf couse, I'd be honoured! :)Ok!PS. I don't like the way the longer lines of code exceed the code-box. I had the same thing and fixed it using 'margin' instead of 'width' in the style sheet. Might work?I think it looks fine.
Oct 20 2006
Chris Miller wrote:I tried it in Mozilla, it looks different from both IE and Opera.(It looks fine in Explorer, what are you using?)Opera.
Oct 20 2006
Walter Bright wrote:Chris Miller wrote:You, sir, must not be a web programmer. :-DI tried it in Mozilla, it looks different from both IE and Opera.(It looks fine in Explorer, what are you using?)Opera.
Oct 20 2006
Kyle Furlong wrote:Walter Bright wrote:Uh-oh, he's on to me!Chris Miller wrote:You, sir, must not be a web programmer. :-DI tried it in Mozilla, it looks different from both IE and Opera.(It looks fine in Explorer, what are you using?)Opera.
Oct 20 2006
Actually, they are portable... but what you're doing is technically incorrect. I had thought it was intentional. You set a width for the box, and so the standards-compliant browsers listen to you and do as you say. You don't set overflow, so it's defaulted to visible. Thus what you see in the screenshot. Internet Explorer is completely ignoring the standards (what the CSS property "width" is supposed to do) and treating it as a minimum width. Normally, you'd set min-width instead to get the effect that Internet Explorer is giving you... but IE does not support min-width. Hence probably why Internet Explorer behaves this way. A lot of people use something like this for that: min-width: 600px; width: expression("600px"); /* This line only understood by IE. */ However, Internet Explorer 7 (coming out _very_ soon, final already available for download) will comply with the standards (when the document has a proper DOCTYPE, which yours does) and thus the above will break it. I would suggest that it wouldn't be too bad to simply have: min-width: 600px; Because, this will mean that Internet Explorer 6 and below will simply show the box at whatever width, including smaller than 600px... but every other browser will work as you wish. -[Unknown]Chris Miller wrote:On Fri, 20 Oct 2006 02:47:40 -0400, Walter Bright <newshound digitalmars.com> wrote:Yowsa! I guess that's the problem with style sheets. They aren't portable. (It looks fine in Explorer, what are you using?)Lionello Lunesu wrote:Looks pretty bad to me, http://img148.imageshack.us/img148/5238/t4h8t4g3ev7.pngOf couse, I'd be honoured! :)Ok!PS. I don't like the way the longer lines of code exceed the code-box. I had the same thing and fixed it using 'margin' instead of 'width' in the style sheet. Might work?I think it looks fine.
Oct 20 2006
Unknown W. Brackets wrote:I would suggest that it wouldn't be too bad to simply have: min-width: 600px; Because, this will mean that Internet Explorer 6 and below will simply show the box at whatever width, including smaller than 600px... but every other browser will work as you wish.I shall apply the fix. Thanks!
Oct 20 2006
"Unknown W. Brackets" <unknown simplemachines.org> wrote in message news:ehanlp$22jc$1 digitaldaemon.com...Actually, they are portable... but what you're doing is technically incorrect. I had thought it was intentional. You set a width for the box, and so the standards-compliant browsers listen to you and do as you say. You don't set overflow, so it's defaulted to visible. Thus what you see in the screenshot. Internet Explorer is completely ignoring the standards (what the CSS property "width" is supposed to do) and treating it as a minimum width. Normally, you'd set min-width instead to get the effect that Internet Explorer is giving you... but IE does not support min-width. Hence probably why Internet Explorer behaves this way. A lot of people use something like this for that: min-width: 600px; width: expression("600px"); /* This line only understood by IE. */ However, Internet Explorer 7 (coming out _very_ soon, final already available for download) will comply with the standards (when the document has a proper DOCTYPE, which yours does) and thus the above will break it. I would suggest that it wouldn't be too bad to simply have: min-width: 600px; Because, this will mean that Internet Explorer 6 and below will simply show the box at whatever width, including smaller than 600px... but every other browser will work as you wish.Wouldn't the same effect be achieved by setting "margin" instead of "(min-)width"? L.
Oct 20 2006
I'm afraid not. Margin controls the amount of spacing outside the box, against other boxes or the outside edge of the browser. Thus, if you want the box to be at least 600px wide on a 800px, 1024px, or 1600px screen (not even beginning to talk about un-maximized browser windows!)... you cannot use a fixed margin to achieve this. Using a percentage wouldn't be too bad, but would cause their to be much scrollable space on the right. Unless you mean something else, and I'm misunderstanding you? You could, in theory, use some trickery to achieve the affect using margins or other properties and nesting many elements (or use a table), but it would likely result in brittle, unmaintainable HTML/CSS which does no one much good. -[Unknown]"Unknown W. Brackets" <unknown simplemachines.org> wrote in message news:ehanlp$22jc$1 digitaldaemon.com...Actually, they are portable... but what you're doing is technically incorrect. I had thought it was intentional. You set a width for the box, and so the standards-compliant browsers listen to you and do as you say. You don't set overflow, so it's defaulted to visible. Thus what you see in the screenshot. Internet Explorer is completely ignoring the standards (what the CSS property "width" is supposed to do) and treating it as a minimum width. Normally, you'd set min-width instead to get the effect that Internet Explorer is giving you... but IE does not support min-width. Hence probably why Internet Explorer behaves this way. A lot of people use something like this for that: min-width: 600px; width: expression("600px"); /* This line only understood by IE. */ However, Internet Explorer 7 (coming out _very_ soon, final already available for download) will comply with the standards (when the document has a proper DOCTYPE, which yours does) and thus the above will break it. I would suggest that it wouldn't be too bad to simply have: min-width: 600px; Because, this will mean that Internet Explorer 6 and below will simply show the box at whatever width, including smaller than 600px... but every other browser will work as you wish.Wouldn't the same effect be achieved by setting "margin" instead of "(min-)width"? L.
Oct 20 2006
"Unknown W. Brackets" <unknown simplemachines.org> wrote in message news:ehcbui$ip8$1 digitaldaemon.com...I'm afraid not. Margin controls the amount of spacing outside the box, against other boxes or the outside edge of the browser. Thus, if you want the box to be at least 600px wide on a 800px, 1024px, or 1600px screen (not even beginning to talk about un-maximized browser windows!)... you cannot use a fixed margin to achieve this. Using a percentage wouldn't be too bad, but would cause their to be much scrollable space on the right. Unless you mean something else, and I'm misunderstanding you?Well, why would anyone (Walter in this case) want to use "width"? Probably to prevent the code-box from touching the edges of the page. The problem with "width" was that it can make the box too small for its contents. That's why I suggested using "margin" instead. It prevents the box from touching the edges but never smaller than the longest line inside the box.. But that was of course before I knew "min-width" existed :) L.
Oct 20 2006
Lionello Lunesu wrote:Well, why would anyone (Walter in this case) want to use "width"? Probably to prevent the code-box from touching the edges of the page. The problem with "width" was that it can make the box too small for its contents. That's why I suggested using "margin" instead. It prevents the box from touching the edges but never smaller than the longest line inside the box.. But that was of course before I knew "min-width" existed :)I used the "width" so that multiple code boxes lined up neatly. It just looked better.
Oct 21 2006
Walter Bright wrote:Chris Miller wrote:The same overflow problem exists in many of the D languages pages, too. e.g. http://www.digitalmars.com/d/template.html If I switch to a small enough default font it looks ok, though. (I use FireFox.) --bbLooks pretty bad to me, http://img148.imageshack.us/img148/5238/t4h8t4g3ev7.pngYowsa! I guess that's the problem with style sheets. They aren't portable. (It looks fine in Explorer, what are you using?)
Oct 20 2006
Bill Baxter wrote:Walter Bright wrote:I wouldn't be surprised at all at that, since they all use the same style sheet, and all are generated with Ddoc macros.Chris Miller wrote:The same overflow problem exists in many of the D languages pages, too. e.g. http://www.digitalmars.com/d/template.htmlLooks pretty bad to me, http://img148.imageshack.us/img148/5238/t4h8t4g3ev7.pngYowsa! I guess that's the problem with style sheets. They aren't portable. (It looks fine in Explorer, what are you using?)
Oct 20 2006
Chris Miller wrote:Looks pretty bad to me, http://img148.imageshack.us/img148/5238/t4h8t4g3ev7.pngThat's how it looks in FireFox as well. L.
Oct 20 2006
I sent Brandon Corfman a link to your article, and here's his reply (posted with his permission):Thanks for sharing that article. It's a good discussion, although I'll certainly need more time to study the results in detail. Here's another link to results in some other languages: http://www.nsl.com/papers/phone.htm Since I can't enter the discussion, one thing I wanted to point out is that I posted my original C++ code verbatim as soon as I was finished. So although there are better ways to use the STL (as has been endlessly pointed out to me by other C++ advocates), the point wasn't to tweak the original program to make it more concise, as that would simply have eaten up more time. The point was to solve the program as quickly as I could and then measure the LOC afterwards. I'm really impressed with the way Lionello wrote the code without looking at the other versions first. I've had plenty of others tell me that they translated existing programs into their pet language or wrote their own after studying the solutions. Most of them also won't tell how long it took them either ... especially the C++ guys ... heh. Brandon
Oct 20 2006
Walter Bright wrote:I sent Brandon Corfman a link to your article, and here's his reply (posted with his permission):To rephrase Brandon's response: D pwnz!!!Thanks for sharing that article. It's a good discussion, although I'll certainly need more time to study the results in detail. Here's another link to results in some other languages: http://www.nsl.com/papers/phone.htm Since I can't enter the discussion, one thing I wanted to point out is that I posted my original C++ code verbatim as soon as I was finished. So although there are better ways to use the STL (as has been endlessly pointed out to me by other C++ advocates), the point wasn't to tweak the original program to make it more concise, as that would simply have eaten up more time. The point was to solve the program as quickly as I could and then measure the LOC afterwards. I'm really impressed with the way Lionello wrote the code without looking at the other versions first. I've had plenty of others tell me that they translated existing programs into their pet language or wrote their own after studying the solutions. Most of them also won't tell how long it took them either ... especially the C++ guys ... heh. Brandon
Oct 20 2006
Walter Bright wrote:Josh Stern wrote:I see the dictionary and input files at the link below, but can't find the mappings.txt file used in the C++ version... Am I just missing it? Thanks.This old blog doesn't mention D, but I think it is good and really relevant anyway: http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.htmlIMO, it points to a set of issues that relate to how D (and its libraries) have the potential to allow developers to be a lot more productive than they are with C++. Particularly relevant D features related to the points mentioned there include but are not limited to GC, mixins, regex, and elimination of header/instantiation separation. The point about the productivity benefits of creating interfaces that return the most interesting value (maybe alongside the interface that allows the greatest efficiency when optimizing) is a good one to remember in practice.It is a very interesting article for anyone wanting to carefully look at language differences. Anyone care to try a D version following the original challenge? http://www.flownet.com/ron/papers/lisp-java/
Oct 11 2006
"Dave" <Dave_member pathlink.com> wrote in message news:egk0jk$2d59$1 digitaldaemon.com...Walter Bright wrote:Ah, I could have posted that file, sorry.. Don't have it here, but it's just a txt file with "e 0\nE 0\n"... etc. I made it myself using the table from the original task description. L.Josh Stern wrote:I see the dictionary and input files at the link below, but can't find the mappings.txt file used in the C++ version... Am I just missing it?This old blog doesn't mention D, but I think it is good and really relevant anyway: http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.html
Oct 13 2006
It's an interesting analysis, but I think some of the points of comparison aren't as strong has the writer implies. For example, he begins by saying that his initial C++ attempt is shorter than average and suggests that this is because his is the only C++ attempt to use the STL. Later he goes on to make a direct comparison of some of his code and some of Peter Norvig's code (in the Style section) and concludes that because Norvig's code is shorter and doesn't modify the sequence in place, functional programming is better. He's forgotten his original statement regarding his code vs. the other C++ entrants however, and perhaps doesn't have enough experience with the STL to know that: words.reverse(); cout << num << ":"; for (list<string>::const_iterator i = words.begin(); i != words.end(); ++i) cout << *i << " "; cout << "\n"; can be rewritten as: std::cout << num << ':'; std::reverse_copy( words.begin(), words.end(), std::ostream_iterator<std::string>( std::cout, " " ) ); std::cout << '\n'; This rewrite addresses his concern about reversing the list in place to print it out (it doesn't modify the original sequence), and partially addresses the comment about having to print out the list manually. It also reduces his LOC count by two and is almost as expressive as the Lisp version. A further reading of his code shows that he doesn't use the algorithm library at all, which is IMO one of the greatest strengths of C++. That said, I do agree with the general thrust of the article. While tricks like the above are possible in C++, they tend to require a good degree of knowledge or experience to be aware of. By comparison, I think Lisp naturally lends itself to the type of code in Norvig's example. The Lisp code is also more succinct and more clear than even an algorithm-aware rewrite of the C++ version, though I believe the gap would be narrower than the original comparison suggests. I believe that D has a definite opportunity to do better than C++ in code clarity and ease of programming, but I'm not sure the library is sufficient quiet yet. The C++ algorithm/iterator model is extremely powerful and D's foreach and delegates aren't enough by themselves. For example, writing the code snippet above in D would be much more like the original C++ version than my rewrite. For D to be great, I think it will need an standard algorithm-oriented library that exploits D's unique language features. DTL seemed a likely candidate, but development on it stalled ages ago. But perhaps it contains ideas worth pursuing. I'll admit it's been so long that I've forgotten a lot of the details of how it works. Sean
Oct 11 2006
Sean Kelly wrote:I believe that D has a definite opportunity to do better than C++ in code clarity and ease of programming, but I'm not sure the library is sufficient quiet yet. The C++ algorithm/iterator model is extremely powerful and D's foreach and delegates aren't enough by themselves. For example, writing the code snippet above in D would be much more like the original C++ version than my rewrite. For D to be great, I think it will need an standard algorithm-oriented library that exploits D's unique language features. DTL seemed a likely candidate, but development on it stalled ages ago. But perhaps it contains ideas worth pursuing. I'll admit it's been so long that I've forgotten a lot of the details of how it works.D just needs a foreach_reverse statement.
Oct 11 2006
On Wed, 11 Oct 2006 10:55:35 -0700, Walter Bright wrote:D just needs a foreach_reverse statement.Ain't that the truth! -- Derek Parnell Melbourne, Australia "Down with mediocrity!"
Oct 12 2006
Walter Bright wrote:Sean Kelly wrote:old thread on the subject: http://www.digitalmars.com/d/archives/digitalmars/D/17320.htmlI believe that D has a definite opportunity to do better than C++ in code clarity and ease of programming, but I'm not sure the library is sufficient quiet yet. The C++ algorithm/iterator model is extremely powerful and D's foreach and delegates aren't enough by themselves. For example, writing the code snippet above in D would be much more like the original C++ version than my rewrite. For D to be great, I think it will need an standard algorithm-oriented library that exploits D's unique language features. DTL seemed a likely candidate, but development on it stalled ages ago. But perhaps it contains ideas worth pursuing. I'll admit it's been so long that I've forgotten a lot of the details of how it works.D just needs a foreach_reverse statement.
Oct 12 2006
clayasaurus wrote:Walter Bright wrote:Thanks Clay. I was about to post an "I told you so..." post, but you saved us all from that fate. Wait... -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O M-- V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e h>--->++ r+++ y+++ ------END GEEK CODE BLOCK------ James DunneSean Kelly wrote:old thread on the subject: http://www.digitalmars.com/d/archives/digitalmars/D/17320.htmlI believe that D has a definite opportunity to do better than C++ in code clarity and ease of programming, but I'm not sure the library is sufficient quiet yet. The C++ algorithm/iterator model is extremely powerful and D's foreach and delegates aren't enough by themselves. For example, writing the code snippet above in D would be much more like the original C++ version than my rewrite. For D to be great, I think it will need an standard algorithm-oriented library that exploits D's unique language features. DTL seemed a likely candidate, but development on it stalled ages ago. But perhaps it contains ideas worth pursuing. I'll admit it's been so long that I've forgotten a lot of the details of how it works.D just needs a foreach_reverse statement.
Oct 16 2006
clayasaurus wrote:Walter Bright wrote:I know, lots of good ideas in that thread. I was hoping to find a way to do it using existing language facilities, but the results are just too hackish.Sean Kelly wrote:old thread on the subject: http://www.digitalmars.com/d/archives/digitalmars/D/17320.htmlI believe that D has a definite opportunity to do better than C++ in code clarity and ease of programming, but I'm not sure the library is sufficient quiet yet. The C++ algorithm/iterator model is extremely powerful and D's foreach and delegates aren't enough by themselves. For example, writing the code snippet above in D would be much more like the original C++ version than my rewrite. For D to be great, I think it will need an standard algorithm-oriented library that exploits D's unique language features. DTL seemed a likely candidate, but development on it stalled ages ago. But perhaps it contains ideas worth pursuing. I'll admit it's been so long that I've forgotten a lot of the details of how it works.D just needs a foreach_reverse statement.
Oct 16 2006
Oh, a quick comment on loops, since the article mentions those as well. Here is the Lisp code: (loop for word in (gethash n *dict*) do His C++ version: for (HashMap::iterator i = gDict.equal_range(n).begin(); i != gDict.equal_range(n).end(); i++) In D, if the words were stored in a sorted array, I would write: foreach( word; dict[lowerBound(n) .. upperBound(n)] ) And if they were in an AA (char[][][int] dict): foreach( word; dict[n] ) Note that this expects the lookup for n to succeed or the current AA code will throw an exception. A more robust version: char[][]* list = n in dict; if( list ) foreach( word; *list ) seems unnecessarily wordy and somewhat unreadable. It would be nice if AAs had some lookup method that returned a default value on failure instead of requiring the pointer check above. Sean
Oct 11 2006
Sean Kelly wrote:Oh, a quick comment on loops, since the article mentions those as well. Here is the Lisp code: (loop for word in (gethash n *dict*) do His C++ version: for (HashMap::iterator i = gDict.equal_range(n).begin(); i != gDict.equal_range(n).end(); i++) In D, if the words were stored in a sorted array, I would write: foreach( word; dict[lowerBound(n) .. upperBound(n)] ) And if they were in an AA (char[][][int] dict): foreach( word; dict[n] ) Note that this expects the lookup for n to succeed or the current AA code will throw an exception. A more robust version: char[][]* list = n in dict; if( list ) foreach( word; *list ) seems unnecessarily wordy and somewhat unreadable. It would be nice if AAs had some lookup method that returned a default value on failure instead of requiring the pointer check above.Perhaps foreach could always check for 'null' if you pass it a pointer to an array. L.
Oct 12 2006