Mancubus
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Misc. > Everything Else > The D Programming Language
 
Author
All times are GMT. The time now is 19:59. Post New Thread    Post A Reply
flubbernugget
Junior Member


Posts: 209
Registered: 06-09


Just found out about the D programming language, and it looks pretty interesting. It's a lot like C++, but it adds new features and helps to get rid of many of the more confusing aspects of C++ like the scope operator. It also adds a lot of features seen in more high level languages like array slicing and foreach loops.Right now, it is somewhat tough to learn how to use because it is still an obscure language and has obscure documentation to complement it, but for experienced programmers the language should be pretty straightforward to learn.

What I really like about the language is that it can conform to the high level and low level needs of individual projects. For example, D has a garbage collector, but if need be it can be disabled for manual memory management and maximum efficiency.

The biggest problem I see with D is that it advocates variable declaration similar to that of Python where data types are implied instead of explicitly stated. Although it provides some write-time convenience, in the long run features like the auto keyword make figuring out the type of data when reading code harder than it should have to be. However, this is a fairly minor issue with D.

Has anybody else worked with D? What are your thoughts on it?

D's home page:

http://dlang.org/

Old Post 01-27-13 15:30 #
flubbernugget is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
andrewj
Senior Member


Posts: 1606
Registered: 04-02


I looked at it years ago and I didn't find it very compelling -- I don't remember exactly what put me off, perhaps because it tries to do too much.

Old Post 01-28-13 00:10 #
andrewj is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Maes
I like big butts!


Posts: 11795
Registered: 07-06


It does nothing that can't be done by throwing enough add-ons and libraries to C/C++. Speaking of which, it's too much like C/C++ to really be as "easy" as Java or .NET, little incentive to use it as a primary development language since you'll need to interface with existing code or libraries in C or C++ anyway, and the results won't be backwards compatible or portable to other compilers, why not use C or C++ then?

Old Post 01-28-13 00:28 #
Maes is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
flubbernugget
Junior Member


Posts: 209
Registered: 06-09



Maes said:
It does nothing that can't be done by throwing enough add-ons and libraries to C/C++.



Maes said in a previous thread about source ports:
...aka the "but it compiles on my computer" scenario. Source code distribution != complete development environment.


So lets throw more libraries into C++ instead of implementing those features directly into a language so compilation is easier. Syntax is also less uniform with multiple libraries from different developers.

In all honesty though, as a new programmer I will admit that a big reason I decided to learn D was because of all the bad things I hear about C++, and since most of my programming is as a hobby I don't have to worry about industry standards.

Old Post 01-28-13 02:22 #
flubbernugget is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Wagi
Member


Posts: 325
Registered: 11-10


I saw people advocating D a long time ago, but I had absolutely no clue people were still trying to use it. "For-each" loops have already been implemented into C++11 in the form of range-based for, and I honestly have never seen a situation where array slicing is a genuinely a must-have feature.

The scope operator isn't a difficult concept to understand either --- Use a period if you're trying to access an object's data, and the scope operator if you're referring to something that belongs to an enum, namespace, or class.

Old Post 01-28-13 05:06 #
Wagi is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Belial
Senior Member


Posts: 2175
Registered: 09-05


I see no advantage over C++ with Qt if you want a direct comparison to "C++ with enough libraries".

Old Post 01-28-13 06:36 #
Belial is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Maes
I like big butts!


Posts: 11795
Registered: 07-06



Belial said:
I see no advantage over C++ with Qt if you want a direct comparison to "C++ with enough libraries".


Not only that, but there are also the various "flavors" and "dialects" of C/C++ with vendor-specific extensions, convenience methods/libraries and the various RAD wizards to compete with e.g. Microsoft's C++ (with or w/o .NET, Borland C++ in the past etc. ), Microsoft's MFC libs, Borland Delphi's (still unmatched) drag & drop RAD etc.

Many modern C/C++ projects, especially those developed under Windows, are not as portable as one might think precisely because of that: too much reliance on the development environment, not just the language per-se. In such a scenario, it's a bit hard for a "bare bones" offering like D to find a niche (if you think about it, it could be implemented as syntactic sugar on top of existing C/C++ compilers, while not really novice-friendly enough as .NET or Java to justify using it as a stepping stone or viable alternative, let alone that there are no decent development tools for it unless you like very oldschool coding...)

Old Post 01-28-13 08:52 #
Maes is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
hex11
Forum Staple


Posts: 2237
Registered: 09-09


