![]() |
| | #1 |
| Hail to the king, baby. Join Date: Oct 2008 Location: Faroe Islands
Posts: 713
| D programming Here are some links: Comparison - D Programming Language 2.0 - Digital Mars Overview - D Programming Language 2.0 - Digital Mars The comparison page says that D doesn't support multi-inheritance which is true, but it uses some other techniques to do multi-heritance, so read up and don't only compare to the comparison page :P Let's start positive; D is based on C++ and claims that it improves from C++ by not having the old C slow it down, which kinda makes sense. It claims to have a proven 10% better working efficiency, meaning that projects are by theory made 10% faster. And you can read more about it. The negative part: D is new compared to C++ which is old and has been update to now and still will be, meaning it most likely has less flaws and more time to think about how the language should work/be implemented/whatever. There's more work for C++ programmers than there is for D, but without the programmers being open minded and not ignorant, this will never change :P There's more help to get with C++ and more resources to learn it. These are some basics I know about. Now start debating and be reasonable, I want open minded thinking, not ignorant thinking |
| Akkernight is offline | |
| | #2 | |||
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
The difference between C and C++ is that C++ provides more tools to the programmer. That is all. It is does not improve performance, and NO ONE ever claimed it did. C++ is not, never has been, and never will be "faster" performance wise. It is just gives the programmer more choices about how to program. Write that out on the blackboard 100 times: "All C++ does is give the programmer more choices". Quote:
Quote:
So, in fact, I say this is not really about speed at all. It is just another new language. It is about functionality. If you like the way the language works, it is good. Do not bother getting excited about it being "faster" -- if all people wanted was faster, new languages would not look like this (they are, in fact, getting slower but the hardware makes up for it, so we can afford more features, like resizable arrays* and various "safety features" for security, etc). * of course, arrays have always been "resizable", it is a question of how much work that is for the programmer.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS Last edited by MK27; 10-18-2009 at 08:40 AM. | |||
| MK27 is offline | |
| | #3 | |
| The larch Join Date: May 2006
Posts: 3,082
| I guess "slow" here measures programmer productivity: because C++ is designed to support (most) C code, it had to make compromises in language design that will slow down the programmer. As D did not set out to support C code directly, its language features could be such as to allow faster development. That said, I haven't tried D myself.
__________________ I might be wrong. Quote:
| |
| anon is offline | |
| | #4 | |
| and the hat of sweating Join Date: Aug 2007 Location: Toronto, ON
Posts: 3,120
| Quote:
__________________ "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008 | |
| cpjust is offline | |
| | #5 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
I tend to work a lot in both C and perl and obviously, things like objects, hashes, dynamic typing, operator overloading, garbage collection, dynamic arrays, etc. are extremely labour saving but they are not necessary. Occasionally I will write something in perl, then once I have the general form of the thing finalized, rewrite it in C. I am pretty sure this actually saves time vs, if I started it in C in the first place, because of all the changes and playing around with form and function during "development". For example, regular expressions are very easy to use, but expensive. Once you know exactly what you want to do and where and to what, it is usually not hard to write a C routine without regexps to do that. Classes usually boil down to typedefs and functions. But writing a routine before you have done much testing and experimentation can mean having to spend hours reworking it over and over and possibly scrapping it, something that only takes minutes with perl. And who wants to admit that some function you spent all day on is now no longer going to be used? I think the same could be said for some library functions, eg, you use them for convenience, but when you really want to optimize at the end, you can take the library right out and write some custom functions for exactly what you are doing. Again, I think "evaluating D" will be a matter of functionality. One thing that just occurred to me is that there may be an advantage to not making everything built in, however...which I guess is a C++ approach. Yes, this is why it is called "quacksort" and is not really a standard function. Eg, with perl the standard sort was qsort for a while, then enough people demonstrated that it's speed is idealized and in reality often sub-optimal, so they went back to a merge sort algorithm which is a better general purpose method. "Sorting" is a great example of a generalized task that is bound to be done better if you DO IT YOURSELF. So when someone says "look at my library, it's faster" well, great, that's probably true, that's what libraries are for. It probably is not so much about the particular language as to being about a particular library. And if you know what you are doing, it might get done BEST without any library at all. This is why I am thinking too much built-in may be a bad thing for a compiled language that wants to be about execution speed.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS Last edited by MK27; 10-18-2009 at 10:47 AM. | |
| MK27 is offline | |
| | #6 | ||||
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Quote:
Quote:
Quote:
Quote:
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way | ||||
| laserlight is offline | |
| | #7 | |||||
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Here's an example of what I mean about the "built-in" drawback: Quote:
Quote:
![]() Quote:
Quote:
C IMO is very very short on libraries and I would guess this is why (like, asm is probably "short on libraries" too). Perl has like 16000+ of them on CPAN. Hmmm.... Quote:
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS | |||||
| MK27 is offline | |
| | #8 |
| Hail to the king, baby. Join Date: Oct 2008 Location: Faroe Islands
Posts: 713
| I was talking about speed in productivity, that programmers can make projects faster, and I understood it so that it still keeps the speed of C++ :P I was also told that collages or whatever are already starting D programming classes, so maybe D really has a chance |
| Akkernight is offline | |
| | #9 |
| and the hat of sweating Join Date: Aug 2007 Location: Toronto, ON
Posts: 3,120
| If they had a Solaris compiler I might like to suggest it as an alternative to C++ at my company.
__________________ "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008 |
| cpjust is offline | |
| | #10 | |
| Guest Join Date: Aug 2001
Posts: 4,923
| Quote:
Code:
#include <iostream>
#include <algorithm>
#include <ctime>
using namespace std;
struct foo
{
foo( int value = 0 )
: value( value )
{ }
int
value;
};
struct cpp_foo_compare
{
cpp_foo_compare( foo const& lhs )
: lhs( lhs )
{ }
inline bool operator ( ) ( foo const& rhs )
{
return lhs.value == rhs.value;
}
foo const&
lhs;
};
int c_foo_compare( void const* lhs, void const* rhs )
{
return ( ( foo const* )lhs )->value == ( ( foo const* )rhs )->value;
}
void* c_find( void const* data, size_t length, size_t span, int ( * compare )( void const*, void const* ), void const* value )
{
unsigned char*
ptr = ( unsigned char* )data;
if( length % span != 0 )
return 0;
while( length-- )
{
if( compare( ptr, value ) )
return ptr;
ptr += span;
}
return 0;
}
void cpp_test( foo const* data, size_t length, foo const* value )
{
find_if( data, data + length, cpp_foo_compare( *value ) );
}
void c_test( foo const* data, size_t length, foo const* value )
{
c_find( data, length, sizeof( foo ), c_foo_compare, value );
}
void hand_coded_test( foo const* data, size_t length, foo const* value )
{
for( foo const* seq = data, * fin = data + length; seq != fin; ++seq )
if( seq->value == value->value )
break;
}
void test
(
char const* name,
foo const* data,
size_t length,
size_t iterations,
void ( * function )( foo const*, size_t, foo const* ),
foo const* value
)
{
clock_t
start,
stop;
start = clock( );
size_t
count = iterations;
while( count-- )
function( data, length, value );
stop = clock( );
cout << "Completed " << iterations << " iterations with function '" << name
<< "' in " << ( double( stop - start ) / CLK_TCK ) << " seconds" << endl;
}
int main( void )
{
size_t const
length = 1024,
iterations = 131072;
foo
data[ length ];
int
target = 3114;
data[ length - 1 ].value = target;
foo
bar( target );
test( "hand_coded_test", data, length, iterations, hand_coded_test, &bar );
test( "c_test", data, length, iterations, c_test, &bar );
test( "cpp_test", data, length, iterations, cpp_test, &bar );
return 0;
}
Last edited by Sebastiani; 10-18-2009 at 05:04 PM. Reason: just for the hell of it | |
| Sebastiani is offline | |
| | #11 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
Which way do you want to write? I am not saying I'd prefer the later, but it is kind of a "I want my cake to eat it too" contest when you start discussing convience as performance advantage methinks. Maybe it will win! This seems to me a desire to avoid "subjective" discussions of "language design" and cower in an idealized world of dubious benchmarks and potentially over abstracted abstractions ![]() I guess part of what got me going here was Akkernight's presentation of D being about "speed" and that 1) execution speed does not seem to be a particular goal of the project any more than any other PR work I have seen on a language. 2) by sticking to a C/C++ comparison, they effectively COMPLETELY DODGE the real issue of development "speed". AFAICT, this is like saying you get better gas mileage than a M1A tank. Not that this writes anything off, I just think the most significant aspects of language design are avoided.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS | |
| MK27 is offline | |
| | #12 |
| Guest Join Date: Aug 2001
Posts: 4,923
| I was just trying to prove that C++ doesn't inherently introduce "unnecessary operations" (and in fact can even be more efficient than a "hand-coded" implementation). The bottom line is that C simply doesn't have the proper facilities for writing generic, reusable software, and can never compete with C++ in that respect (nor D, for that matter). Not that you can't write decent software with C, but it's just much more difficult and a whole lot more work. |
| Sebastiani is offline | |
| | #13 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS | |
| MK27 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|