Archived

This topic is now archived and is closed to further replies.

This topic is 4917 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My coding team is attempting to make a compiler for a new programming language called C3 (see-third or see-three) based on C++. Any suggestions? [Edited by - Yohomyth on July 3, 2004 9:51:54 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ROFL. Try some *other* languages. They can be better than C++ in ways you could never imagine.

Share this post


Link to post
Share on other sites
quote:
Original post by Yohomyth
C++ is my favorite programming language, but there are still many things about it that can be better. For example: I would rather use a . than a :: or ->. What do you think?


Har har. I think you should check out c# =)

Share this post


Link to post
Share on other sites
I''m not saying I want to switch to another language. I just posted this to get everyone''s opinion.



-----------------------------------------------
Here comes the Thnikkaman!

Share this post


Link to post
Share on other sites
quote:
C++ can be better...
Duh.

As for opinions on improving C++, there are at least two multiple-page threads where opinions are detailed at length. It''s tiresome. Search for them, using either GDNet''s search tool or Google with the site:gamedev.net qualifier.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Yohomyth
I''m not saying I want to switch to another language. I just posted this to get everyone''s opinion.
You should try out other languages to truly know what is flawed in C++. Some few random opinions here shouldn''t be very interesting or useful to you. And something like needing to use ., -> and :: is a triviality, which I wouldn''t even call a flaw.

Share this post


Link to post
Share on other sites
I am in a high-school, computer profile and my old teacher said that c++ is old(!), so we would switch to C# for our senior year. 10,11th grade we were at C++. What do high-school teachers know about modern programming anyway?

Share this post


Link to post
Share on other sites
Every language has shortcomings and oddities. I use C++, Perl, and Java on a regular basis, Java being my least favorite. In modern languages'' attempts to make programming safer, I feel like they''ve succeeded in nothing more than putting the programmer in a straightjacket. Just MHO...

Share this post


Link to post
Share on other sites
the english language is old. we should switch to esperanto.

Share this post


Link to post
Share on other sites
Biggest thing I would like to see in C++ is protection level as part of the name mangling.

right now if you had a

class temp
{
private:
int this_is_private;
public:
float this_is_public;
};

you can just by changing the header get access to a private member.

class temp
{
public:
int this_is_private;
public:
float this_is_public;
}

I think thats bad. This should have been though of but wasn''t.
Its not a big issue because most programer don''t change headers supply to them but they do have that power.

If protect level was part of mangling then the 2nd class couldn''t find a public int this_is_private because the class in the library won''t have one.

If I create a class put it into a library release the lib and headers I would won''t others to so easy change class so they can get access to data memebers.

Lord Bart

Share this post


Link to post
Share on other sites
Use the PIMPL idiom so clients of your class can''t see the implementation. I suppose they could make the pimpl pointer public and start dorking with it, but they get what they deserve if they do that.

Share this post


Link to post
Share on other sites
Well, yeah, if you''re truly desperate you can just cast the entire object to an array of chars and modify the data directly. I have actually done this to try and debug something once - and it worked - I got the bug! Die bug! Die! :o)

"I would rather use . than ->"
I actually thought this was a troll when I read it?

Share this post


Link to post
Share on other sites
quote:
Original post by dmikesell
Use the PIMPL idiom so clients of your class can't see the implementation. I suppose they could make the pimpl pointer public and start dorking with it, but they get what they deserve if they do that.


The structure of the pimpl isn't given though:


class SomethingImpl;//forward declaration


class Something {
SomethingImpl* pimpl;
};

//or even

class SomethingElse {
class SomethingElseImpl;//forward declaration

SomethingElseImpl* pimpl;
};


[edited by - quorn on June 10, 2004 11:02:39 AM]

Share this post


Link to post
Share on other sites
I, as I''m sure many others who have looked at this post, tried to refrain from replying to this post, but I''d just like to say a few words on the subject.

Alot of the complaints you have brought up concerning C++ are thoughtless. You wake up one day and wonder why your apps are so crappily moulded together just so that they work in some part, and then wonder why C++ has so many "faults" that just make your life that much harder. You pick apart the very features C++ has to offer which in turn make it so powerful.

"Oh my God, someone could just go into the header file and change this variable to public!!111oneone!" Yeah? And? Is it not a programmer''s decision how he or she would like to interact with their object instances? Is it a bug that C++ prevents you from changing a headerfile once it has been initially written? Come on. If you''re so worried, make your cruddy files read only and see how that tickles your fancy. I''m not even going to bother slugging off the other replies.