It's not just Windows stuff that's not portable... A lot of non-trivial C/C++ Linux userland code just doesn't run on any other platforms without heavy modification. The Gnome and KDE ports in particular have been a big source of trouble for OpenBSD to keep up-to-date. I think some of that is related to the compiler itself, as gcc has made it rather difficult for the obsd devs to submit patches, because it's not considered to be a "first tier" OS or something like that. Effectively obsd devs have submitted patches to gcc so it can build and run correctly and they haven't gotten any feedback whatsoever, good, bad or indifferent from the gcc team for months on end. And when they finally do get feedback, the gcc codebase has changed enough to make the obsd patches obsolete. Rince, repeat, etc... I guess that's one reason they want to move away from gcc (at least to the point where the base system doesn't depend on it). But that won't make Gnome/KDE any easier to build. Not that I care, since I wouldn't be caught dead using such "desktop environment" suites, but those complex and bloated beasts are good examples of how non-portable C/C++ code can be.

Old Post 01-28-13 11:26 #
hex11 is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
yukib1t
Will DDR for food


Posts: 2482
Registered: 06-02


Interesting, but not enough parenthesis for me...

Old Post 01-28-13 18:31 #
yukib1t is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
flubbernugget
Junior Member


Posts: 209
Registered: 06-09


Well then I guess my next question would be:

Why do I hear so much hate about C++ when no alternatives seem to be effectively proposed or implemented?

Old Post 01-28-13 21:10 #
flubbernugget is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Maes
I like big butts!


Posts: 11795
Registered: 07-06



flubbernugget said:
Why do I hear so much hate about C++ when no alternatives seem to be effectively proposed or implemented?


Delphi? It offers C-level performance, can do all of C's low-lewel tricks, has objects, properties etc. and comes with a kickass RAD component-based development model, still unmatched by even the most advanced wizard Visual Studio can offer. BTW, the C# language was designed by the creator of Delphi...should say a lot ;-)

Old Post 01-28-13 21:18 #
Maes is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
exp(x)


Posts: 2595
Registered: 04-04


C++ haters are just whiners.

Old Post 01-28-13 22:35 #
exp(x) is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Maes
I like big butts!


Posts: 11795
Registered: 07-06


Now that I think about it, there's always Objective-C...a true Apple fanboy should code in nothing but that ;-)

Old Post 01-28-13 22:49 #
Maes is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
printz
CRAZY DUMB ZEALOT


Posts: 8552
Registered: 06-06



Maes said:
Now that I think about it, there's always Objective-C...a true Apple fanboy should code in nothing but that ;-)
Especially if the low level code gets made only in C, no pluses.

__________________
Automatic Wolfenstein - Version 1.0

Old Post 01-28-13 23:56 #
printz is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Maes
I like big butts!


Posts: 11795
Registered: 07-06


Actually, it's all related: C++ can be viewed as a superset of C with A LOT of syntactic sugar and preprocessors added. Objective-C is actually designed to be a proper superset of C (moreso than C++).

Delphi/Pascal can be mapped almost 1:1 to C (there were even tools that did that automatically)...

Even more disturbingly, if you use a tool like GCJ, it actually compiles Java code into a C (or C++?) intermediate form...so in the end there's no escaping C, is there?

Even the way Doom is coded, the code "reeks" of OO influences from a mile away ;-)

Old Post 01-29-13 00:17 #
Maes is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Blzut3
Member


Posts: 464
Registered: 06-04



flubbernugget said:
Why do I hear so much hate about C++ when no alternatives seem to be effectively proposed or implemented?

