www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is D more cryptic than C++?

reply "Abrahm" <abe2007 nospam.net> writes:
I get the feeling that it is from reading the threads in here. Is there 
somewhere that has non-trivial D and C++ code that does the same thing, 
side by side, so that I can evaluate D better? Links if you got 'em 
please. Maybe even a small entire application would be good to download 
and perusal. This request really calls for code that is not part of D, so 
the D front end compiler and the like is inappropriate. 
Nov 29 2011
next sibling parent reply "Adam Wilson" <flyboynw gmail.com> writes:
On Tue, 29 Nov 2011 22:30:21 -0800, Abrahm <abe2007 nospam.net> wrote:

 I get the feeling that it is from reading the threads in here. Is there
 somewhere that has non-trivial D and C++ code that does the same thing,
 side by side, so that I can evaluate D better? Links if you got 'em
 please. Maybe even a small entire application would be good to download
 and perusal. This request really calls for code that is not part of D, so
 the D front end compiler and the like is inappropriate.

Well, i'd say that this forum can get hypertechnical in a hurry; a lot of the conversation on this forum is directed at making D better, and because of that, threads tend to run down arcane rabbit holes that use code that you will probably never touch. I wouldn't really hold up the threads here as an example of D's readability. In my experience D is roughly analogous to C# in terms of crypticness and readability, I am here doing long-term evaluations of D as a replacement for C# on my employers projects as we may face power constraints in the future that preclude the use of a JIT'ed language. So far, I like what I've seen. As for non-trivial code, there are a number of FOSS project lying around, but I don't know of any that have parallel D and C++ implementations; usually the developers have more interesting things to be working on... The best you'll be able to do is probably this page: http://www.d-programming-language.org/cpptod.html It includes some very tricky examples surrounding templates towards the bottom. -- Adam Wilson Project Coordinator The Horizon Project http://www.thehorizonproject.org/
Nov 30 2011
parent reply "Abrahm" <abe2007 nospam.net> writes:
"Adam Wilson" <flyboynw gmail.com> wrote in message 
news:op.v5q2zgji707hn8 invictus.skynet.com...
 On Tue, 29 Nov 2011 22:30:21 -0800, Abrahm <abe2007 nospam.net> wrote:

 I get the feeling that it is from reading the threads in here. Is 
 there
 somewhere that has non-trivial D and C++ code that does the same 
 thing,
 side by side, so that I can evaluate D better? Links if you got 'em
 please. Maybe even a small entire application would be good to 
 download
 and perusal. This request really calls for code that is not part of D, 
 so
 the D front end compiler and the like is inappropriate.

Well, i'd say that this forum can get hypertechnical in a hurry; a lot of the conversation on this forum is directed at making D better, and because of that, threads tend to run down arcane rabbit holes that use code that you will probably never touch. I wouldn't really hold up the threads here as an example of D's readability.

I'll check out the learn ng next time. Maybe that is then more focused on the higher-level constructs of the language.
 In my experience D is roughly analogous to C# in terms of crypticness 
 and  readability, I am here doing long-term evaluations of D as a 
 replacement  for C# on my employers projects as we may face power 
 constraints in the  future that preclude the use of a JIT'ed language. 
 So far, I like what  I've seen.

But I thought that C# could be precompiled in some fashion? In either case, going from C# to D seems like a major move. Not so much the move but a too broadly defined application that it could actually be a good fit with both languages.
 As for non-trivial code, there are a number of FOSS project lying 
 around,

Recommendations of which to peek at? A link? SourceForge?
 but I don't know of any that have parallel D and C++ implementations; 
 usually the developers have more interesting things to be working on... 
 The best you'll be able to do is probably this page: 
 http://www.d-programming-language.org/cpptod.html It includes some very 
 tricky examples surrounding templates towards the bottom.

Nov 30 2011
next sibling parent Dejan Lekic <dejan.lekic gmail.com> writes:
*Any* project on http://wwww.dsource.org ...
Nov 30 2011
prev sibling parent reply bcs <bcs example.com> writes:
On 11/30/2011 03:36 AM, Abrahm wrote:
 "Adam Wilson"<flyboynw gmail.com>  wrote in message
 news:op.v5q2zgji707hn8 invictus.skynet.com...
 In my experience D is roughly analogous to C# in terms of crypticness
 and  readability, I am here doing long-term evaluations of D as a
 replacement  for C# on my employers projects as we may face power
 constraints in the  future that preclude the use of a JIT'ed language.
 So far, I like what  I've seen.

