1,384 reputation
79
bio website github.com/jmdavis
location San Jose, CA
age 32
visits member for 4 years, 1 month
seen Dec 7 at 8:55

Nov
18
awarded  Yearling
Jun
19
awarded  Nice Answer
Dec
20
comment Can modern OO languages compete with C++'s array store performance?
@supercat If you want to write a function which sorts arbitrary types, then templatize it. e.g. dlang.org/phobos/std_algorithm.html#sort
Nov
18
awarded  Yearling
Nov
18
awarded  Yearling
Aug
6
awarded  Good Answer
Jan
18
awarded  Nice Answer
Jan
17
comment Can modern OO languages compete with C++'s array store performance?
@BenVoigt Then the online docs need to be updated. They aren't always 100% up-to-date unfortunately. The conversion will work with const U[], since then you can't assign the wrong type to the array's elements, but T[] definitely does not convert to U[] as long as U[] is mutable. Allowing covariant arrays like it did before was a serious design flaw which has now been corrected.
Jan
17
awarded  Commentator
Jan
17
comment Can modern OO languages compete with C++'s array store performance?
@Jesse And when else would you expect exceptions but at runtime? The problem isn't code which throws exceptions at runtime - there are plenty of cases where that makes good sense - the problem is code which is guaranteed to be wrong which doesn't get statically caught by the compiler but instead results in an exception at runtime.
Jan
17
answered Can modern OO languages compete with C++'s array store performance?
Nov
18
awarded  Yearling
Sep
14
comment Why is the 'final' keyword used so little in the industry?
Yes, it's a common design, but OO programming isn't necessarily looking to have everything in an object be mutable. OO programming deals with how you organize your code not necessarily whether any of it's mutable or not. Data is organized into objects which have functions on them which then operate on the data as one entity. The internals of that object are then encapsulated and aren't generally relevant to those using it. Much of the time, variables are mutable (and in Java, final is crippled enough that it doesn't add much anyway), but OO does not strive or require that they be mutable.
Sep
13
answered Why C++ cannot adopt D's approach for its concept implementation?
Aug
4
comment What does C++ do better than D?
Well, aside from whether C++ references can ever be null, the current answer looks correct.
Aug
2
comment What does C++ do better than D?
So yes, being able to have a class reference which is non-nullabe would be nice, but C++ manages to do what you're showing because it allows for classes to be on the stack and allows for pointers to be dereferenced. And while you can dereference pointers in D, classes are references, not pointers, so you can't dereference them. Since you can't put them on the stack, and you can't dereference them, there is no way built into D to have a class which can't be null. It is a loss, but NonNullable will fix it, and the gains from the separation of structs and classes are generally greater anyway.
Aug
2
comment What does C++ do better than D?
You're confusing things. Classes are always references, and that's separate from ref. References in D are like references in Java. They're managed pointers. Passing or returning by ref is like passing or returning with & in C++. Passing a class reference by ref is like passing a pointer in C++ with & (e.g. A*&). Classes don't go on the stack. Yes, NonNullable would make it possible to have a class reference which was guaranteed to be non-null, but that's completely separate from ref. What you're trying to do in the C++ code doesn't work in D because classes don't go on the stack. Structs do.
Aug
1
comment What does C++ do better than D?
Both function arguments and return values in D can be marked with ref to give you the same effect as C++'s &. The one major difference is that ref won't take a temporary even if it's const.
Jul
31
awarded  Good Answer
Jul
31
revised What does C++ do better than D?
deleted 5 characters in body