I would argue that it's mostly fud. Some old hats don't trust compiler optimizations (back in the day compilers weren't that great at this) and feel that everyone should hand optimize their code. That or they strongly believe that expensive operations should be difficult to write in order to make you think twice. There's also a lack of education in that most of OOP is just syntactic sugar, so some people worry that C++ will automatically slow down their program.

In reality, C++ is pretty much designed to not insert anything unless you explicitly call for it.

Old Post 01-29-13 02:01 #
Blzut3 is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Belial
Senior Member


Posts: 2175
Registered: 09-05


I've never cared for such opinions. It's a tool, everything depends on how you use it.

At my last job there were two guys who did C# exclusively (1 year and 3 years of professional experience). I've heard all the usual nonsense from them (lol pointers, unmanaged, memory leaks, outdated) until one of them was forced to do some C++/Qt stuff for Linux. A year later he used Qt for the next Windows desktop app he was supposed to write because he found it easier to do certain things with it. He'd still use C# if he had to do something server/database related, but for anything optimized for performance (video processing in this case) he'd stick to C++.

Pick the right tools for the goal ahead of you and don't give a damn about other peoples horror stories.

Old Post 01-29-13 06:43 #
Belial is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Maes
I like big butts!


Posts: 11795
Registered: 07-06


The funny thing is that both D and C# let you mix managed and "unsafe" code (though C# makes you jump through hoops whenever you do that). Even Java allows you to do it, through JNI and the infamous Unsafe class.

Old Post 01-29-13 10:02 #
Maes is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
GooberMan
Scripting Nut


Posts: 1170
Registered: 02-01


We're actually using D at work. Yes, an actual video game company is using D. A colleague of mine is well known on the D newsgroups as a result, but he recently left my workplace so now I'm taking over the mantle of D maintenance.

We had an internal game jam a few months back. My team wrote the game logic code in D. It was also the first time I'd programmed anything in the language. I read the first chapter of Andrei Alexandrescu's D book the night before the jam, and had my colleague on hand for any questions I had. I ended up programming with a more C# idiom than D, but I did manage to probe the language to see what it was capable of and made a construction table with one line of code (compared to the 1000-plus-line mammoth files we used to write on the PS2).

There's a lot of stuff I can go in to here, but as I'm at work I'll keep it to a minimum for now.

Old Post 01-29-13 10:45 #
GooberMan is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
gggmork
If you can make any sense of this post, congratulations


Posts: 2653
Registered: 06-07



GooberMan said:
We're actually using D at work. Yes, an actual video game company is using D.


That puts you in a tactical position to make money writing some sort of "game programming in D" or whatever book, assuming there'd be little competition from competing writers, since you suggested few use D to make games, thus making you the only one selling something with that search term. I mean if you don't mind killing trees which is what selling dead tree copies is largely about.
You might think.. "that'd be a lot of work", but you're missing the point. Writing a book about programming isn't about teaching others to program at all (based on every programming book I've ever read). Its all about swindling the suckers who buy it to make money. Just shovel some fast food crap info into a book: "this is what a for loop is" etc. and use an extremely trivial pathetic "game", like tic tac toe or something, as the single recurring example throughout the book. You could write it in a day. Then use sock puppets to make fake positive reviews and fake negative reviews for any competing books. That's what your competition will be doing to you so its necessary to stay competitive.

Old Post 01-29-13 16:04 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
GooberMan
Scripting Nut


Posts: 1170
Registered: 02-01


Not sure if genius or joker.

Old Post 01-29-13 17:37 #
GooberMan is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
GooberMan
Scripting Nut


Posts: 1170
Registered: 02-01


Alright, so it's a double reply. Sue me.

D is quite a nice language to use. Its aim is to be a successor to C++ for low level systems programming. I think it's almost at the point where you could use it as such. In terms of speed, it's almost as fast as C++. There are many language-supported features that are done more efficiently in D than any C++ system could manage, but one major thing that holds it back speed wise is that every method of your classes are virtual by default. But it's a tradeoff with benefits there - D's type system is far more robust and safer than C/C++'s.

Arrays aren't just a pointer. They're a tuple of a pointer and a size. Going outside of the bounds of your array becomes far more difficult as a result. As a result of this, it's also got a fairly elegant solution for strings - as the string keyword is synonymous with immutable char[]. Any array operation is subsequently a valid string operation, including the ~ concatenate operator and slicing arrays for tokenising. It's also a fair sight cleaner than C#'s string implementation, which is the only basic type that behaves as a reference type rather than a value type.

I'm finding a heap of usage out of Universal Function Call Syntax. Basically, a function prototype of R function(T val) can be called in a similar manner to a property, ie val.function. It's not immediately obvious, but it straight up means you can extend the inbuilt types. floatVal.squareRoot for example is entirely possible. I wrote a WAD loader in D as an exercise, and I've found stuff like rotation.DoomRotationToRadians to be pretty handy. Combined with templates, it's a really freaking powerful feature to have.

Speaking of. Templates are far less of a headache than C++. Specialisation is fully supported, so you can restrict your template to certain types or other qualifiers.

There's other cool things too, such as opDispatch. Have you ever wanted to swizzle a vector in C++ code? opDispatch lets you interpret any old accessor string on your classes/structs and decide what to do with it. vector.xzy is completely valid if you've created the correct opDispatch function.

By far the most valuable thing though in D is that the preprocessor has been eliminated. There's still conditional compilation via things like the version keyword (which handles processor architectures, unit testing, etc). static if is also quite valuable in that regard - it basically means that swizzle operator I mentioned above can be compiled away to nothing. But by far the best part with the most ramifications for your coding style is the fact that compile-time code execution is implemented. Any D code you write can be evaluated and run at compile time and thus affect the output of your code. It's meta programming on a whole new level. The kind of stuff you can do it with is nuts. We're using it extensively at the moment, I can't really go in to details yet. Needless to say, it makes #define look as archaic as it actually is, and other metaprogramming solutions weak in comparison. The amount of code it cleans up and effort it saves over the corresponding C++ equivalent is insane. And since you're evaluating stuff at compile time, massive C++ systems can effectively be compiled out to nothing in D.

As D fully supports the C ABI, it can also bind all the commonly used libraries (Phobos in fact has bindings to the C runtime functions). It also has limited compataibility with C++. There isn't a single consistent C++ ABI out there, so D has limited itself to supporting the C++ virtual function table. If you write matching interfaces in C++ and D, you can cross-communicate between the two with your objects.

I'm not an expert on D yet, but I'll be getting more knowledgable and confident in the language both out of necessity and by choice.

Old Post 01-29-13 20:09 #
GooberMan is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 19:59. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Misc. > Everything Else > The D Programming Language

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Message Board Statistics