The more and more I open this thread to read an added reply makes me more and more sick.

Go learn Visual Basic if you can''t be bothered working with something far more rewarding, you clearly have no idea what you''re talking about, and VB has all the features you would ever use anyway.

Sorry for any agression on my part.

Share this post


Link to post
Share on other sites
Well said wAVaRiaN. C++ can be pulled to shreds, took down a peg or two when compared to C#, Java, or any other programming language, and even be completely ignored by some. But that doesn''t stop it from still being the industry standard especially when it comes to games development. Instead of waisting time complaining about what we have or haven''t got why not just learn a language and make some cool programs, it''s certainly more productive.

Share this post


Link to post
Share on other sites
quote:
Original post by proveren
What do high-school teachers students know about modern programming anyway?


Share this post


Link to post
Share on other sites
quote:
Original post by Lord Bart
Biggest thing I would like to see in C++ is protection level as part of the name mangling.

right now if you had a

class temp
{
private:
int this_is_private;
public:
float this_is_public;
};

you can just by changing the header get access to a private member.

class temp
{
public:
int this_is_private;
public:
float this_is_public;
}

I think thats bad. This should have been though of but wasn''t.
Its not a big issue because most programer don''t change headers supply to them but they do have that power.

If protect level was part of mangling then the 2nd class couldn''t find a public int this_is_private because the class in the library won''t have one.

If I create a class put it into a library release the lib and headers I would won''t others to so easy change class so they can get access to data memebers.

Lord Bart
...The point of data encapsulation is not to prevent you from doing something, it''s to prevent you from making mistakes that lead to hard-to-find bugs. There is no reason to change the way it is, and even if it was changed there would still be a way to get around it.

Share this post


Link to post
Share on other sites
Try Nemerle.

Nemerle macros are of the same sort that Lisp has sported for years now. (functions that recieve code, transform it, then return it) I am somewhat surprised that anybody has dared think about implementing a language without them. (it''s not like the idea is new, after all)

(if C++ had them, at least, implementing things like serialization and generating Python bindings wouldn''t be nearly as complex as they are now. c''est la vie)

"Without deviation, progress itself is impossible." -- Frank Zappa

Share this post


Link to post
Share on other sites
Definitely. It should drop headers, introduce delegates (boost::function is a crippled preprocessor/template hack), properties (can be emulated with templates, but it would be more elegant with direct language support), have a typeof keyword (so that functions like min/max can even be expressed in the language), have a finally clause (wrapping stuff in objects so that destructors can release resources is a pain, sometimes finally is more quick n dirty and practical). I''m forgetting a few because I''m writing this from the top of my head.
We can dream tho because the committee is hell bent on maintaining compatibility with classic C, which was probably important in the 80s to lure people over to C++, nowadays I think that argument is horse crap.

Share this post


Link to post
Share on other sites
I think it would be cool if the bool keyword could make a type with flags.



bool Flags
{
a, //1
b, //2
c, //4
d //8
}; //there are 5 bits so the type would use 1 byte of memory

Flags flags;

flags = a | b;
//or
flags.a = true;
flags.b = true;



