Did C# surpass C++ in popularity, or did I miss something?

Started by
117 comments, last by wyrd 19 years, 11 months ago
Old women laugh at you people.
Advertisement
quote:Original post by Arild Fines
quote:Original post by Max_Payne
even perform arithmetic on them.

And as we all know, that's *very* useful...


Actually, it *IS* useful, for memory manipulation.

quote:
quote:
Pointers work quite well too... You just need an elementary understanding of how a computer works to understand the concept.

I understand the concept of pointers perfectly well, thank you very much. Are you trying to imply that I'm not?


I didn't imply anything... Do you feel insecure about the topic or something?

quote:
quote:C# may not use "pointers" in the way you use them in C, it has to use references in a form or another.

Are you trying to educate *me* on how pointers work in C#?

What you said was utterly and completely wrong. In the future, ask yourself "Do I really know anything about this?" before you hit the "Reply to topic" button.


Now, what the hell is your problem? What I said was absolutely true. You're the one who's not bringing anything into this discussion... You don't even have any arguments.

I will return you your own compliment: Think before you reply.


Looking for a serious game project?
www.xgameproject.com

[edited by - Max_Payne on May 26, 2004 9:14:58 PM]

Looking for a serious game project?
www.xgameproject.com
quote:Original post by the Speed Bump

You sure?

std::string s;
s = "Hello " + "World";



Yes, I'm sure, take your pick:

std::string s;
s = "Hello ";
s += "World";

or

std::string s;
s = std::string("Hello ") + std::string("World");

and if neither of those work for you, C++ is one of the few languages that gives you the flexibility to write your own string class.


[edited by - EvilSteve on May 26, 2004 9:45:49 PM]
quote:Original post by Arild Fines
quote:Original post by Magmai Kai Holmlor
It''s blantantly false that you have to use raw pointers in C++ to use dynamically allocated memory.

Last time I checked, both new and malloc returned pointers.

Obviously, don''t use malloc unless you have a particularly good reason.

new might return a pointer, but does that mean you have to use it?

std::auto_ptr<int> pi = new int; 


Now, if you''re complaining that C++ uses pointers behind the scenes, even if you don''t explicitly use pointers, then show me a language doesn''t use pointers behind the scenes for dynamically allocated objects.
CoV
quote:Original post by EvilSteve
quote:Original post by the Speed Bump

You sure?

std::string s;
s = "Hello " + "World";



Yes, I'm sure, take your pick:

std::string s;
s = "Hello ";
s += "World";

or

std::string s;
s = std::string("Hello ") + std::string("World");

and if neither of those work for you, C++ is one of the few languages that gives you the flexibility to write your own string class.

Erm. A whole lot of languages give you that flexibility (including C#). The world is <edit>not</edit> divided into C++ and Java.

It's a shame that C++'s legendary flexibility doesn't run to allowing me to define:

const char *operator+ (const char *a, const char *b) {  char *t = new char[strlen(a) + strlen(b) + 0];  strcpy(t,a);  strcat(t,b);  return t;}   


You might say that operator+ is already defined for char *, but C++ is imagined to support generic types: the standard operator+ that applies to pointers can therefore be defined as <template T> T *operator+ (T *, T*);, and the above definition becomes a template specialisation.

<edit>Or, if for some reason you'd rather it vaguely resembled valid C++, template <typename T> T *operator+ (T *, T *)</edit>

[edited by - Mayrel on May 26, 2004 10:17:10 PM]
CoV
quote:I personally don''t like the whole "the pointers are the source of all evil" philosophy. I think people need to realise that the source of all bugs is not in the programming languages, but rather incompetence, negligence, procrastination and the "WE MUST DELIVER THIS SOFTWARE SUPER FAST" type of pressures.


That''s the smartest thing I''ve read on the whole language vs. language debate in a long time.

quote:Original post by Max_Payne
quote:Original post by Arild Fines
quote:Original post by Max_Payne
even perform arithmetic on them.

And as we all know, that''s *very* useful...

Actually, it *IS* useful, for memory manipulation.

That''s kinda vague, isn''t it? ''Memory manipulation''?

Now, I agree that pointer arithmetic can be useful. But only for moving a pointer within the bounds of an array. A language can use a specialisation of pointers for ''pointing into an array''. I call them cursors, C++ calls them iterators, I think C# calls them iterators as well this week.

If you''re limiting your use of ''memory manipulation'' with pointer arithmetic to such things, then it''s worth considering that a pointer that is only ever used to point into an array is effectively just syntax sugar for a reference to the array and an integer index.

Of course, there''s still a pointer in the form of a reference to the array. But you shouldn''t (IMO) be allowed to do pointer arithmetic on that.

int *array = new int[10];int *index = &array[0];++array; // This shouldn''t be allowed.++index; // This is okay. 


It should be obvious that you can''t sensibly do this without changing the syntax for array and/or cursor types.
CoV
quote:Original post by Mayrel
Erm. A whole lot of languages give you that flexibility


I would be interested in hearing your extensive list of languages that give you the flexibility to write your own string class without encapsulating an existing string class...
quote:Original post by EvilSteve
quote:Original post by Mayrel
Erm. A whole lot of languages give you that flexibility


I would be interested in hearing your extensive list of languages that give you the flexibility to write your own string class without encapsulating an existing string class...

I would be interested in hearing why you said "without encapsulating an existing string class", when the post to which I was replying listed so such requirement.

Given that requirement, the list of languages is shorter. I can think of only two off hand: D and Common Lisp.

This is because in most other well-designed languages, the thing that a "string" is is already what you would probably consider a class.

Why, precisely, do you consider it important to be able to write a string class without encapsulating an existing string class? You don''t like code reuse?
CoV

Because there is a difference between *writing* a string class, and *redirecting* to another string class. One allows for greater efficiency than the original class and one does not.


[edited by - EvilSteve on May 26, 2004 10:43:21 PM]

This topic is closed to new replies.

Advertisement