But I thought that C# could be precompiled in some fashion? In either case, going from C# to D seems like a major move. Not so much the move but a too broadly defined application that it could actually be a good fit with both languages.

A while back I built a tool to do automatic translation of C# to D1. Aside from a small number of language features, a large number of libraries and a significant amount of freedom w.r.t. formatting, the darn thing worked! (Debugging it was "fun", as in running diffs of million+ line execution traces. But then I'm crazy enough to do that!) Up shot is that for some applications, those languages aren't really that different.
Nov 30 2011
parent reply "Abrahm" <abe2007 nospam.net> writes:
"bcs" <bcs example.com> wrote in message 
news:jb6vke$2f6o$1 digitalmars.com...
 On 11/30/2011 03:36 AM, Abrahm wrote:
 "Adam Wilson"<flyboynw gmail.com>  wrote in message
 news:op.v5q2zgji707hn8 invictus.skynet.com...
 In my experience D is roughly analogous to C# in terms of crypticness
 and  readability, I am here doing long-term evaluations of D as a
 replacement  for C# on my employers projects as we may face power
 constraints in the  future that preclude the use of a JIT'ed 
 language.
 So far, I like what  I've seen.

But I thought that C# could be precompiled in some fashion? In either case, going from C# to D seems like a major move. Not so much the move but a too broadly defined application that it could actually be a good fit with both languages.

A while back I built a tool to do automatic translation of C# to D1.