And I think there should be a way to overload zero checking operators (if there isn't already).



class CMyClass
{
public:
int m_nValue;
bool operator(!CMyClass)(CMyClass &MyClass)
{
if(!MyClass.m_nValue) return true;
else return false;
}



I have lots of other ideas, but chances are they will never be a reality.



-----------------------------------------------
Here comes the Thnikkaman!

[edited by - Yohomyth on June 10, 2004 12:46:12 AM]

Share this post


Link to post
Share on other sites
Sigh...

The reason C++ is so great is that it's very close to the metal. The only (mainstream) things that closer are C and assembly.

Java and C# and friends have traded this in for ease of use.

If you're suggsting that C++ would be better if it did "this" or "that", then you're insane. If you want these extra features use Java or C# (they're very similar). C++ is so great because it isn't bogged down with the unnecessary. There needs to be a language like C++. If all languages were the same - what would be their point.


On the original topic...

You're suggesting that it would be better if C++ just used '.' instead of '::' and '->'

For simple things, you could probably get away with having the compiler automaticly work out weather you ment '.' or '->' or '::' when you used '.', however, there are cases where the distinction is actualy important.

Say for instance, Java - which does things exactly as you say. The thing is with Java is that everything is an object accessed in the same way.

In C++, however, '.' access a member, whereas '->' access a member through a pointer (and '::', accesses a static member, amongst other things). Why would you want to blur this (important ) distinction? Doing so would make things harder, not eaiser.

And of course, this is not to mention the fact you can overload the '->' operator, but not the '.' operator.



This was posted when I was writing my reply.

quote:
Original post by fallenang3l
Definitely. It should drop headers, introduce delegates (boost::function is a crippled preprocessor/template hack), properties (can be emulated with templates, but it would be more elegant with direct language support), have a typeof keyword (so that functions like min/max can even be expressed in the language), have a finally clause (wrapping stuff in objects so that destructors can release resources is a pain, sometimes finally is more quick n dirty and practical). I'm forgetting a few because I'm writing this from the top of my head.
We can dream tho because the committee is hell bent on maintaining compatibility with classic C, which was probably important in the 80s to lure people over to C++, nowadays I think that argument is horse crap.


Now some of these are good ideas. One thing I am particularly fond of are accessors (basicly get/set methods made easy). This was actualy implemented in BCB for C++, because it needed them to maintain compatibility with delphi.

[edited by - Andrew Russell on June 11, 2004 1:01:57 AM]

Share this post


Link to post
Share on other sites
quote:

For example: I would rather use a . than a :: or ->. What do you think?



You never HAVE to use ::, except when declaring a variable of a type that is not in a namespace loaded for that particular module (but is defined), or when accessing objects of a higher scope.

-> is the accessor for pointers. If you don''t want to use it, don''t use pointers! 99% of things that people use pointers for could be done using references instead (and SHOULD BE). In the event that you''re using a pointer instead of a reference, the -> is going to indicate that *HEY* this a pointer to that object, not the actual object itself. Without that particular notation, you could create so many fuck ups in your code that you wouldn''t realize it''s not even funny.

There''s a reason why the language works the way it does. If you don''t like the way it works, use something else.

quote:

I think it would be cool if the bool keyword could make a type with flags.



No, you don''t. Bool is a single variable, not a structure. If you want a templated bitfield, there are already classes in the STL that do that.

Aside from that, there''s no reason for any of that. C++ lets you use bit-wise operators. If you want a bitfield, use a damned integer.


enum eFlags
{
BIT_1 1,
BIT_2 1 << 1,
BIT_3 1 << 2,
BIT_4 1 << 3,
BIT_5 1 << 4,
BIT_6 1 << 5,
BIT_7 1 << 6,
BIT_8 1 << 7
};

// Stuff


if(iFlags & BIT_1)
DoThis();
if(iFlags & BIT_2)
DoThat();


Simple.

quote:

And I think there should be a way to overload zero checking operators (if there isn''t already).



There is no such thing as a "zero checking" operator, nor should there be. when you say "!Object", it means that all data in the object is set to 0''s. What you want to do is alter the reality of boolean algebra, which is a *VERY BAD IDEA*. If you want to test to see if an object is equivilent to a specific value (which is what you ACTUALLY want to do), then overload the == operator (or !=).

Quit trying to make C++ something that it is not. You will NEVER see a major change to the overall way the language works. You will see additions and modifications that make things easier & more efficient, but you will not see changes to the language in general just because people think it would be "better" to do it some other way.

No, it wouldn''t be better. You should use a different language.

(note: this is why I HATE managed C++. If you want to use .Net, use C# - a language that was actually designed for it. Don''t try to hack an existing language).

You might as well #define BEGIN; { and #define END; } and just alter the language altogether.


Share this post


Link to post
Share on other sites
Yeah, I guess it is better to use :: and ->.

But the reason that C++ would be better to have those other features, instead of switching to another language, is because C/C++ has better performance than pretty much any other high-lever programming language, and it could be even better if it could be easier, but still keep the performance.



-----------------------------------------------
Here comes the Thnikkaman!

Share this post


Link to post
Share on other sites
quote:
Original post by Yohomyth
And I think there should be a way to overload zero checking operators (if there isn''t already).


Do you mean a conversion operator? Eg:


class WeirdBooleanClass
{
public:
bool m_bValue;
operator bool() { return m_bValue; }
}

Share this post


Link to post
Share on other sites