D- ? Is D Programming Language Just Too Much?
First of all for those of you who have not heard about it, D Programming Language http://d-programming-language.org/ .
The first time I looked at the language garbage collection scared me away. I don't really like having my program stop randomly to collect garbage. The second time the write up on garbage collection put me on the fence. After taking a good look I notices that the language had some fantastic features. Many of them being related to re-doing (removing) the pre-processor and make it more like regular code. I also loved delegates something that was a pain in the @$$ to do in C++. But, after looking through the language I found that a lot of things were really quite unnecessary. Guido van Rossum (creator of python) popped into my head thinking that there should be one clear way to do things. For example, closures. Fantastic for scripting languages because they are quick and easy. For the same reason that the are awesome for replacing macros. But, as soon as you return them from a function I think you want a class. Writing code like this is about writing something that can be evolved. A function that returns a function is just a class constructor with one method. Now try to add a second one. Oops. Also, I find that too much is implemented in the language instead of libraries. This is one of the things that made C so powerful. You started with noting but if you wanted you have access to a wonderful standard library. In D string is a built-in and all of the functions that work with is are just sitting around in the global namespace. They did the same things with arrays. The say that an array carries around no bounds information. This is true and a great reason to wrap it in a class that implements an array interface. Then you can extend it at will and all of the functions you need are right there in that namespace. I don't think that C++ needed to have new features. The syntax and symantics just needed to be cleaned up and re-worked. I'm not saying that D sucks. In fact I love it. The language took a bold step forward with the beloved C/C++ style and did a lot of cleaning up. The only problem is I think it went a little overboard. The things that I like most about D is that it has build in standardized support for unit testing and documentation. Making it easy to ensure you codes works and a small update doesn't break anything, and makes it easy for other people to know what your code does (or you a year from now). I have one more nit that I am going to pick before I shut up. I think using the old build system was a bit of a mistake. The reason why I started looking for a new programming language after loving C/C++ for a good number of years is that the #include's suck. They really do. You have to keep the header file and the source file and compile them correctly. If you write a library you need to ensure that people using it link their program with the proper libraries and la-deda-deda. I was looking something like an import style inclusion where everything is included once and the imported namespace is controlled. Unfortunately D doesn't do this how I would like. D sticks to old tools for compiling and linking. This means that imports aren't automatically compiled and linked as necessary. I would love to go compile app.d and have the whole application build and linked for me. In the new days of programming languages is think it would be good to have the build info built right into the file. So I was wondering what you guys thought about D and evolutions of C. Another last thing. In the title I made a D- joke, I wasn't really intending to make a new language. I don't know squat about compiler writing or the like. But if someone/somepeople (preferably more that one person) share some views I would be prepared to put some time into helping this project happen. Just an offer :P |
Quote:
Can I say that C++ sucks? C rules. So does Ada :) But I'm guessing that D is more or less irrelevant now that we have F#. |
D should not be seen as a successor of C or C++, that is nonsense.
it is a nice "new" (not rely) programming language with tons of cool features unfortunately it is out since years now but it is still not part of distributions, with the 1.x series there was the tango/phobos quirks and some other stuff, but with 2 things become somehow better and I still have the hope that someday it will be more in use. since some years, don' know exactly how many but enough, it is meanwhile somehow a tradition for me to go once or twice a year to d programming language, play around with it and think ok, lets wait an other year... |
Quote:
Quote:
Quote:
Btw, C++11 will have closures. I think it would be silly to have delegate literals/lambda functions but not closures. Quote:
Code:
alias immutable(char)[] string; // somewhere in object.d which is implicitly imported to every D module Quote:
Quote:
To the namespace thing: There is no global namespace in D, only module namespace, and most operations on a strings are actually implemented in the library. The design for uniform function call syntax (you can use method call syntax for non-member functions on arrays) should probably be generalized to be less ad-hoc and to work with other data types as well. But so far it has worked quite well. Btw, no standard library implements all useful string facilities. In D you can just extend them with custom functions and use the array.function syntax with them as well. Quote:
And even with C++11, C++, language-wise, does still not hold a candle to D. Quote:
In fact that is a common reaction from programmers coming from a C++ background. In C++ the argument "if it can be done in the library in some half-assed way, it does not have to be a language feature" has real value, because changing the C++ language is a pita, as it has so much legacy and a no-breaking-change policy. If you design everything from scratch in the way 'it should actually have been done', you have much more freedom to make things that should be language features, well, language features. Quote:
Quote:
Quote:
|
My sense concerning language projects like "D" is that the driving opinion is that "C++ is too much (for me and my project). My engineering needs would be served by a simpler language that provided, e.g. automatic garbage-collection, without throwing in a lot of other stuff that I don't need or want."
If your software engineering needs are consistent with that, then "D" might be the cat's meow for you. If they're not, it's not a condemnation of the language itself. |
Thanks for all of the insights. A lot of you mentioned the "built-in" string class. What I mean is best showed with a code example.
Code:
string str0 = "Hello World!"; |
Quote:
I think sort and reverse should not be built-in, but it does not normally hurt at all. (edit: apparently they will even eventually get deprecated) Quote:
edit: I did not look close enough into your code. It could be written as: Code:
import std.string; Quote:
|
Quote:
Quote:
Quote:
alias immutable(char)[] string; A D string is literally just an array of immutable characters. (Well, actually, a D 'char' is a UTF-8 code-unit, but the point is, a D string is literally just an array.) Quote:
Quote:
Code:
struct Array(T) Quote:
Code:
void foo(T)(T[] a, string blah) Quote:
Code:
> rdmd --build-only -ofapp app.d Code:
@echo off |
Quote:
Code:
str0.rightJustify(10); |
I think that it's also worth noting that, now that CPUs and so-forth are just so dammed fast, nowadays ..., computer programming languages can often easily afford to be "sloppy." Or to put it another way, "sloppy," interpreted tools can be used.
Having said that, let me very quickly concede the fact that languages such as "C" or "D" are the ones that are used to build these other tools. Hence, they do retain and always will retain their vital place. However, having said that, the sheer firepower that can be made available at moderate cost ("throw silicon at it ...") makes those "sloppy" higher-level tools become very attractive indeed in situations where lower-level tools once would have been the most logical choice. Ruby, Perl, PHP, Python, even dot-NET, all exploit the fact that CPU-power is today not nearly so much "a resource that must be conserved like water in the desert." Given that "80% of the time is spent in 20% of the code," that "80% of the time" can be spent in highly-optimized, yet "wasteful," interpreter core-code. The "C" language is primitive. (By design, I might add ... and it's also a middle-aged fortysomething ... which a-HEM! is not 'old' :tisk: at all!!) Therefore, there are always opportunities to improve upon it, and to that end, an incremental improvement strategy (such as the one "D" takes) is quite valuable. As others have said, well-seasoned designers who have produced excellent results in the past are working on it, and with good reason. |
Quote:
Quote:
|
Quote:
|
Quote:
I looked over the conceptual background of D on its homepage and the creators acknowledge all of my main complaints about C and C++. They seem to have taken these issues into account with the design, rather than justifying their design after the fact. Whether or not their solutions are agreeable is another question; I have no experience with D. They do treat the developer like an actual adult with experience and the ability to make his/her own judgments, though. One critical feature I noticed about D is the C ABI compatibility. That certainly beats inventing an IPC protocol or writing language bindings to access existing libraries (e.g. POSIX functions). One of the main problems I have with Java is it was designed to be too universal, without any concept of interacting with non-Java programs or libraries. I don't think having a large number of features and/or functionality is inherently negative. There are certainly a lot of ways to make additional features a negative thing:
Quote:
Thanks for bringing this up! I looked into D several years ago, probably because of a thread on this board, and I didn't really care for it at the time. It looks like it's come a long way, though, and I'm not nearly as "loyal" to C++ as I was back then (I've probably become proficient in 3 new languages since then). Kevin Barry |
Quote:
Kevin Barry |
Quote:
|
All times are GMT -5. The time now is 11:15 PM. |