Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » the D programming language

This thread is locked; no one can reply to it. rss feed Print
the D programming language
ImLeftFooted
Member #3,935
October 2003
avatar

Quote:

Ahh sorry no, its about the same, except D doesn't have that nasty header include c preprocessor crap to deal with.

Yes I enjoy the "nasty header include" feature. Thats not to say its for everybody, but its a feature that I enjoy very much and 'modern languages' appear to be dropping.

Thomas Fjellstrom
Member #476
June 2000
avatar

You actually enjoy having to handle the following:

#define FOO 100+1
int foo = FOO * 2; // does not do what any sane person would expect

And:

// bar.h
#include "foo.h"

// foo.h
#include "bar.h"

Really?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

bamccaig
Member #7,536
July 2006
avatar

Thomas Fjellstrom said:

#define FOO 100+1
int foo = FOO * 2; // does not do what any sane person would expect

If that's what you want it to do then it's very useful. Otherwise, use parenthesis. Oooh, hard.

Thomas Fjellstrom said:

// bar.h
#include "foo.h"

// foo.h
#include "bar.h"

I don't quite understand this part... :-/ Those are useless comments and equally useless comments could be applied in D.

import foo.bar; // zoo.car
import zoo.car; // foo.bar

I don't understand the Java package system... Where the hell do they come from and how do I make mine available on the system!? >:( The answer seems to be with the classpath which means I have to do the same thing as include it, but instead I have to add it to the system's classpath or I have to pass it everytime I compile. I think... >:( Stupid! In college when we built GUI apps using NetBeans everything was automatically set up so the programs would run from the IDE... If you tried to compile and run outside the IDE the classpath was missing a ton of packages and that basically meant we couldn't actually use them... ::)

How does D's (C♭'s) package system work? :-/ Where do the packages come from and how do you add them to a build?

P.S. In the time I've spent trying to learn how D does things I've learned that D's documentation sucks.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

If that's what you want it to do then it's very useful. Otherwise, use parenthesis. Oooh, hard.

Wow. Learn to think once in a while. Its about having to handle that specially. shouldn't be necessary.

Quote:

I don't quite understand this part... :-/ Those are useless comments and equally useless comments could be applied in D.

Doubly for this one. ::)
These comments are there to tell you what file they would be in. Wow.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Onewing
Member #6,152
August 2005
avatar

Quote:

I don't quite understand this part...

He's mentioning the circular logic of bar.h including foo.h and vice versa, which is confusing. It's like trying to define a word by using a word that is defined by the word you are trying to define. Wha? ???

[edit] see above post.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Hard Rock
Member #1,547
September 2001
avatar

Quote:

Doubly for this one. ::)
These comments are there to tell you what file they would be in. Wow.

Does that even work? In any case you can get around this by using forward declaration.

Quote:

I don't understand the Java package system... Where the hell do they come from and how do I make mine available on the system!? >:( The answer seems to be with the classpath which means I have to do the same thing as include it, but instead I have to add it to the system's classpath or I have to pass it everytime I compile. I think... >:( Stupid! In college when we built GUI apps using NetBeans everything was automatically set up so the programs would run from the IDE... If you tried to compile and run outside the IDE the classpath was missing a ton of packages and that basically meant we couldn't actually use them... ::)

I've got a suggestion for you. Why don't you actually try figuring out how it works rather then guessing on something which you apparently know nothing about?

In any case they work nearly identical to dlls. You have a global classpath you can put all your libraries in, you can also just drop them next to the application your are running and they will automatically be detected.

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

spellcaster
Member #1,493
September 2001
avatar

No, it doesn't work. Unless you take care. That's his point.
At some point, this thread moved from "look how nice D is" to "see, C++ isn't THAT bad, see? SEE?!"

--
There are no stupid questions, but there are a lot of inquisitive idiots.

bamccaig
Member #7,536
July 2006
avatar

Thomas Fjellstrom said:

Wow. Learn to think once in a while. Its about having to handle that specially. shouldn't be necessary.

If you were writing the expression you would need the parenthesis anyway. It's no more work than an expression normally requires. And if you actually want FOO*2 to expand into 100+1*2 then it's useful and necessary.

Thomas Fjellstrom said:

Doubly for this one. ::)
These comments are there to tell you what file they would be in. Wow.

A few simple preprocessor instructions handle that. It's nothing that should make or break the deadline.

If you're going to illustrate that it's better to separate them so that it looks like the code is from different sources. It takes of couple of seconds and makes what you're trying to say clear.

bar.h...
#include "foo.h"
foo.h...
#include "bar.h"
Afterall, it's not very often you see a file with a single preprocessor instruction. :)

spellcaster said:

At some point, this thread moved from "look how nice D is" to "see, C++ isn't THAT bad, see? SEE?!"

No, it went from "D does things nicely" to "C/C++ sucks" to "No, C/C++ doesn't suck".

Kitty Cat
Member #2,815
October 2002
avatar

Quote:

And a javadoc-like documentation system is built into the compiler, which means that you'll often get html documentation of the public API by just compiling with the -D argument. It's built in to make it more likely that at least basic docs are available.

One could argue, no docs are better than bad/incomplete/incorrect docs. If you're not willing to take the time to make proper documentation, the "documentation" is generally not worth reading (just look at ALSA).

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

spellcaster
Member #1,493
September 2001
avatar

The point is not that you can't do something with C/C++. It's that some things are - compared to todays standards - not really elegant.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Afterall, it's not very often you see a file with a single preprocessor instruction. :)