Oh, so you prefer the easy tasks then! Noted. (Embedded sarcasm defined: Try going from D to C#! A very much harder, end of the chapter excercise).
 Aside from a small number of language features, a large number of 
 libraries and a significant amount of freedom w.r.t. formatting, the 
 darn thing worked!

Well, don't make it out to be an accomplishment of the "harder" end-of-chapter excercises when it is actually in the easy section.
 (Debugging it was "fun", as in running diffs of million+ line execution 
 traces. But then I'm crazy enough to do that!)

Your need for "praise" and whatever, noted. I can't help you with that (not that I don't want to or that your need isn't an indicator of something wrong).
 Up shot is that for some applications, those languages aren't really 
 that different.

That's really good. You're well on your way to completing the coursework. Gold star. Keep up the good work.
Nov 30 2011
parent reply bcs <bcs example.com> writes:
On 11/30/2011 08:47 PM, Abrahm wrote:
 "bcs"<bcs example.com>  wrote in message
 A while back I built a tool to do automatic translation of C# to D1.

Oh, so you prefer the easy tasks then! Noted. (Embedded sarcasm defined: Try going from D to C#! A very much harder, end of the chapter excercise).

The direction was not by choice, we had a C# code base a need to run on Linux and a good reason to not us Mono.
 Aside from a small number of language features, a large number of
 libraries and a significant amount of freedom w.r.t. formatting, the
 darn thing worked!

Well, don't make it out to be an accomplishment of the "harder" end-of-chapter excercises when it is actually in the easy section.

I never claimed that it was complex! In fact I, my point is better supported by it being simple.
 (Debugging it was "fun", as in running diffs of million+ line execution
 traces. But then I'm crazy enough to do that!)

Your need for "praise" and whatever, noted. I can't help you with that (not that I don't want to or that your need isn't an indicator of something wrong).

I'm not bragging, Even if I was, the only thing I could brag about there would be bull-headedness. It would sort of be like you bragging about how hard it is to find adjective that describe you that are usable in polite company.
 Up shot is that for some applications, those languages aren't really
 that different.

That's really good. You're well on your way to completing the coursework. Gold star. Keep up the good work.

You *really* have zero idea what my point is don't you?
Nov 30 2011
next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 12/01/2011 06:34 AM, bcs wrote:
 On 11/30/2011 08:47 PM, Abrahm wrote:
 "bcs"<bcs example.com> wrote in message
 A while back I built a tool to do automatic translation of C# to D1.

Oh, so you prefer the easy tasks then! Noted. (Embedded sarcasm defined: Try going from D to C#! A very much harder, end of the chapter excercise).

The direction was not by choice, we had a C# code base a need to run on Linux and a good reason to not us Mono.

Nice! =D. How well does the resulting C#-style D code perform?
 Aside from a small number of language features, a large number of
 libraries and a significant amount of freedom w.r.t. formatting, the
 darn thing worked!

Well, don't make it out to be an accomplishment of the "harder" end-of-chapter excercises when it is actually in the easy section.

I never claimed that it was complex! In fact I, my point is better supported by it being simple.
 (Debugging it was "fun", as in running diffs of million+ line execution
 traces. But then I'm crazy enough to do that!)

Your need for "praise" and whatever, noted. I can't help you with that (not that I don't want to or that your need isn't an indicator of something wrong).

I'm not bragging, Even if I was, the only thing I could brag about there would be bull-headedness. It would sort of be like you bragging about how hard it is to find adjective that describe you that are usable in polite company.
 Up shot is that for some applications, those languages aren't really
 that different.

That's really good. You're well on your way to completing the coursework. Gold star. Keep up the good work.

You *really* have zero idea what my point is don't you?

I think he might actually get your point. Don't feed the troll ;).
Dec 01 2011
parent bcs <bcs example.com> writes:
On 12/01/2011 08:02 AM, Timon Gehr wrote:
 On 12/01/2011 06:34 AM, bcs wrote:
 On 11/30/2011 08:47 PM, Abrahm wrote:
 "bcs"<bcs example.com> wrote in message
 A while back I built a tool to do automatic translation of C# to D1.

Oh, so you prefer the easy tasks then! Noted. (Embedded sarcasm defined: Try going from D to C#! A very much harder, end of the chapter excercise).

The direction was not by choice, we had a C# code base a need to run on Linux and a good reason to not us Mono.

Nice! =D. How well does the resulting C#-style D code perform?

I don't recall if we ever ran per test. I do remember that wasn't a huge amount slower. I'm also not sure we ever finished it, but if not, it was for lack of resources not any technical constraint.
Dec 01 2011
prev sibling parent Dejan Lekic <dejan.lekic gmail.com> writes:
 
 You *really* have zero idea what my point is don't you?

I think Abrahm is a bot or someone who is constantly high. But the first seems a more plausable explanation.
Dec 01 2011
prev sibling next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Abrahm:

D is a bigger and more complex language compared to Java. And D gives more
freedom compared to Java, so it's a bit easier to write D2 code that's
unreadable compared to Java. But compared to C++ I think D code is a bit less
cryptic because some of idioms of good C++ are language constructs in D, so
they are more easy to see and (hopefully) better enforced by the language. I've
seen both unreadable Python code and well readable Perl5 code so in the end
it's a lot a matter of how you use it.


 I get the feeling that it is from reading the threads in here. Is there 
 somewhere that has non-trivial D and C++ code that does the same thing, 
 side by side, so that I can evaluate D better?

I suggest Rosettacode, it contains hundreds of "Tasks", with their translations in many languages, like C++ and D2: http://rosettacode.org/wiki/Category:C%2B%2B http://rosettacode.org/wiki/Category:D There are draft Tasks too: http://rosettacode.org/wiki/Category:Draft_Programming_Tasks Few people are working hard to create hundreds of well written D2 implementations of those. They are tiny programs, so if you look for longer C++ vs D comparisons you will need to look elsewhere. Bye, bearophile
Nov 30 2011
parent reply "Abrahm" <abe2007 nospam.net> writes:
"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:jb4rgv$1bi1$1 digitalmars.com...
 Abrahm:

 D is a bigger and more complex language compared to Java. And D gives 
 more freedom compared to Java, so it's a bit easier to write D2 code 
 that's unreadable compared to Java. But compared to C++ I think D code 
 is a bit less cryptic because some of idioms of good C++ are language 
 constructs in D, so they are more easy to see and (hopefully) better 
 enforced by the language. I've seen both unreadable Python code and 
 well readable Perl5 code so in the end it's a lot a matter of how you 
 use it.


 I get the feeling that it is from reading the threads in here. Is 
 there
 somewhere that has non-trivial D and C++ code that does the same 
 thing,
 side by side, so that I can evaluate D better?

I suggest Rosettacode, it contains hundreds of "Tasks", with their translations in many languages, like C++ and D2: http://rosettacode.org/wiki/Category:C%2B%2B http://rosettacode.org/wiki/Category:D There are draft Tasks too: http://rosettacode.org/wiki/Category:Draft_Programming_Tasks Few people are working hard to create hundreds of well written D2 implementations of those. They are tiny programs, so if you look for longer C++ vs D comparisons you will need to look elsewhere.

Alright. I probably asked for more than I need anyway with the "side by side" thing. An easy to grok small app, but non-trivial and using a number of D features would be ideal.
Nov 30 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Abrahm:

 An easy to grok small app, but non-trivial and using a 
 number of D features would be ideal. 

I see. What kind of app do you prefer? Bye, bearophile
Nov 30 2011
parent reply "Abrahm" <abe2007 nospam.net> writes:
"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:jb56j2$21g4$1 digitalmars.com...
 Abrahm:

 An easy to grok small app, but non-trivial and using a
 number of D features would be ideal.

I see. What kind of app do you prefer?

Anything high-level. A weird request in a systems language ng? I program desktop apps in C++, but mostly am working on libraries (containers and such) lately. So, something with a GUI interface maybe? A database app? Or doesn't anyone do that kind of thing with D? A small commandline utility would work too. Or even a server app. Obviously nothing realtime or device driverish. Preferably something non-scientific so as not having to grok the domain abstractions as well as the language.
Nov 30 2011
parent simendsjo <simendsjo gmail.com> writes:
On 30.11.2011 13:20, Abrahm wrote:
 A small commandline
 utility would work too.

Take a look at rdmd: https://github.com/D-Programming-Language/tools
Nov 30 2011
prev sibling next sibling parent reply Peter Alexander <peter.alexander.au gmail.com> writes:
On 30/11/11 6:30 AM, Abrahm wrote:
 I get the feeling that it is from reading the threads in here. Is there
 somewhere that has non-trivial D and C++ code that does the same thing,
 side by side, so that I can evaluate D better? Links if you got 'em
 please. Maybe even a small entire application would be good to download
 and perusal. This request really calls for code that is not part of D, so
 the D front end compiler and the like is inappropriate.

If you care about non-trivial programs and want to compare D with C++, here's all you need to know: No header files - Seriously, this makes all the difference. Several times I have quit D to go back to C++, then I remember header files. I use C++ at my day job, so I am used to having to maintain header files, but if you switch from D to C++, you WILL feel the pain. Range-based foreach for integral types - foreach (i; 0..n) vs. for (int i = 0; i < n; ++i) It's a small thing, but makes all the difference. Sorting on some member or member function. - sort!("a.weight < b.weight")(things); vs. sort(things.begin(), things.end(), [](Thing const& a, Thing const& b) { return a.weight < b.weight; }); And that's if you're using C++11. Huge amounts of pain if you're not. In general, things just work and do what you expect without syntactic nonsense. If you use templates a lot then you'll definitely notice a difference there.
Nov 30 2011
next sibling parent reply "Abrahm" <abe2007 nospam.net> writes:
"Peter Alexander" <peter.alexander.au gmail.com> wrote in message 
news:jb4sjp$1dnr$1 digitalmars.com...
 On 30/11/11 6:30 AM, Abrahm wrote:
 I get the feeling that it is from reading the threads in here. Is 
 there
 somewhere that has non-trivial D and C++ code that does the same 
 thing,
 side by side, so that I can evaluate D better? Links if you got 'em
 please. Maybe even a small entire application would be good to 
 download
 and perusal. This request really calls for code that is not part of D, 
 so
 the D front end compiler and the like is inappropriate.

If you care about non-trivial programs and want to compare D with C++, here's all you need to know: No header files

OK, but I was considering the syntax-level rather than the process-level things. Hence my use of 'cryptic'. I wasn't looking for an overall assessment of developing software with D vs. with C++.
 - Seriously, this makes all the difference. Several times I have quit D 
 to go back to C++, then I remember header files. I use C++ at my day 
 job, so I am used to having to maintain header files, but if you switch 
 from D to C++, you WILL feel the pain.

Having syntax-folding editors these days has caused me to lately leave everything in the C++ header files and only move code in .cpp files when there are circular references or when I want to hide something from library USERS. IOW, let the compiler figure out that most of the code can't be inlined. Care to comment on how the "only header files in C++"strategy compares to "no header files in D"? Seems similar to me.
 Range-based foreach for integral types
 - foreach (i; 0..n)
   vs.
   for (int i = 0; i < n; ++i)
   It's a small thing, but makes all the difference.

Even more minor than you show above for C++11 has improvements over the traditional 'for' loop and the 'auto' keyword allows building similar constructs (haven't used my 'foreach' lately so I forget if it was just for containers, but probably).
 Sorting on some member or member function.
 - sort!("a.weight < b.weight")(things);
   vs.
   sort(things.begin(), things.end(), [](Thing const& a, Thing const& b) 
 { return a.weight < b.weight; });
   And that's if you're using C++11. Huge amounts of pain if you're not.

I don't think I like that. D's 'sort' is some kind of construct instead of a function? Not intuitive at all. Seemingly incorrect from a design standpoint (but I'm not thinking about it heavily).
 In general, things just work and do what you expect without syntactic 
 nonsense. If you use templates a lot then you'll definitely notice a 
 difference there.

I avoid using templates for the most part except where they clearly make sense (containers, other things). Sometimes even if a template will only be used to generate 2 distinct versions, I use it to ensure some delicate code will be only in one place (the template), but in general, most of my templates make sense for a lot of types.
Nov 30 2011
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Abrahm:

 I don't think I like that. D's 'sort' is some kind of construct instead 
 of a function?

It's essentially a function template.
 Not intuitive at all. Seemingly incorrect from a design 
 standpoint (but I'm not thinking about it heavily).

Better getting used to that kind of D code :-) Bye, bearophile
Nov 30 2011
parent reply "Abrahm" <abe2007 nospam.net> writes:
"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:jb566l$20rr$1 digitalmars.com...
 Abrahm:

 I don't think I like that. D's 'sort' is some kind of construct 
 instead
 of a function?

It's essentially a function template.

OK. Whatever it is though, it doesn't look like "language proper" material. That is, I'll relegate it to libraryland.
 Not intuitive at all. Seemingly incorrect from a design
 standpoint (but I'm not thinking about it heavily).

Better getting used to that kind of D code :-)

Uh oh, is that a warning to the weary? Should I look for a post called "D Quirks"? If you want to make such a list, great, but if you do, please try to go from high-level things to esoteric things so those not concerned about the latter don't have to wade through them or figure out in which classification they belong. Looks like a good topic for a new thread: D Quirks. I'm too lazy to start a new thread right now.
Nov 30 2011
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 11/30/2011 01:14 PM, Abrahm wrote:
 "bearophile"<bearophileHUGS lycos.com>  wrote in message
 news:jb566l$20rr$1 digitalmars.com...
 Abrahm:

 I don't think I like that. D's 'sort' is some kind of construct
 instead
 of a function?

It's essentially a function template.

OK. Whatever it is though, it doesn't look like "language proper" material. That is, I'll relegate it to libraryland.

Not sure what you are talking about, but: It is in the library and does not have any special language support.
Nov 30 2011
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 11/30/2011 12:57 PM, Abrahm wrote:
 "Peter Alexander"<peter.alexander.au gmail.com>  wrote in message
 news:jb4sjp$1dnr$1 digitalmars.com...
 On 30/11/11 6:30 AM, Abrahm wrote:
 I get the feeling that it is from reading the threads in here. Is
 there
 somewhere that has non-trivial D and C++ code that does the same
 thing,
 side by side, so that I can evaluate D better? Links if you got 'em
 please. Maybe even a small entire application would be good to
 download
 and perusal. This request really calls for code that is not part of D,
 so
 the D front end compiler and the like is inappropriate.

If you care about non-trivial programs and want to compare D with C++, here's all you need to know: No header files

OK, but I was considering the syntax-level rather than the process-level things. Hence my use of 'cryptic'. I wasn't looking for an overall assessment of developing software with D vs. with C++.
 - Seriously, this makes all the difference. Several times I have quit D
 to go back to C++, then I remember header files. I use C++ at my day
 job, so I am used to having to maintain header files, but if you switch
 from D to C++, you WILL feel the pain.

Having syntax-folding editors these days has caused me to lately leave everything in the C++ header files and only move code in .cpp files when there are circular references or when I want to hide something from library USERS. IOW, let the compiler figure out that most of the code can't be inlined. Care to comment on how the "only header files in C++"strategy compares to "no header files in D"? Seems similar to me.

You can use interface files that just contain the relevant declarations, there is no "no header files in D" policy. But it is currently completely up to the programmer to keep header and implementation in sync. I haven't needed to use those so far, because the compiler is so fast that usually just rebuilding the whole project is quicker than trying to engage in a separate compilation model. I am not sure how large a project needs to grow until using a few interface files actually gives you a performance benefit.
 Range-based foreach for integral types
 - foreach (i; 0..n)
    vs.
    for (int i = 0; i<  n; ++i)
    It's a small thing, but makes all the difference.

Even more minor than you show above for C++11 has improvements over the traditional 'for' loop and the 'auto' keyword allows building similar constructs (haven't used my 'foreach' lately so I forget if it was just for containers, but probably).

This is about the best you can get in C++11: for(auto i : iota(0,n)) {} It is certainly more cryptic than foreach(i;0..n) {} It is a little bit longer too. This one of the constructs that occur most often in procedural code, so the few additional key strokes add up.
 Sorting on some member or member function.
 - sort!("a.weight<  b.weight")(things);
    vs.
    sort(things.begin(), things.end(), [](Thing const&  a, Thing const&  b)
 { return a.weight<  b.weight; });
    And that's if you're using C++11. Huge amounts of pain if you're not.

I don't think I like that. D's 'sort' is some kind of construct instead of a function? Not intuitive at all. Seemingly incorrect from a design standpoint (but I'm not thinking about it heavily).

D's sort is a template function, just like C++'s sort. It is just that D templates can take string arguments and it is possible to generate D code from strings. This makes the D version more concise and less cluttered. This is an alternative that uses a delegate literal (it solves a similar problem as C++11 lambda functions) sort!((a,b){return a.weight<b.weight;})(things);
Nov 30 2011
prev sibling parent reply Jesse Phillips <jessekphillips+d gmail.com> writes:
What bearophile was referring to was the use of templates is common. D's 
templates have the advantage of being easier on the eyes and more 
powerful (with the inclusion of 'static if' in the language).

On Wed, 30 Nov 2011 06:14:34 -0600, Abrahm wrote:

 "bearophile" <bearophileHUGS lycos.com> wrote in message
 news:jb566l$20rr$1 digitalmars.com...
 Abrahm:

 I don't think I like that. D's 'sort' is some kind of construct
 instead of a function?

It's essentially a function template.

OK. Whatever it is though, it doesn't look like "language proper" material. That is, I'll relegate it to libraryland.
 Not intuitive at all. Seemingly incorrect from a design standpoint
 (but I'm not thinking about it heavily).

Better getting used to that kind of D code :-)

"D Quirks"? If you want to make such a list, great, but if you do, please try to go from high-level things to esoteric things so those not concerned about the latter don't have to wade through them or figure out in which classification they belong. Looks like a good topic for a new thread: D Quirks. I'm too lazy to start a new thread right now.

Nov 30 2011
next sibling parent reply "Abrahm" <abe2007 nospam.net> writes:
"Jesse Phillips" <jessekphillips+d gmail.com> wrote in message 
news:jb6qfv$1kut$1 digitalmars.com...
 What bearophile was referring to was the use of templates is common.

Are you sure about that? What say you Bear?
 D's
 templates have the advantage of being easier on the eyes and more
 powerful (with the inclusion of 'static if' in the language).

Having "come from" C++land, and knowing what some people do with it, making it EASIER to apply templates does not seem necessarily a good thing to me. (Ref: template metaprogramming). That said, does your statement above about D's template machinery being "powerful" etc., mean "it's easier to do template metaprogramming in D"? If so, I, personally, do not find that any asset at all (though I know some surely will, for there have been books written on that "abhorrence").
 On Wed, 30 Nov 2011 06:14:34 -0600, Abrahm wrote:

 "bearophile" <bearophileHUGS lycos.com> wrote in message
 news:jb566l$20rr$1 digitalmars.com...
 Abrahm:

 I don't think I like that. D's 'sort' is some kind of construct
 instead of a function?

It's essentially a function template.

OK. Whatever it is though, it doesn't look like "language proper" material. That is, I'll relegate it to libraryland.
 Not intuitive at all. Seemingly incorrect from a design standpoint
 (but I'm not thinking about it heavily).

Better getting used to that kind of D code :-)

"D Quirks"? If you want to make such a list, great, but if you do, please try to go from high-level things to esoteric things so those not concerned about the latter don't have to wade through them or figure out in which classification they belong. Looks like a good topic for a new thread: D Quirks. I'm too lazy to start a new thread right now.


Nov 30 2011
next sibling parent deadalnix <deadalnix gmail.com> writes:
Le 01/12/2011 05:32, Abrahm a écrit :
 "Jesse Phillips"<jessekphillips+d gmail.com>  wrote in message
 news:jb6qfv$1kut$1 digitalmars.com...
 What bearophile was referring to was the use of templates is common.

Are you sure about that? What say you Bear?
 D's
 templates have the advantage of being easier on the eyes and more
 powerful (with the inclusion of 'static if' in the language).

Having "come from" C++land, and knowing what some people do with it, making it EASIER to apply templates does not seem necessarily a good thing to me. (Ref: template metaprogramming). That said, does your statement above about D's template machinery being "powerful" etc., mean "it's easier to do template metaprogramming in D"? If so, I, personally, do not find that any asset at all (though I know some surely will, for there have been books written on that "abhorrence").

It means basically that many things are easier to do, AND, many thing that cannot be done in C++ metaprogramming can be done in D. Your assertion about metaprogramming isn't quite true IMO. Template are a good thing and are usually overcomplicating stuff is C++. But the source of this complication is more C++ language itself than what metaprogramming is about. Making it easier to use IS a good thing. Consider what auto, static if and compile time reflection can do for you when it comes to metaprogramming. This is amazing.
Dec 01 2011
prev sibling next sibling parent dsimcha <dsimcha yahoo.com> writes:
On 11/30/2011 11:32 PM, Abrahm wrote:
 "Jesse Phillips"<jessekphillips+d gmail.com>  wrote in message
 news:jb6qfv$1kut$1 digitalmars.com...
 What bearophile was referring to was the use of templates is common.

Are you sure about that? What say you Bear?
 D's
 templates have the advantage of being easier on the eyes and more
 powerful (with the inclusion of 'static if' in the language).

Having "come from" C++land, and knowing what some people do with it, making it EASIER to apply templates does not seem necessarily a good thing to me. (Ref: template metaprogramming). That said, does your statement above about D's template machinery being "powerful" etc., mean "it's easier to do template metaprogramming in D"? If so, I, personally, do not find that any asset at all (though I know some surely will, for there have been books written on that "abhorrence").

A lot of people from C++ backgrounds say this. What they miss is that template metaprogramming in C++ is so ugly because the language wasn't designed for it. In D you can do readable template metaprogramming.
Dec 01 2011
prev sibling parent bcs <bcs example.com> writes:
On 11/30/2011 08:32 PM, Abrahm wrote:
 "Jesse Phillips"<jessekphillips+d gmail.com>  wrote in message
 news:jb6qfv$1kut$1 digitalmars.com...
 What bearophile was referring to was the use of templates is common.

Are you sure about that? What say you Bear?
 D's
 templates have the advantage of being easier on the eyes and more
 powerful (with the inclusion of 'static if' in the language).

Having "come from" C++land, and knowing what some people do with it, making it EASIER to apply templates does not seem necessarily a good thing to me. (Ref: template metaprogramming). That said, does your statement above about D's template machinery being "powerful" etc., mean "it's easier to do template metaprogramming in D"? If so, I, personally, do not find that any asset at all (though I know some surely will, for there have been books written on that "abhorrence").

Most of the argument for template metaprogramming being a bad thing in C++ are just flat not valid in D. That is not by chance. While designing the D template system they (including the guy who wrote one of these books you mention) took as look at what people actually want to do with all that abhorrence and provided a sane way to do it. With one 10th the complexity, D can do 10 times as much. As a specific example, one of the most abhorrent bits of D template code I've worked with is a compile time parser generate that, at compile time, parses a string into an AST describing the grammar that it will then generate a recursive decent parser to parse. All in under 1-2kLOC. Version 2 was going to include the ability to automatically reactor out left recursion so that it could handle the D grammar as documented. Even at the level of complexity, it wasn't really that hard to comprehend. The same end effect is available in C++ but takes a megabyte and a half of header files.
Dec 01 2011
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Wednesday, November 30, 2011 22:32:51 Abrahm wrote:
 "Jesse Phillips" <jessekphillips+d gmail.com> wrote in message
 news:jb6qfv$1kut$1 digitalmars.com...
 
 What bearophile was referring to was the use of templates is common.

Are you sure about that? What say you Bear?
 D's
 templates have the advantage of being easier on the eyes and more
 powerful (with the inclusion of 'static if' in the language).

Having "come from" C++land, and knowing what some people do with it, making it EASIER to apply templates does not seem necessarily a good thing to me. (Ref: template metaprogramming). That said, does your statement above about D's template machinery being "powerful" etc., mean "it's easier to do template metaprogramming in D"? If so, I, personally, do not find that any asset at all (though I know some surely will, for there have been books written on that "abhorrence").

Andrei Alexadrescu, the author of Modern C++ (_the_ book on template metaprogramming), is one of the leaders in the D community. There is no question that D's templates are intended to be able to do powerful metaprogramming. However, much of what would be truly disgusting in C++ is incredibly simple in D such that it isn't an abhorrence at all. You don't have to constantly fight templates to be able to do anything fancy. Instead, the resulting code is much more intuitive and maintainable. However, aside from template constraints, the primary use of templates in D (at least in the standard library) is generally related to simply making functions more generic, not trying to do excessively complicated stuff. Templates in D are absolutely fantastic in comparison to C++'s templates and are a _major_ boon IMHO. http://stackoverflow.com/questions/7300298/metaprogramming-in-c-and-in-d - Jonathan M Davis
Nov 30 2011
prev sibling next sibling parent reply Dejan Lekic <dejan.lekic gmail.com> writes:
I think there is no need for a whole app. Take *any* D source code, and 
write the same code in C++, and you will understand.

A nice summary about D: http://www.d-programming-language.org/new/
Nov 30 2011
parent reply "Abrahm" <abe2007 nospam.net> writes:
"Dejan Lekic" <dejan.lekic gmail.com> wrote in message 
news:jb5gmk$2i10$1 digitalmars.com...
 I think there is no need for a whole app.

Well now. That's an interesting note. Perhaps there aren't many examples of anything in D? (I am always and first, a sceptic).
 Take *any* D source code,

How much of that is there to be had?
 and
 write the same code in C++, and you will understand.

Wrong answer. It borders on trying to bullshit me. Just don't do that. (You have been warned).
 A nice summary about D: http://www.d-programming-language.org/new/

I am seeking example code, not an owner's manual.
Nov 30 2011
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
Abrahm Wrote:
 Take *any* D source code,


About 200,000 lines making up the stdlib + runtime. I've also written over 100,000 lines for my work.
Nov 30 2011
prev sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 11/30/2011 09:00 PM, Abrahm wrote:
 "Dejan Lekic"<dejan.lekic gmail.com>  wrote in message
 news:jb5gmk$2i10$1 digitalmars.com...

 write the same code in C++, and you will understand.

Wrong answer. It borders on trying to bullshit me. Just don't do that. (You have been warned).

And I have informed you before: you don't know C++ enough to compare with D. You made this clear during your couple of saner moments on this forum. You have a limited understanding of C++. For example you don't understand RAII yet.
 I am seeking example code, not an owner's manual.

Here is something that members of the ddili forum had started writing over 2 years ago: http://code.google.com/p/trileri/ It is a library that defines the concept of an alphabet. From one of the unittests: assert(yazı.büyüğü == "ALİ JIM"); assert(yazı.küçüğü == "ali jim"); I have been bringing it up to date with the changes in dmd. I am currently adding range support to it and changing its design as I look at it with fresher eyes. What do you think? Ali
Dec 01 2011
prev sibling next sibling parent Maxim Fomin <maxim maxim-fomin.ru> writes:
2011/11/30 Abrahm <abe2007 nospam.net>:
 I get the feeling that it is from reading the threads in here. Is there
 somewhere that has non-trivial D and C++ code that does the same thing,
 side by side, so that I can evaluate D better? Links if you got 'em
 please. Maybe even a small entire application would be good to download
 and perusal. This request really calls for code that is not part of D, so
 the D front end compiler and the like is inappropriate.

Considering his last posts i think he is a troll.
Dec 01 2011
prev sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--bcaec5304f6978b94404b30a5e23
Content-Type: text/plain; charset=ISO-8859-1

2011/12/1 Dejan Lekic <dejan.lekic gmail.com>

 You *really* have zero idea what my point is don't you?

I think Abrahm is a bot or someone who is constantly high. But the first seems a more plausable explanation.

yeah, I also noticed some strange problems with him. Posting over 10 messages in a row with literally no interesting information is not really useful/normal. He did sometime bring up a good point though, I just can't remember when. and to answer the question he posed in the beginning: take a look at the code of adam rupe involving web stuff, it's a great example of d's capabilities. --bcaec5304f6978b94404b30a5e23 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">2011/12/1 Dejan Lekic <span dir=3D"ltr">&lt;<a h= ref=3D"mailto:dejan.lekic gmail.com">dejan.lekic gmail.com</a>&gt;</span><b= r><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:= 1px #ccc solid;padding-left:1ex;"> <div class=3D"im"><br> &gt;<br> &gt; You *really* have zero idea what my point is don&#39;t you?<br> <br> </div>I think Abrahm is a bot or someone who is constantly high. But the fi= rst<br> seems a more plausable explanation.<br> </blockquote></div><br>yeah, I also noticed some strange problems with him.= Posting over 10 messages in a row with literally no interesting informatio= n is not really useful/normal. He did sometime bring up a good point though= , I just can&#39;t remember when.<br> <br>and to answer the question he posed in the beginning:<br>take a look at= the code of adam rupe involving web stuff, it&#39;s a great example of d&#= 39;s capabilities.<br> --bcaec5304f6978b94404b30a5e23--
Dec 01 2011