December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy Attachments:
| On 13 December 2013 23:34, Daniel Murphy <yebblies@nospamgmail.com> wrote:
> "Rikki Cattermole" <alphaglosined@gmail.com> wrote in message news:otjpativnfoecwjqethp@forum.dlang.org...
> >
> > You have a lot of global variables of same type. With very similar
> default
> > values.
> > Example windX and runTmr. They are both doubles.
> >
> > Perhaps an alternative way to write it is like this:
> > double
> > windX = 0,
> > runTmr = 0;
> >
> > You also have a lot of enums that like WIDTH and HEIGHT that could be
> > transformed into a single enum.
> > e.g.
> > enum int WIDTH = 800;
> > enum int HEIGHT = 600;
> >
> > Would become:
> > enum : int {
> > WIDTH = 800,
> > HEIGHT = 600
> > }
> >
> > Adds a couple extra lines but hey when you got 20 odd values and
> repeating
> > the type it kinda looks ugly.
> >
>
> I would not consider either of those an improvement.
>
Me either.
|
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On 12/13/2013 05:05 PM, Manu wrote: > > Is it idiomatic to use egyptian braces in D? Brackets? Yes. > I've never seen D code written this way... > looks like Java. Not really, no. |
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr Attachments:
| On 14 December 2013 02:12, Timon Gehr <timon.gehr@gmx.ch> wrote: > On 12/13/2013 05:05 PM, Manu wrote: > >> >> Is it idiomatic to use egyptian braces in D? >> > > Brackets? Yes. [] is brackets, {} is braces. I've never seen D code written this way... >> looks like Java. >> > > Not really, no. > No, as in, people 'not really' write D code that way, or no as in, it doesn't look like java, except that it does, because only it and javascript have idiomatic egyptian braces... ;) I'm just saying, if it's code to be compared against other languages, then it should conform to the general standards of the language. I've never seen D code use egyptian braces. Certainly the vast majority of D code doesn't. I don't care which, but stick with one as a 'standard'. D has clearly chosen C braces, not Java braces, all the standard libraries agree. If you were going to publish some Java code using C braces, how would you feel about that? |
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Friday, 13 December 2013 at 16:06:10 UTC, Manu wrote:
> Is it idiomatic to use egyptian braces in D? I've never seen D code written
> this way... looks like Java.
If by "idiomatic" you mean "Phobos style guidelines", then - no. But idiomatic D is something I don't have clear grasp of :)
|
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Friday, 13 December 2013 at 16:40:13 UTC, Manu wrote: > I'm just saying, if it's code to be compared against other languages, then > it should conform to the general standards of the language. > I've never seen D code use egyptian braces. You've never read TDPL. .. or Ali Cehreli's D tutorial. ... or looked at the D Rosetta code examples > Certainly the vast majority of > D code doesn't. I don't care which, but stick with one as a 'standard'. D > has clearly chosen C braces, D is not a sentient being and can't choose anything. Some group of D coders chose that brace placement and 8 space indentation. Others have chosen a style which favors less extravagant usage of screen or book page real estate. > If you were going to publish some Java code using C braces, how would you feel about that? Feel free! I acknowledge that Phobos has specified a style, but this isn't a Phobos submission. I can read either (and more!) but I have noticed that what you're calling Java style is catching on across a number of languages with C inspired syntax. There are advantages to that. If you feel strongly about this you may prefer Nimrod, which removes the choice from you, like Python. There are advantages to that, too. -- Brian |
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian Rogoff Attachments:
| On 14 December 2013 03:10, Brian Rogoff <brogoff@gmail.com> wrote: > On Friday, 13 December 2013 at 16:40:13 UTC, Manu wrote: > >> I'm just saying, if it's code to be compared against other languages, then >> it should conform to the general standards of the language. >> I've never seen D code use egyptian braces. >> > > You've never read TDPL. > Published material, optimised for print. Andrei admits this. He uses C braces in his code. .. or Ali Cehreli's D tutorial. > Possibly following Andrei's lead, and possible consideration for print? ... or looked at the D Rosetta code examples No, not really. That's a bit sad. I'd make the same argument there if it's as you say though. Certainly the vast majority of >> D code doesn't. I don't care which, but stick with one as a 'standard'. D has clearly chosen C braces, >> > > D is not a sentient being and can't choose anything. Some group of D coders chose that brace placement and 8 space indentation. Others have chosen a style which favors less extravagant usage of screen or book page real estate. > > > If you were going to publish some Java code using C braces, how would you >> feel about that? >> > > Feel free! You're saying you wouldn't find it unconventional, and perhaps ammateur looking? I acknowledge that Phobos has specified a style, but this isn't a Phobos > submission. I take druntime and phobos as they are the largest and most widely used body of D code, along with many other projects I've run into that also follow that lead. I'm yet to encounter any exceptions. I can read either (and more!) but I have noticed that what you're calling > Java style is catching on across a number of languages with C inspired syntax. There are advantages to that. > > If you feel strongly about this you may prefer Nimrod, which removes the choice from you, like Python. There are advantages to that, too. I only feel strongly about not being ambivalent on the matter. When I write Java, I use egyptian braces, and then it looks like Java code. Most people seem to understand that that's an expectation in Java. When I write C code, I use C braces. I think C became widely confused soon after university CS courses started teaching Java primarily, then you have inexperienced post-grads bring their Java habits into their C code. If D deliberately commits to the 'university post-grad syndrome' principle that C has found itself in, then I find that to be sad. However, clearly, since there's debate on this, D _has_ already inadvertently made that commitment. Oh well. |
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Friday, 13 December 2013 at 17:30:09 UTC, Manu wrote: > On 14 December 2013 03:10, Brian Rogoff <brogoff@gmail.com> >> You've never read TDPL. >> > > Published material, optimised for print. Andrei admits this. He uses C > braces in his code. I don't see why 'optimized for print' isn't a strong argument for code being read from a terminal or browser or IDE or whatever, but I accept that this is a matter of taste. > > .. or Ali Cehreli's D tutorial. >> > > Possibly following Andrei's lead, and possible consideration for print? Or possibly Ali just prefers this style? > ... or looked at the D Rosetta code examples > > > No, not really. That's a bit sad. I'd make the same argument there if it's > as you say though. It is as I say. Also with much of the C++ and Java (as you would guess) submissions. I don't find it sad. I find it sadder that 8 spaces was chosen for the Phobos indentation. >> If you were going to publish some Java code using C braces, how would you >>> feel about that? >>> >> >> Feel free! > > > You're saying you wouldn't find it unconventional, and perhaps ammateur > looking? No, I'm not saying that. I would find it unusual. As I said, I've noticed that the publication style indentation is becoming more widely used in C and C++ as well. I'm just saying that I've grown used to reading many different styles, so I wouldn't assume amateurism, but given the code I've been reading and what I said above anything that isn't publication style looks a bit unusual to me. More so in Java, as you say. BTW, I like the term 'Egyptian style', but 'publication style' more accurately suggests its rationale. > I only feel strongly about not being ambivalent on the matter. When I write > Java, I use egyptian braces, and then it looks like Java code. Most people > seem to understand that that's an expectation in Java. When I write C code, > I use C braces. > I think C became widely confused soon after university CS courses started > teaching Java primarily, then you have inexperienced post-grads bring their > Java habits into their C code. I remember discussion of this in C long before Java became popular. I learned to just use whatever other programmer's had used on any given project. If there is a choice, some people will make different choices. > If D deliberately commits to the 'university post-grad syndrome' principle > that C has found itself in, then I find that to be sad. > However, clearly, since there's debate on this, D _has_ already > inadvertently made that commitment. Oh well. I don't think it's a university thing. Nor am I suggesting that there is debate: the course for Phobos has been charted. What I'm suggesting is that the entire D community isn't committed to that style. You can enforce it on your own projects, but that's your choice. -- Brian |
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On 12/13/2013 05:40 PM, Manu wrote: > On 14 December 2013 02:12, Timon Gehr <timon.gehr@gmx.ch > <mailto:timon.gehr@gmx.ch>> wrote: > > On 12/13/2013 05:05 PM, Manu wrote: > > > Is it idiomatic to use egyptian braces in D? > > > Brackets? Yes. > > > [] is brackets, {} is braces. > ... [] // angle brackets {} // curly brackets, braces if(..){ // egyptian brackets } http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html Note that egyptian brackets is way easier to google than egyptian braces, and the latter term does not occur in any of the results on the first page as far as I can see. > > I've never seen D code written this way... > looks like Java. > > > Not really, no. > > > No, as in, people 'not really' write D code that way, or no as in, it > doesn't look like java, except that it does, because only it and > javascript have idiomatic egyptian braces... ;) > ... D code does not look like Java code. > I'm just saying, if it's code to be compared against other languages, > then it should conform to the general standards of the language. The language is whitespace-agnostic except for delimiting tokens. > I've never seen D code use egyptian braces. I've never heard the term egyptian braces. Also, I don't believe you. http://dlang.org > Certainly the vast majority of D code doesn't. The vast majority seems to use the term 'egyptian brackets'. > I don't care which, but stick with one as a > 'standard'. D has clearly chosen C braces, not Java braces, all the > standard libraries agree. > ... Well, Phobos is not even fully consistent here, ../dmd-2.064/src/phobos/std$ grep ")\s*{" *.d | wc -l 2070 even if we allow if(...){ } etc., .../dmd-2.064/src/phobos/std$ grep ")\s*{[^}]*$" *.d | wc -l 743 > If you were going to publish some Java code using C braces, I don't. > how would you feel about that? Why does this matter? |
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Friday, 13 December 2013 at 17:30:09 UTC, Manu wrote:
> I take druntime and phobos as they are the largest and most widely used
> body of D code, along with many other projects I've run into that also
> follow that lead. I'm yet to encounter any exceptions.
If you ever used the Derelict-style bindings for Assimp I threw together (and which are hopelessly out of date at this point), which I remember you mentioning quite some while ago, that's not true. ;)
I prefer this style and use it for all my personal projects, as I feel it makes inferring the structure glancing over the code a bit easier for me. Though, honestly, it doesn't really matter to me at this point. I just want to point out that I would hardly consider it to be a Java-only thing. The style is not only used in the K&R book, but also in many well-known C/C++ projects such as LLVM, and IIRC is also called for in Google's internal C++ style guide.
David
|
December 13, 2013 Re: D benchmark code review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On 12/13/13 9:29 AM, Manu wrote:
> On 14 December 2013 03:10, Brian Rogoff <brogoff@gmail.com
> <mailto:brogoff@gmail.com>> wrote:
>
> On Friday, 13 December 2013 at 16:40:13 UTC, Manu wrote:
>
> I'm just saying, if it's code to be compared against other
> languages, then
> it should conform to the general standards of the language.
> I've never seen D code use egyptian braces.
>
>
> You've never read TDPL.
>
>
> Published material, optimised for print. Andrei admits this. He uses C
> braces in his code.
Facebook uses Egyptian braces in its D code.
Andrei
|
Copyright © 1999-2021 by the D Language Foundation