Its called an example. Pseudo code even.

Quote:

If you were writing the expression you would need the parenthesis anyway.

Not really:

const int foo = 1+2;
int bar = foo * 2;

You can do that now, and should. But people like their pre processor ::)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

As Snoopy once said, "Good jokes are wasted on birds."

bamccaig
Member #7,536
July 2006
avatar

Thomas Fjellstrom said:

Its called an example. Pseudo code even.

An unclear example is a poor example. Take a second to make your point clear or expect to clarify. And your example was code. Pseudocode is...

bar.h...
include foo.h

foo.h...
include bar.h
Not that included files necessarily belong in pseudocode in the first place. :)

Thomas Fjellstrom said:

You can do that now, and should. But people like their pre processor ::)

Which you can do in C++ as well... You don't need D for that.

Thomas Fjellstrom
Member #476
June 2000
avatar

It was perfectly clear to everyone else. Why not you?

You need hand holding perhaps?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

bamccaig
Member #7,536
July 2006
avatar

Thomas Fjellstrom said:

It was perfectly clear to everyone else. Why not you?

You need hand holding perhaps?

I'm busy with other things. I assumed you were capable of expressing ideas. And "everyone" in this case is like 4 people. ::) Maybe they're just used to interpreting your posts.

Thomas Fjellstrom
Member #476
June 2000
avatar

Yup. Same old bamccaig. Expecting everyone else to hand hold him cause he's "too busy" to think for himself. ::)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Tobias Dammers
Member #2,604
August 2002
avatar

bamccaig: What are you, mentally challenged? The example is perfectly clear. If you have two files, foo.h and bar.h, each one including the respective other, then you are in a nasty situation. Each file is, by itself, perfectly OK, and you cannot see by looking at any one of them that something is wrong. But use them together, and the compiler will yell at you. And while the example is overly simple (as to clarify things: it is boiled down to the essential part), it illustrates the problem in a way that everybody who has encountered circular dependency issues before will recognize it.
Of course it only becomes a problem when a project grows huge, and it isn't obvious at a glance which files exactly cause the problem. And the solution, while simple and easy, isn't a very satisfactory one. Consider these classes:
(parent.h)

#include "child.h"

class cParent {
  protected:
    cChild* child;
    int bar;
  public:
    int get_bar() const { return bar; }
    int get_child_foo() const { if (child) return child->get_foo(); else return 0; }
};

(child.h)

#include "parent.h"

class cChild {
  protected:
    cParent* parent;
    int foo;
  public:
    int get_foo() const { return foo; }
    int get_parent_bar() const { if (parent) return parent->get_bar(); else return 42; }
};

The solution in this scenario would be to put the function bodies of one class into a separate .cpp file, at least those that use an instance of the other class by value, or dereference a pointer to one.

There are 2 problems with this:
- Performance; the out-sourced member functions cannot be inlined. Not a major issue usually, but still.
- Limited templating. If both classes are templates, then we have a problem. Though one might argue that this may be a sign of over-using templates.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

bamccaig
Member #7,536
July 2006
avatar

Tobias Dammers said:

What are you, mentally challenged?

No. Are you?

Tobias Dammers said:

The example is perfectly clear...it illustrates the problem in a way that everybody who has encountered circular dependency issues before will recognize it.

Perfectly clear. ::) I haven't encountered circular dependency issues before. It sounds silly to have two classes each with a member of each other. Do you have an actual correct model where it's applicable? (I've never modeled anything like that before so it's hard to imagine).

spellcaster
Member #1,493
September 2001
avatar

Quote:

Mind you, your example was a million times better than Thomas Fjellstrom's.

Please PM me when we start comparing penis sizes.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Hard Rock
Member #1,547
September 2001
avatar

Quote:

It was perfectly clear to everyone else. Why not you?

I'll probably look like an idiot for writing this, but initially the way you wrote it I didn't follow what you were trying to show either. I can now understand why you wrote it like that (less bbcode) but in any case....

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

ImLeftFooted
Member #3,935
October 2003
avatar

Tobias said:

Of course it only becomes a problem when a project grows huge, and it isn't obvious at a glance which files exactly cause the problem. And the solution, while simple and easy, isn't a very satisfactory one. Consider these classes:
(parent.h)

Exactly! :) and D dumbs down the linking interface so circular dependencies are harder to solve.

On a personal note my style prefers to have the class skeleton in its own file (keeping file size down is an ongoing problem for me).

Jonny Cook
Member #4,055
November 2003

I've always thought that if a program required circular referencing, in many cases, it was because of a design flaw. After working with a program written in C# and seeing how many circular references have been made, and how absolutely horrible it is to work with the code, I'm starting to like C/C++s way of making it hard to do circular references. It prevents people from making circular references all the time, and thus, requires them to put more thought into their design. Of course, that's just my theory. It could be wrong.

The face of a child can say it all, especially the mouth part of the face.

bamccaig
Member #7,536
July 2006
avatar

Dustin Dettmer said:

Exactly! :) and D dumbs down the linking interface so circular dependencies are harder to solve.

Are circular dependencies even an issue in D? I thought the whole point was that D eliminates that problem... :-/

Onewing
Member #6,152
August 2005
avatar

Quote:

Please PM me when we start comparing penis sizes.

"...and I see your Schwartz is as big as mine. Let's see how well you handle it."

------------
Solo-Games.org | My Tech Blog: The Digital Helm

bamccaig
Member #7,536
July 2006
avatar



Go to: